"threads" for depletion calculations

Is there a way to specify/limit the number of OMP threads used for depletion calculations similar to the optional “threads” argument for openmc.run()?

@stu646 Welcome to the community.

Have you tried setting the environment variable OMP_NUM_THREADS=<number of threads to use>?

1 Like

The use of multiple cores for depletion calculations relies on Python’s multiprocessing module. Right now, there’s no way to set the number of processes that are used for depletion, but if you want to turn off the use of multiprocessing (so that depletion calculations run in serial), you can set:

openmc.deplete.pool.USE_MULTIPROCESSING = False
2 Likes

Thank you for your answer.

I thought of that. I tried at first using Python’s os module
e.g.
import os
os.environ[“OMP_NUM_THREADS”]=“24”;

That had no effect. (Ubuntu 20.04 LTS, running from a Jupyter Python 3 notebook)

What did work: from the bash terminal prior to starting the Jupyter notebook,
$ export OMP_NUM_THREADS=24

I really wanted to do it from within the notebook but it’s better than nothing.

Thank you, again for your answer.

Best Regards,
Stu

Hi Paul,

Thank you.

Based in part on Ariful’s suggestion I tried (again) with OMP_NUM_THREADS but instead of trying to set from within Jupyter (using os.environ) I simply used export OMP_NUM_THREADS=… from the command line.

It’s not as clean as making that adjustment from within python/Jupyter but it it’s probably preferable to doing the entire calculation in serial.

Thank you, again, for your prompt response.

Best Regards,
Stu

@stu646 my apologies – I misinterpreted what you were asking for. Ariful’s suggestion is correct, although I agree there ought to be a way to specify that directly from Python. I’ll look into adding an option for specifying that in our next release.