What is an ideal data structure in parallel programing, in my case OpenMP.
#pragma omp parallel for
for(int i = 0; i < N; i++)
{
if(table[i] == true)
container.insert(i); // ?? what kind
}
In this example it might be simple if we use a table of similar size. What is a more general data structure for shared-memory parallel programing in C++?
It is best not to rely on shared data structures at all (because you’ll have to rely on locks at some point, which will slow things down). Instead, have each thread write to its own structure, and coalesce the results once the parallel section has completed.