I'm new to OpenMP and for the second time i notice a slow down in code like this:
const Graph::GraphData &graph = graphPerPart[part];
#pragma omp parallel for
for (int borderIndex = 0; borderIndex < newBorders.size(); borderIndex++)
int source = borders[borderIndex].FirstVertex(*mesh);
int target = borders[borderIndex].LastVertex(*mesh);
Graph::DijkstraComputePaths (source, graph.vertex_adjacency_list, min_distance, previous); // this grows both vectors
newBorders[borderIndex].DoSomethingWithTheClosestPath (previous, target, ...); // this also grows some std::vectors
OMP code runs only 0.75 times as fasat as single threaded (VS 2013, quad core).
I guess it is because each thread has to manage memory for the stl::vectors - can this be true and is there a clue to fix this?
This is for a preprocessing tool and avoiding stl surely isn't worth the time,
but usually i get the expected speed ups with very little affort so i'm curious.
Also i'd like to know if OpenMP can get closely as fast as other multithreading techniques for runtime code, because it's so easy to use.