Cilk Plus and more

bearophile bearophileHUGS at lycos.com
Wed Dec 14 05:11:11 PST 2011


An computer science popularization article about Cilk and related matters, that I did miss, from the August:

http://software.intel.com/en-us/articles/data-and-thread-parallelism/

It explains the not too much hard to undestand task parallelism with the spawn and sync keywords, the parallel for loops, that haven ot fully enforced constraints:

>The compiler will detect violations and enforce these restrictions in most cases. Exceptions are when the comparison value and index variable are updated through pointers.<


The Intel Cilk Plus Array Notation is similar to the vector syntax of D, you use:

a[:] = b[:] + c[:]

Instead of:

a[] = b[] + c[]

But the complete syntax supports a stride too:

array_base[begin:length:stride]

That allows code like this, similar to the Python NumPy one:

a[0:5][3][0:8:2]

Intrinsic functions like _sec_reduce_add remind me the desire for a sum() in Phobos:

int[] a;
int total = sum(a); // no exception here
assert(total == 0);


The Intel Cilk Plus Elemental Function annotated with __declspec(vector) seem similar to D2 pure functions, but the compieler seems to use them better (so it's not a matter of language, but implementation).


I have a D version too of the Ambient Occlusion Benchmark (AOBench), of course.

In the end a 16.5x with a 4-core CPU is nice.

Bye,
bearophile


More information about the Digitalmars-d mailing list