First taste of building cilk program on Arch Linux

I bump into cilk that is much like OpenMP this week, and give it a try on Arch Linux:

(1) Follow the Quick start to build Tapir-Meta:

$ git clone --recursive
$ cd Tapir-Meta/
$ ./ release
$ source ./

Please note gcc is the default compiler on Arch Linux, and there is a compile error of using gcc. So I switch to clang:

$ CC=clang CXX=claang++ ./ release

The is simple, just make Tapir/LLVM compilers as the default ones:

$ which clang
$ which clang++

(2) Build libcilkrts (please refer this issue: “/usr/bin/ld: cannot find -lcilkrts” error).

(3) Write a simple program:

$ cat test.c
#include <unistd.h>
#include <cilk/cilk.h>

int main(void)
        cilk_spawn sleep(100);
        cilk_spawn sleep(100);
        cilk_spawn sleep(100);

        return 0;

Build it:

$ clang -L/home/xiaonan/cilkrts/build/install/lib -fcilkplus test.c
$ ldd a.out (0x00007ffdccd32000) => /home/xiaonan/cilkrts/build/install/lib/ (0x00007f1fe4d60000) => /usr/lib/ (0x00007f1fe4b48000) => /usr/lib/ (0x00007f1fe478c000) => /usr/lib/ (0x00007f1fe4588000) => /usr/lib/ (0x00007f1fe436a000) => /usr/lib/ (0x00007f1fe3fe1000) => /usr/lib/ (0x00007f1fe3c4c000)
    /lib64/ => /usr/lib64/ (0x00007f1fe4f7e000)

From ldd output, we can see it links the ibcilkrts library. Execute the program:

$ ./a.out &
[1] 25530
[[email protected] ~]$ ps -T 25530 | wc -l

We can see a.out spawns many threads.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.