Thursday, September 10, 2015

Finally - Cilk(TM) Plus in gcc 5.1

gcc 5.1 now has CilkTM Plus support.

Thread level parallelism and vectorization in 27 lines of c++:

#include <iostream>
#include <cilk/cilk.h>

using namespace std;

int main()
{
    int a[8];
    int b[8];

    b[0:4] = 1;
    b[4:4] = -1;

    cilk_for (int i = 0; i < 8; ++i)
    {
        a[i] = i*i;
    }

    a[:] = a[:] * b[:];

    for (int i = 0; i < 8; ++i)
    {
        cout << a[i] << endl;
    }

    return 0;
}

I really, really love this...

No comments:

Post a Comment