I have a serial application that I parallelized using OpenMP. I simply added the following to my main loop :
#pragma omp parallel for default(shared)
for (int i = 0; i < numberOfEmitters; ++i)
{
computeTrajectoryParams* params = new computeTrajectoryParams;
// defining params...
outputs[i] = (int*) ComputeTrajectory(params);
delete params;
}
It seems to work well : at the beginning, all my worker threads execute an iteration of the loop, everything goes fast, and I have a 100% CPU load (on a quad-core machine). However, after a moment, one of the worker thread stops, and stays in a function called _vcomp::PersistentThreadFunc
from vcomp90.dll
(the file is vctools\openmprt\src\ttpool.cpp
), and then another, etc... until only the main thread remains working.
Does anybody have an idea why this happens ? This starts to happen after about half of the iterations have been executed.