- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to compile and run my first example of fibbonacci with cilk plus langage :
#include
#include
int fib(int n)
{
int x, y;
if (n < 2)
return n;
x = cilk_spawn fib(n-1);
y = fib(n-2);
cilk_sync;
return x+y;
}
int main(int argc, char **argv)
{
int n = 30;
printf("fib(%d): %d\\n", n, fib(n));
return 0;
}
I compile this example as the following :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -ldl -lcilkrts fibonacci.cpp
I have the a.out file as a result :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ls
a.out fibonacci.cpp
Now, how to run it ??
is it as the following :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./a.out
./a.out: error while loading shared libraries: libcilkrts.so.5: cannot open shared object file: No such file or directory
Thank you for your help,
I am trying to compile and run my first example of fibbonacci with cilk plus langage :
#include
#include
int fib(int n)
{
int x, y;
if (n < 2)
return n;
x = cilk_spawn fib(n-1);
y = fib(n-2);
cilk_sync;
return x+y;
}
int main(int argc, char **argv)
{
int n = 30;
printf("fib(%d): %d\\n", n, fib(n));
return 0;
}
I compile this example as the following :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -ldl -lcilkrts fibonacci.cpp
I have the a.out file as a result :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ls
a.out fibonacci.cpp
Now, how to run it ??
is it as the following :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./a.out
./a.out: error while loading shared libraries: libcilkrts.so.5: cannot open shared object file: No such file or directory
Thank you for your help,
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
The problem is that we have to add libraries LIBRARY_PATH and LD_LIBRARY_PATH in path :
amina@amina-laptop:~/projet/cilkplus-install/bin$ export LD_LIBRARY_PATH=/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ echo $LD_LIBRARY_PATH
/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ export LIBRARY_PATH=/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ echo $LIBRARY_PATH
/home/amina/projet/cilkplus-install/lib
it runs ok :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -pthread -o fib fibonacci.cpp -lcilkrts -ldlamina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ls
a.out fib fibonacci.cpp fibonacci_old.cpp
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./fib
fib(30): 832040
But, i have added the libraries after installing the cilkplus branch of gcc, why the librairies are deleted ??
i have to add the librairies each time to run an example ??
The problem is that we have to add libraries LIBRARY_PATH and LD_LIBRARY_PATH in path :
amina@amina-laptop:~/projet/cilkplus-install/bin$ export LD_LIBRARY_PATH=/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ echo $LD_LIBRARY_PATH
/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ export LIBRARY_PATH=/home/amina/projet/cilkplus-install/lib
amina@amina-laptop:~/projet/cilkplus-install/bin$ echo $LIBRARY_PATH
/home/amina/projet/cilkplus-install/lib
it runs ok :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -pthread -o fib fibonacci.cpp -lcilkrts -ldlamina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ls
a.out fib fibonacci.cpp fibonacci_old.cpp
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./fib
fib(30): 832040
But, i have added the libraries after installing the cilkplus branch of gcc, why the librairies are deleted ??
i have to add the librairies each time to run an example ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have another question please :
I want to use the cilkwiew, i add the following lines to fibonnaci example :
int main(int argc, char *argv[])
{
cilkview_data_t d;
int n = atoi(argv[1]);
__cilkview_query(d);
int result = fib(n);
printf("Fibonacci of %d is %d.\n", n, result);
__cilkview_report(d, NULL, "Fib-result", CV_REPORT_WRITE_TO_RESULTS);
return 0;
}
when compiling i have errors :
root@amina-laptop:/home/amina/projet/cilkplus-install/examples/fibonacci# gcc -pthread -o fib2 fibonacci_old.cpp -lcilkrts -ldl
In file included from fibonacci_old.cpp:33:0:
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h: In function void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int):
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:198:52: erreur: void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int) was declared extern and later static [-fpermissive]
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:106:6: erreur: previous declaration of void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int) [-fpermissive]
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h: In function void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int):
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:241:19: attention : deprecated conversion from string constant to char* [-Wwrite-strings]
fibonacci_old.cpp: In function int main(int, char**):
fibonacci_old.cpp:57:3: erreur: cannot convert cilkview_data_t to cilkview_data_t* for argument 1 to void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int)
Have you an idea for this problem ??
Thank you in advance.
I want to use the cilkwiew, i add the following lines to fibonnaci example :
int main(int argc, char *argv[])
{
cilkview_data_t d;
int n = atoi(argv[1]);
__cilkview_query(d);
int result = fib(n);
printf("Fibonacci of %d is %d.\n", n, result);
__cilkview_report(d, NULL, "Fib-result", CV_REPORT_WRITE_TO_RESULTS);
return 0;
}
when compiling i have errors :
root@amina-laptop:/home/amina/projet/cilkplus-install/examples/fibonacci# gcc -pthread -o fib2 fibonacci_old.cpp -lcilkrts -ldl
In file included from fibonacci_old.cpp:33:0:
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h: In function void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int):
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:198:52: erreur: void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int) was declared extern and later static [-fpermissive]
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:106:6: erreur: previous declaration of void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int) [-fpermissive]
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h: In function void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int):
/home/amina/projet/cilkplus-install/include/cilktools/cilkview.h:241:19: attention : deprecated conversion from string constant to char* [-Wwrite-strings]
fibonacci_old.cpp: In function int main(int, char**):
fibonacci_old.cpp:57:3: erreur: cannot convert cilkview_data_t to cilkview_data_t* for argument 1 to void __cilkview_do_report(cilkview_data_t*, cilkview_data_t*, char*, unsigned int)
Have you an idea for this problem ??
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your LD_LIBRARY_PATH and LIBRARY_PATH are both wrong.
Please set your LD_LIBRARY_PATH and LIBRARY_PATH to ~/project/cilkplus-install/lib (or make sure it points to the lib directory of wherever you have installed the gcc compiler).
Thanks,
Balaji V. Iyer.
Please set your LD_LIBRARY_PATH and LIBRARY_PATH to ~/project/cilkplus-install/lib (or make sure it points to the lib directory of wherever you have installed the gcc compiler).
Thanks,
Balaji V. Iyer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We do not yet implemented Cilkview and Cilkscreen support into the Cilkplus GCC.
Thanks,
Balaji V. Iyer.
Thanks,
Balaji V. Iyer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Balaji,
Thank you for your reply,
So, can i use the ctime librairy to compute the time of execution ? :
#include
...
int main(int argc, char *argv[])
{
int n = atoi(argv[1]);
clock_t debut,fin;
debut = clock();
int result = fib(n);
printf("Fibonacci of %d is %d.\n", n, result);
fin = clock();
cout<<"Time of execution : "<<(double)(fin-debut) / (double) CLOCKS_PER_SEC<<" secondes \n";
return 0;
}
The result :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -pthread -o fib2 fibonacci_old.cpp -lcilkrts
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./fib2 30 CILK_NWORKERS=4
Fibonacci of 30 is 832040.
Time of execution : 0.19 secondes
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$
is it correct to know the time of execution on multicore architecture ?
Thank you for your reply,
So, can i use the ctime librairy to compute the time of execution ? :
#include
...
int main(int argc, char *argv[])
{
int n = atoi(argv[1]);
clock_t debut,fin;
debut = clock();
int result = fib(n);
printf("Fibonacci of %d is %d.\n", n, result);
fin = clock();
cout<<"Time of execution : "<<(double)(fin-debut) / (double) CLOCKS_PER_SEC<<" secondes \n";
return 0;
}
The result :
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ gcc -pthread -o fib2 fibonacci_old.cpp -lcilkrts
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$ ./fib2 30 CILK_NWORKERS=4
Fibonacci of 30 is 832040.
Time of execution : 0.19 secondes
amina@amina-laptop:~/projet/cilkplus-install/examples/fibonacci$
is it correct to know the time of execution on multicore architecture ?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page