diff --git a/config_example.py b/config_example.py index 0ac65ad..c2f7fcf 100644 --- a/config_example.py +++ b/config_example.py @@ -20,6 +20,10 @@ dumpXML = 1 visualization = 1 logLevel = logging.INFO +# number of parallel workers. -1: all cores; 1: sequential +# for more details, see joblib.Parallel +numJobs = 3 + # Number of simulation runs with the same parameters for statistical relevance runs = range(10) diff --git a/study.py b/study.py index 914acfe..f557fc2 100644 --- a/study.py +++ b/study.py @@ -50,7 +50,8 @@ def study(): sim.logger.info("Starting simulations:", extra=sim.format) start = time.time() - results = Parallel(-1)(delayed(runOnce)(sim, config, shape) for shape in config.nextShape()) + results = Parallel(config.numJobs)(delayed(runOnce)(sim, config, shape) for shape in config.nextShape()) + end = time.time() sim.logger.info("A total of %d simulations ran in %d seconds" % (len(results), end-start), extra=sim.format)