I encountered the following problem.
I have an array with size of num_items * length. Pointer to array is pArray.
For each item "i" in the range of num_items, I launch a task. In the execution of this task, I update this array at pArray+i*length.The update length is "length". I used memcpy. The size of data type has been considered.
The code looks like this: pArray is pointer to float array.
memcpy(pArray+length*i, pSourceArray, length*sizeof(float));
pArray is correctly allocated before launching tbb::task.
So in theory, there should not be any memory overlap on writing. The sequential execution of this method has been proved.
However, when I run in parallel version using tbb task, I got glibc, memory corruption error.
Why did I do wrong here? Thanks.