Software Archive
Read-only legacy content
17061 Discusiones

cilkplus limitations?

giannhssdra
Principiante
1.991 Vistas
Hello
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?
Thanks
0 kudos
15 Respuestas
Barry_T_Intel
Empleados
1.991 Vistas
You should never see a Cilk assertion message. These are internal sanity checks.

Can you give me your test application?

- Barry
giannhssdra
Principiante
1.991 Vistas
Here is the code

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

#include
#include
#include
#include
#include

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";

srand(time(NULL));
struct timeval start, end;
gettimeofday(&start, 0);

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

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
Barry_T_Intel
Empleados
1.991 Vistas
Which compiler and OS are you using?

- Barry
giannhssdra
Principiante
1.991 Vistas
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.
Barry_T_Intel
Empleados
1.991 Vistas
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
giannhssdra
Principiante
1.991 Vistas
Thanks for your time.
Another question
I installed this branch http://gcc.gnu.org/svn/gcc/branches/cilkplus/
but there is also this one. http://gcc.gnu.org/svn/gcc/branches/cilkplus-4_7-branch/

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 CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
export OBJC_INCLUDE_PATH=$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
Barry_T_Intel
Empleados
1.991 Vistas
I'm sorry, but I don't know those answers. Balaji will have to answer them on Monday.

- Barry
Balaji_I_Intel
Empleados
1.991 Vistas
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.


Thanks,

Balaji V. Iyer.
giannhssdra
Principiante
1.991 Vistas
Hello

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?

Thanks
Balaji_I_Intel
Empleados
1.991 Vistas
Can you please give us a code example?

-Balaji V. Iyer.
giannhssdra
Principiante
1.991 Vistas
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
giannhssdra
Principiante
1.991 Vistas
Hello

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?
TimP
Colaborador Distinguido III
1.991 Vistas
Wouldn't the default worker stack be larger in 64-bit mode?
Barry_T_Intel
Empleados
1.991 Vistas
None of his sample applications should be stressing the stack size, or even the number of stacks, even in 32-bit mode.

- Barry
Balaji_I_Intel
Empleados
1.991 Vistas
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

start

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

end



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

Thanks,

Balaji V. Iyer.
Responder