Cilk Guide, Meaning , Facts, Information and Description
Cilk is a general-purpose programming language for multithreaded concurrent programming based on ANSI C. Cilk is especially effective for exploiting dynamic, highly asynchronous parallelism, which can be difficult to write in data-parallel or message-passing style.Cilk is particularly effective for programming numerical algorithms, such as matrix factorization and N-body simulations, both dense and sparse. Cilk's runtime system employs a scheduler that allows the performance of programs to be estimated accurately.
Three world-class chess programs have been programmed in Cilk: StarTech, Socrates, and Cilkchess.
Note that if the three underlined keywords are removed, the result is a valid C program, called the serial elision (or C elision) of the full Cilk program. Cilk is a clean extension of C and the serial elision of any Cilk program is always a valid serial implementation in C of the semantics of the parallel Cilk program.Sample code
Below is a recursive implementation of the Fibonacci function in Cilk, with parallel recursive calls:
cilk int fib (int n)
{
if (n < 2) return n;
else
{
int x, y;
x = spawn fib (n-1);
y = spawn fib (n-2);
sync;
return (x+y);
}
}
