cilkplus limitations?

cilkplus limitations?

Im using this piece of code in my program just to check time differences bettween the serial program and parallel by changing the CILK_NWORKERS

  1. void doSomething() { int k = 10000000; while( --k ); }
  2. cilk_for( int i = 0 ; i < 1000 ; i++ )
  3. doSomething();

No matter what is the value of CILK_NWORKERS( 4, 8, 16 ) half of the times the program runs correctly and half of the times gives this error.
/cilkplus/libcilkrts/runtime/local_state.c:42: cilk assertion failed: fcn
Aborted (core dumped)

or seg fault

Shouldnt the program run nomatter the value of workers?

I was wondering what is a valid value for CILK_NWORKERS.should i leave the default value?

Also about cilk_for is there any kind of limitation i should know?Is there a limitations about the number of iterations?I mean , since every worker works with a queue(fifo) of strands and cilk_for keeps spawning until the number of iterations < grainsize maybe it crashes from to many spawns i dont know.

And its not the only time where i get seg faults where i shouldnt.All my programs half of the times run correctly and half give a seg fault.even the examples from the include files.

Any ideas?

16 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You should never see a Cilk assertion message. These are internal sanity checks.

Can you give me your test application?

- Barry

Here is the code

Also whenever i use cilk_spawn it gives me this wanring
cc1plus: warning: unused variable sf_02 [-Wunused-variable]


double timeDif( timeval& s , timeval& e ) {
double time_in_ms = (e.tv_sec - s.tv_sec) * 1000.0 + (e.tv_usec - s.tv_usec)/1000.0;
return time_in_ms;

void doSomething(){
int k = 1000000;
while( --k );

int main() {

std::cout<<"start of main...\n";

struct timeval start, end;
gettimeofday(&start, 0);

cilk_for( int i = 0 ; i < 1000 ; i++ )

gettimeofday(&end , 0);
std::cout<<"time : "<
std::cout<<"end of main...\n";

return 0;

with the default number of workers the program crashes.
with workers > 8 the program runs but with workers < 8 it gives the errror i told you before

Which compiler and OS are you using?

- Barry

ubuntu12.04 with default compiler gcc-4.6.3
and with cilk /cilkplus/bin/gcc-4.8.0
But also installed gcc 4.7.1 under /home/user not the default installation(i dont know if matters)

You think this has something to do with the os?because i told you even the simpler program somethimes gives runtime errors.

It *shouldn't* have anything to do with the OS, but it's easier to ask up front. But I definitely needed to know that you're working with the GCC compiler, and on a Linux.

If it's a GCC-specific bug it may have to wait for Balaji.

- Barry

Thanks for your time.
Another question
I installed this branch
but there is also this one.

Are they the same ?Should i install the second one?

Are these variables set correct for cilk?for 32bit os

export C_INCLUDE_PATH=/usr/include/i686-linux-gnu:$C_INCLUDE_PATH
export LIBRARY_PATH=/usr/lib/i686-linux-gnu:$LIBRARY_PATH

export GCCDIR=/home/subuntu/cilkplus
export PATH=$GCCDIR/bin:$PATH
export LD_LIBRARY_PATH=$GCCDIR/gmp/lib:$GCCDIR/mpfr/lib:$GCCDIR/mpc/lib:/home/subuntu/cilkplus/lib:$LD_LIBRARY_PATH
export INCLUDE_PATH=$INCLUDE_PATH:/home/subuntu/cilkplus/include

I'm sorry, but I don't know those answers. Balaji will have to answer them on Monday.

- Barry

The most up-to-date one is the cilkplus branch NOT the 4.7 branch.

I dont think the environment variables that need to be set are dfferent on 32-bit and 64-bit machines.

From what I can tell, I think you are setting the library paths correctly.


Balaji V. Iyer.


The compiler gives this warning for every function i use spawn.(sf_02 , sf_03...) even in main
cc1plus: warning: unused variable sf_01 [-Wunused-variable]

And i have this strange behaviour from spawn.
I cant use twice the spawn-sync compination in the same function.
I cant spawn from inside a child.And several other strange things.

And cilk_for always returns this error during runtime and core dumb.
/cilkplus/libcilkrts/runtime/local_state.c:42: cilk assertion failed: fcn

This warning is normal or not?
Does anyone else has the same behaviour with the gcc branch?


Can you please give us a code example?

-Balaji V. Iyer.

These 3 files produce the warnings and errors i told you.
Any chance i did something wrong with the installation?Or since it finished the installation it should work?

Thanks for your time


Downloadtext/x-c++src cilk_for.cpp367 bytes
Downloadtext/x-c++src cilk_spawn.cpp395 bytes
Downloadtext/x-c++src cilk_spawn1.cpp383 bytes


I changed from ubuntu 32bit to 64 bit and now everything seeems to work fine with cilk.No more seg faults
Is this a known problem?

Wouldn't the default worker stack be larger in 64-bit mode?

None of his sample applications should be stressing the stack size, or even the number of stacks, even in 32-bit mode.

- Barry

Hello giannhssdra,
I tried your code-sample onmy 2core32 bit Ubuntu machine and the Cilk_for seem to work for me. I did not get any warnings. It gave me this output which looked correct. Please let me know if I have mistaken.

$ ../../install-test/bin/g++ cilk_for.c -O3 -ldl -lcilkrts

$ ./a.out


iteration : 0 worker : 0

iteration : 4 worker : 1

iteration : 1 worker : 0

iteration : 5 worker : 1

iteration : 6 worker : 1

iteration : 2 worker : 0

iteration : 7 worker : 1

iteration : 3 worker : 0


I am currently looking into the spawn examples and will get back to you when I get an answer.


Balaji V. Iyer.

Leave a Comment

Please sign in to add a comment. Not a member? Join today