I am trying to parallelise over experiments, each of which consist of a set of trials (not parallelising over trials). Due to how the library works, I can't follow the mpga example exactly but instead the library I am uses requires use of tbb to parallelise over experiments.
I attached the code to show before the experiments start (start_code) and during a single experiment (experiment_code).
The issue that I am seeing is that, when I set the random seed to 0, the code works fine. Otherwise, for other seeds, the code hangs at some point before the first progress file is being written. It possibly has to do with flushing. I was looking at the definition of reset:
void CSimulator::Reset() {
...
if(m_bWasRandomSeedSet) {
..
}
else {
...
LOG << "[INFO] Using random seed = " << m_unRandomSeed << std::endl;
}
...
/ Reset the loop functions */
m_pcLoopFunctions->Reset();
LOG.Flush();
LOGERR.Flush();
}
I am just wondering if Flushing without writing could be problematic somehow ? More generally, when do you need to flush and is there any possibility it can hang the master ?
I also saw in mpga_example.cpp l.85-88:
Code: Select all
/* The master sleeps to give enough time to the slaves to
* initialize and suspend properly. If not enough time is given
* here, the master will hang later on. */
::sleep(3);
Could you suggest some ways fix this issue ?