add numJobs parameter to config

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-03-13 14:22:14 +01:00
parent 16b670e916
commit 567d13e370
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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)