Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile fib example on website #75

Closed
hq6 opened this issue Aug 7, 2018 · 2 comments
Closed

Unable to compile fib example on website #75

hq6 opened this issue Aug 7, 2018 · 2 comments

Comments

@hq6
Copy link

hq6 commented Aug 7, 2018

I installed Cilk using the instructions from the website.

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

I copied the following program from the 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));
}

I then compiled using the compiler flag that they specified.

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

The desired output is a working executable that uses Cilk and prints 6765.

What magic incantations are needed to produce this executable?

I am running Ubuntu 18.04 with kernel 4.4.0-45-generic.

@neboat
Copy link
Collaborator

neboat commented Aug 7, 2018

Thanks for reaching out.

You need to include the cilk/cilk.h header file to get the cilk_spawn and cilk_sync keywords. I think that's the only change to the code that you'll need.

Thanks for pointing out the issue. We should add a note about that header on the Cilk Hub website.

@hq6
Copy link
Author

hq6 commented Aug 7, 2018

Thanks! With the header, the program compiles and runs.

@hq6 hq6 closed this as completed Aug 7, 2018
stelleg pushed a commit to stelleg/Tapir-LLVM that referenced this issue Dec 19, 2018
------------------------------------------------------------------------
r314070 | dylanmckay | 2017-09-24 14:07:26 +1300 (Sun, 24 Sep 2017) | 6 lines

[AVR] Implement getCmpLibcallReturnType().

This fixes the avr-rust issue (wsmoses#75) with floating-point comparisons generating broken code.
By default, LLVM assumes these comparisons return 32-bit values, but ours are 8-bit.

Patch By Thomas Backman.
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@314357 91177308-0d34-0410-b5e6-96231b3b80d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants