Skip to content

Commit 48a9ed3

Browse files
author
Samuel Moors
committed
monkeypatch srun launcher
1 parent 44d1f64 commit 48a9ed3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

eessi/testsuite/common_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
from reframe.core.launchers.mpi import SrunLauncher
34
import reframe.core.logging as rflog
45

56
perflog_format = '|'.join([
@@ -143,3 +144,16 @@ def get_sbatch_account():
143144
err_msg += " It is required to set `SBATCH_ACCOUNT` to run on this system."
144145
raise ValueError(err_msg)
145146
return sbatch_account
147+
148+
149+
# Monkeypatch the srun launcher: remove '--cpus-per-task' option:
150+
# we add it ourselves, see the `assign_tasks_per_compute_unit` hook
151+
_srunlauncher_command = SrunLauncher.command
152+
153+
154+
def _srunlauncher_patched_command(self, job):
155+
cmd = _srunlauncher_command(self, job)
156+
return [x for x in cmd if not x.startswith('--cpus-per-task=')]
157+
158+
159+
SrunLauncher.command = _srunlauncher_patched_command

eessi/testsuite/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def assign_tasks_per_compute_unit(test: rfm.RegressionTest):
162162
test.used_cpus_per_task = test.num_cpus_per_task
163163

164164
if test.current_partition.launcher_type().registered_name == 'srun':
165-
# Add again --cpus-per-task to srun, which wins because it is set last:
165+
# Add (again) --cpus-per-task to srun, which wins because it is set last:
166166
test.job.launcher.options += ['--cpus-per-task', str(test.used_cpus_per_task)]
167167
# Make sure srun inherits --cpus-per-task from the job environment for Slurm versions >= 22.05 < 23.11,
168168
# ensuring the same task binding across all Slurm versions.

0 commit comments

Comments
 (0)