Skip to content

Commit 8dbcc99

Browse files
committed
Set amrex.omp_threads = "nosmt"
Improve the performance on Intel and AMD CPUs by default: Avoid oversubscribing the physical number of CPU threads, as is default in OpenMP.
1 parent 4a78861 commit 8dbcc99

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

docs/source/usage/parameters.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Overall simulation parameters
3333
For all regular ImpactX operations, we therefore do explicit memory transfers without the need for managed memory and thus changed the AMReX default to false.
3434
`Please also see the documentation in AMReX <https://amrex-codes.github.io/amrex/docs_html/GPU.html#inputs-parameters>`__.
3535

36+
* ``amrex.omp_threads`` (``system``, ``nosmt`` or positive integer; default is ``nosmt``)
37+
An integer number can be set in lieu of the ``OMP_NUM_THREADS`` environment variable to control the number of OpenMP threads to use for the ``OMP`` compute backend on CPUs.
38+
By default, we use the ``nosmt`` option, which overwrites the OpenMP default of spawning one thread per logical CPU core, and instead only spawns a number of threads equal to the number of physical CPU cores on the machine.
39+
If set, the environment variable ``OMP_NUM_THREADS`` takes precedence over ``system`` and ``nosmt``, but not over integer numbers set in this option.
40+
3641
* ``amrex.abort_on_unused_inputs`` (``0`` or ``1``; default is ``0`` for false)
3742
When set to ``1``, this option causes the simulation to fail *after* its completion if there were unused parameters.
3843
It is mainly intended for continuous integration and automated testing to check that all tests and inputs are adapted to API changes.

src/initialization/InitParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ namespace impactx::initialization
2525
bool the_arena_is_managed = false; // AMReX' default: true
2626
pp_amrex.queryAdd("the_arena_is_managed", the_arena_is_managed);
2727

28+
// https://amrex-codes.github.io/amrex/docs_html/InputsComputeBackends.html
29+
std::string omp_threads = "nosmt"; // AMReX' default: system
30+
pp_amrex.queryAdd("omp_threads", omp_threads);
31+
2832
// Here we override the default tiling option for particles, which is always
2933
// "false" in AMReX, to "false" if compiling for GPU execution and "true"
3034
// if compiling for CPU.

0 commit comments

Comments
 (0)