Programming in Cilk
OpenCilk makes it easy to parallelize an existing serial C or C++ program.
-
Modify the source file to include the
cilk/cilk.h
header file. -
Expose logical parallelism within the program using Cilk’s three keywords:
cilk_spawn
,cilk_sync
andcilk_for
. -
Compile the program using the OpenCilk compiler by passing the extra compiler flag
-fopencilk
. -
Run the resulting binary.
We also recommend the following best practices for Cilk programming.
-
Use Cilksan to check that your Cilk program is free from unintended races.
-
Use Cilkscale to measure your program’s parallel scalability and zero-in on scalability bottlenecks.