Functions are central in Cilk. We’ll learn about functions with a few different examples.
To compile and run the Cilk program:
Cilk extends C++ with support for parallel programming, but for these simple functions, the syntax is very similar to standard C++. The main differences in Cilk typically come into play when dealing with parallel constructs, which we haven’t used in this basic example.
There are several other features to Cilk functions, particularly related to parallelism. One of the key features is the ability to spawn parallel tasks, which we’ll look at in later examples.