File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 11import os
22
3+ from reframe .core .launchers .mpi import SrunLauncher
34import reframe .core .logging as rflog
45
56perflog_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
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments