Cilk FAQ - Section 3
Using Cilk


Question 3.1. How do I compile a Cilk program?

Use the cilkc command in the same way you would use gcc. For example, cilkc -O2 program.cilk -o program -lm.

cilkc should accept all gcc options, and in addition it accepts the following three options.

All files that comprise an executable must be compiled and linked with the same set of -cilk-* flags. If not, the linker prints an error message and fails.

Additional cilkc arguments are documented in the programming manual.

Question 3.2. Cilk seems really slow.

Normally, a spawn is 2--6 times slower than a function call, but Cilk becomes much slower when the critical-path measurements are enabled. This problem occurs because Cilk reads the system clock at every thread boundary (i.e. at every spawn, sync, return). Some systems, such as Solaris, have fast user-level clock routines, but other systems, such as Linux, require a system call. If Cilk programs are still unacceptably slow (when compared to the C version), please contact cilk-support@lists.sourceforge.net.

Question 3.3. Can I call Cilk from C/C++/FORTRAN?

Not with Cilk-5.3. We have an experimental ``library version'' of Cilk-5.2 which can be called by C, but it was not incorporated into Cilk-5.3.

Question 3.4. The linker says Cilk_flags_are_wrong_*_please_recompile.

All Cilk files that comprise your program must be compiled and linked with the same Cilk flags. (See Q3.1 `How do I compile a Cilk program?' for a description of the Cilk flags.) If the flags differ, the linker issues and error message like the following:
undefined reference to `Cilk_flags_are_wrong_NODEBUG_NOTIMING_NOSTATS_please_recompile'

Back: Installing Cilk.
Return to contents.

Bradley C. Kuszmaul / bradley@mit.edu - 27 January 2013

Extracted from Cilk Frequently Asked Questions with Answers, Copyright © 2013 Bradley C. Kuszmaul.