I have the following loop that is executed within a lambda function called by TBB and I would like to use a cilk_for instead of the usual for:
//distsq and tmpC3 are arrays of floats
for (int k = 0; k < len1D; k += 1)
int t = k*3;
distsq[k] = tmpC3[t] + tmpC3[t+1] + tmpC3[t+2];
When I do change the for to a cilk_for the program crashes and Parallel Inspector says I have a data race. I assume the race involves distsq[k]; is that right? Do I need to protect distsq? Is it OK to use cilk_for inside a TBB lambda function?