openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
301 stars 88 forks source link

Change defaults and allow configuration of Antechamber charge assignment threads #1831

Open Yoshanuikabundi opened 4 months ago

Yoshanuikabundi commented 4 months ago

Is your feature request related to a problem? Please describe.

My machine has a 12-core/24 thread CPU. By default, antechamber spins up 24 threads to charge a molecule. I've found that performance is much better with only 8 threads (~2-4x speedup), though I haven't carefully tested how this varies.

Describe the solution you'd like

Antechamber's threading behaviour can be controlled with the OMP_NUM_THREADS environment variable. When Antechamber is called in assign_partial_charges, this environment variable should be set to a small number (say, n_threads/3) if it is not already set in the environment. IIRC this variable can be set with the subprocessing.run(env: dict) argument so that it doesn't leak to other processes.

In addition, AmberToolsToolkitWrapper() and/or assign_partial_charges() could take an optional n_threads argument that overrides the environment variable.

Describe alternatives you've considered

We could just document this behavior and how it can be configured.