Software Archive
Read-only legacy content
17061 Discussions

GCC Cilk Plus: warning: unused variable 'sf_01;

dsf423
Beginner
507 Views

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)

 

0 Kudos
4 Replies
Balaji_I_Intel
Employee
507 Views

Hi David,

     Is there any specific reason you are using the Cilk Plus branch? To my best knowledge, it is old and not actively maintained. All of Cilk features (with a few exceptions such as Cilk view support) have been merged into GCC mainline. GCC 5.0 should have all of the features and GCC 4.9 should have almost all features except _Cilk_for.

 

Thanks,


Balaji V. Iyer.

0 Kudos
dsf423
Beginner
507 Views

Balaji Iyer (Intel) wrote:

Hi David,

     Is there any specific reason you are using the Cilk Plus branch? To my best knowledge, it is old and not actively maintained. All of Cilk features (with a few exceptions such as Cilk view support) have been merged into GCC mainline. GCC 5.0 should have all of the features and GCC 4.9 should have almost all features except _Cilk_for.

 

Thanks,

Balaji V. Iyer.

No there's not. That's good to know!

I Google searched "gcc cilk plus" and the Cilk Plus build instructions were the first result that popped up, which directs you to download the Cilk Plus branch. I should have seen the repository "last changed date" was 2013!

I'll update again if there's the same problem with GCC 5.0.

Thanks Balaji

0 Kudos
TimP
Honored Contributor III
507 Views

Even with gcc 5.0 updated 2 days ago, it still says __sec_reduce_add(b*c) is invalid built-in, and there's an ICE according to bugzilla 63336. It seems like a lot of effort and waiting to figure this stuff out.

It's interesting that the posted Intel advice still didn't recommend gcc releases until you replied just now.

0 Kudos
TimP
Honored Contributor III
507 Views

I submitted another pr about cilkplus reducer ice which was confirmed. I guess there may be no interest in fixing the problem with array notation  and potentially overlapping pointers.

0 Kudos
Reply