Commit 90bfeb8
committed
Restore setNumOMPthreads in the GROMACS 2025 patch (plumed#1435)
* Restore setNumOMPthreads in the GROMACS 2025 patch
Up to the 2024.3 patch, PLUMED was told how many OpenMP threads GROMACS
was using:
int nth = gmx_omp_nthreads_get(ModuleMultiThread::Default);
plumed_cmd(plumedmain, "setNumOMPthreads", &nth);
When the 2025.0 patch was written against the native PLUMED support that
GROMACS now ships, that call was not carried over. As a result
PLMD::OpenMP::getNumThreads() always returns 1, and actions that
parallelise over OpenMP silently run serially unless the user sets
PLUMED_NUM_THREADS by hand -- which is not something that can be known in
advance on a heterogeneous machine, nor after GROMACS' dynamic load
balancing has redistributed the work.
Reinstate the call in the PlumedForceProvider constructor, behind the same
API-version gate the 2024.3 patch used. The value is available at that
point: gmx_omp_nthreads_init() is called in runner.cpp well before the
force providers are constructed.
Fixes plumed#1407
* regtest: check that setNumOMPthreads reaches OpenMP::getNumThreads
The patch this branch restores works by having the MD code tell PLUMED how many
OpenMP threads it is using, via cmd("setNumOMPthreads"), from the
PlumedForceProvider constructor. Nothing was covering that path.
It cannot be covered from the patch side: patches/ is never compiled by
PLUMED's build (no object is produced under it), and there is no harness that
patches and builds a GROMACS tree. What can be covered, and is what actually
broke, is the mechanism the patch depends on -- that the command is honoured
and is visible to OpenMP::getNumThreads(). When it is not, getNumThreads()
reports 1 and every OpenMP-parallel action silently runs serially: results stay
correct, so only a test like this notices.
Setting the value twice also pins down that the command is re-issuable rather
than latch-once, and 0 is checked because PlumedMain maps it to 1 instead of
passing a meaningless thread count through.
The expected values are fixed (3, 5, 1) rather than machine-dependent:
OpenMP::setNumThreads stores what it is given without clamping.1 parent e1cdfc8 commit 90bfeb8
5 files changed
Lines changed: 53 additions & 0 deletions
File tree
- patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed
- regtest/basic/rt-make-ompthreads
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
118 | 128 | | |
119 | 129 | | |
120 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments