Quantcast
Channel: Intel® Cilk™ Plus
Viewing all articles
Browse latest Browse all 77

GCC Cilk Plus: warning: unused variable 'sf_01;

$
0
0

Hello, and thank you for your time.

I've just installed a fresh version of GCC Cilk Plus, and my first simple program is presenting an anomalous warning.

/home/david/cilkplus-install/bin/g++ -Wall -O0 -fcilkplus -o hello_cilk hello_cilk.cpp -Wl,-rpath=/home/david/cilkplus-install/lib64  -lcilkrts -lpthread -ldl

In function ‘int fib(int)’:
cc1plus: warning: unused variable ‘sf_01’ [-Wunused-variable]
In function ‘int main(int, char**)’:
cc1plus: warning: unused variable ‘sf_02’ [-Wunused-variable]

I've seen this warning mentioned in some other threads in this forum and other places on the internet, but I never found a definite cause or resolution. I'm curious if the Cilk Plus team has an explanation/resolution (or at least an intuition that this won't cause a problem). 

The program in question:

//Hello to GCC Cilk!
#include <iostream>

const int iterations = 1000000;

void adder( int& a){
        for(int i=0; i < iterations; i++)
                a++;
}

void subber( int& b){
        for(int i=0; i < iterations; i++)
                b--;
}

int fib( int x ){

        if(x <= 1){
                return x;
        }else{
                int y = _Cilk_spawn fib(x-1);
                int z = _Cilk_spawn fib(x-2);
                _Cilk_sync;

                return y + z;
        }
}

int main( int argc, char* argv[]){

        //Classic Cilk test
        std::cout << "Hello Cilk!"<< std::endl;
        std::cout << fib(30) << std::endl; //Should be 832040


        //Generate a race condition just for fun
        int race = 0;
        _Cilk_spawn adder(race);
        subber(race);
        _Cilk_sync;
        std::cout << race << std::endl;

        return 0;
}

The only thing I've noticed is that the warning seems to be associated with the presence of spawn/sync statements in the code, not their invocation. If you comment out the call to fib(30) you'll still get both warnings. If you additionally comment out the definition of fib() then one of the warnings goes away. If you comment out the spawn adder() and following sync statement, the other warning will go away.

This doesn't appear to have affected correctness, fib returns the correct result and the variable race is indeed a proper race condition.  Is there any kind of self-validation included with GCC Cilk Plus?

Thank you for your time!
David

GCC and Linux versions:

/home/david/cilkplus-install/bin/g++ -v

Using built-in specs.
COLLECT_GCC=/home/david/cilkplus-install/bin/g++
COLLECT_LTO_WRAPPER=/home/david/cilkplus-install/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/david/gcc-cilkrts/cilkplus-gcc/configure --prefix=/home/david/cilkplus-install --enable-languages=c,c++
Thread model: posix
gcc version 4.9.0 20130520 (experimental) (GCC)


uname -a

Linux 3.16.0-33-generic #44~14.04.1-Ubuntu SMP Fri Mar 13 10:33:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

I'm not sure how to find the Cilk version number anymore. SVN revision:

URL: svn://gcc.gnu.org/svn/gcc/branches/cilkplus
​Revision: 221750
Last Changed Author: bviyer
Last Changed Rev: 203896
Last Changed Date: 2013-10-21 10:31:38 -0500 (Mon, 21 Oct 2013)

 


Viewing all articles
Browse latest Browse all 77

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>