我该如何编译书记员程序?

时间:2018-08-07 08:00:15

标签: c clang cilk

我按照their website中的说明安装了Cilk。

sudo apt-add-repository ppa:wsmoses/tapir-toolchain
sudo apt-get update
sudo apt-get install tapirclang-5.0 libcilkrts5

我从Cilk documentation复制了以下程序。

#include <stdio.h>
#include <stdint.h>

int64_t fib(int64_t n) {
    if (n < 2) return n;
    int x, y;
    x = cilk_spawn fib(n - 1);
    y = fib(n - 2);
    cilk_sync;
    return x + y;
}

int main(){
   printf("%ld\n", fib(20));
}

然后我使用他们指定的编译器标志进行编译。

clang-5.0 -fcilkplus Fib.c

Fib.c:7:9: error: use of undeclared identifier 'cilk_spawn'
    x = cilk_spawn fib(n - 1);
        ^
Fib.c:9:5: error: use of undeclared identifier 'cilk_sync'
    cilk_sync;
    ^

所需的输出是使用Cilk并显示6765的有效可执行文件。

要生成此可执行文件需要什么魔术?

我正在使用内核4.4.0-45-generic运行Ubuntu 18.04。

0 个答案:

没有答案
相关问题