Hi all,
I downloaded and built the gcc47-cilkplus branch. I managed to built the library using binutils version 2.20.1, as I had some problems with versions 2.22 and 2.18. I then tried to experiment with the following code:
#include
#include
int fib (int n) {
if (n<2) return n;
else {
int x, y;
#ifdef cilk
x = cilk_spawn fib (n-1);
y = cilk_spawn fib (n-2);
cilk_sync;
#else
x = fib(n-1);
y = fib(n-2);
#endif
return (x+y);
} }
int main (int argc, char *argv[]) {
int n, result; struct timeval t1, t2;
double time; n = atoi(argv[1]);
gettimeofday(&t1, 0);
#ifdef cilk
result = cilk_spawn fib(n);
cilk_sync;
#else
result = fib(n);
#endif
gettimeofday(&t2, 0);
time=(double)((t2.tv_sec-t1.tv_sec)*1000000+t2.tv_usec-t1.tv_usec)/1000000;
printf ("Result: %dn", result);
printf("Time : %.4fn", time);
return 0;
}
For the compilation I export LD_LIBRARY_PATH and LIBRARY_PATH and I run:
gcc -Wall -Wno-unused-variable -O3 -o fib-serial-gcc47-O3 fib.c -ldl -lcilkrts gcc -Wall -Wno-unused-variable -O3 -Dcilk -o fib-cilk fib.c -ldl -lcilkrts
for the serial and the parallel version. I limit the CILK_NWORKERS to 1 and I get the following results for fib(40): serial :Time : 1.0540 cilk :Time : 27.3902 Even for 8 workers (I have an 8-core machine) cilk reports3.4457...still slower than the serial version! Something seems to be wrong. Maybe something to do with code optimizations? Or do you think something went wrong while building gcc? Kind regards, Kostis





