This repo contains tools for building the OpenCilk compiler, runtime, and productivity tools. Specifically, it includes scripts for building OpenCilk from source or building a Docker image of OpenCilk.
OpenCilk has been tested on the following processor architectures:
The present version has been tested on the following operating systems:
cilk_spawn
, cilk_sync
, and cilk_for
keywords are enabled
by using the -fopencilk
compiler flag and including
<cilk/cilk.h>
.cilk_scope
keyword specifies that all spawns within a given
lexical scope are guaranteed to be synced upon exiting that lexical
scope. The cilk_scope
keyword can also be used as a hint that the
runtime system should ensure that Cilk workers are initialized, in
order to quiesce performance measurements. Like the other Cilk
keywords, cilk_scope
is available by using the -fopencilk
compiler flag and including <cilk/cilk.h>
.clang
options as well as advanced linking features,
such as link-time optimization (LTO).-lopencilk-pedigrees
.cilk_reducer(I, R)
to its type, where I
and R
designate the identity and reduce functions for the reducer.-fsanitize=cilk
compiler flag. Cilksan supports
reducers and Pthread mutex locks. In addition, Cilksan offers an
API for controlling race detection, which is available by including
<cilk/cilksan.h>
.-fcilktool=cilkscale
compiler flag.
Cilkscale offers an API for analyzing user-specified code regions,
which is made available by including <cilk/cilkscale.h>
, and
includes facilities for benchmarking an application on different
numbers of parallel cores and visualizing the results.OpenCilk is largely compatible with Intel's latest release of Cilk Plus. Unsupported features include:
__cilkrts_set_param()
.Precompiled binaries for OpenCilk are available for some systems here:
https://github.com/OpenCilk/opencilk-project/releases/. To install,
either download and run the appropriate shell archive (i.e., the .sh
file) or unpack the appropriate tarball. A Docker image with OpenCilk
installed is available from the same page. Some documentation on how
to use the Docker image can be found here: docker.
These precompiled binaries require that standard system header files
and libraries are already installed. These header files and libraries
can be obtained by installing a modern version of GCC (including
g++
) on Linux or by installing a modern version of Xcode on macOS.
For other systems, we recommend instructions for downloading and building OpenCilk from source can be found here.
Reducers: OpenCilk version 2.0 and newer does not support the
Intel Cilk Plus reducer library and instead features a new syntax and
implementation for reducers. The new reducer implementation allows
one to change a local or global variable into a reducer by adding
cilk_reducer(I,R)
to the variable's type, where I
and R
designate the identity and reduce functions for the reducer. For
example, here is how a simple integer-summation reducer can be
implemented using the new reducer syntax:
#include <cilk/cilk.h>
void zero(void *v) {
*(int *)v = 0;
}
void plus(void *l, void *r) {
*(int *)l += *(int *)r;
}
int foo(int *A, int n) {
int cilk_reducer(zero, plus) sum = 0;
cilk_for (int i = 0; i < n; ++i)
sum += A[i];
return sum;
}
To port a Cilk Plus program to OpenCilk, once all uses of unsupported features have been updated, make the following changes to your build process:
-fcilkplus
with -fopencilk
.-lcilkrts
with -fopencilk
.Bug reports should be posted to the GitHub issue tracker. Other queries and comments should be emailed to contact@opencilk.org.
OpenCilk is supported in part by the National Science Foundation, under grant number CCRI-1925609, in part by the Department of Energy, National Nuclear Security Administration under Award Number DE-NA0003965, and in part by the USAF-MIT AI Accelerator, which is sponsored by United States Air Force Research Laboratory under Cooperative Agreement Number FA8750-19-2-1000.
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and should not be interpreted as representing the official policies or views, either expressed or implied, of the United states Air Force, the U.S. Government, or the National Science Foundation. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein.