The support of reduction variables in Cilk Plus is outstanding, comparing to OpenMP. However, I was unable to find equivalents to OpenMP's private, firstprivate, threadprivate.For example,
#pragma omp parallel for firstprivate(accessor)
for (int i = 0; i < trip_count; ++i)
{
work(accessor.GetWorkData(i));
}
The above code has 'accessor', which is a simple struct with only POD types. In OpenMP, it is very easy to allocate this 'accessor' per thread, by using firstprivate, or threadprivate.
What would be an optimal approach in Cilk Plus? Of course, I can write the code that allocates thread-private accessors by using thread id returned by __cilkrts_get_worker_number(), while avoiding false sharing. I also think I might able to write a class based on reducer and hyperobject. However, I just want to find a better and elegant solution proposed by Cilk Plus.





