Skip to content

Commit dc490b0

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1356 from rsarm/feat/slurm-N-option
[feat] Add configuration option for always emitting `--nodes` in Slurm job scripts
2 parents 2195f68 + 5971855 commit dc490b0

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

docs/config_reference.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,14 @@ Common scheduler options
960960
A list of systems or system/partitions combinations that this scheduler configuration is valid for.
961961
For a detailed description of this property, you may refer `here <#.environments[].target_systems>`__.
962962

963+
.. js:attribute:: .schedulers[].use_nodes_option
964+
965+
:required: No
966+
:default: ``false``
967+
968+
Always emit the ``--nodes`` Slurm option in the preamble of the job script.
969+
This option is relevant to Slurm backends only.
970+
963971

964972
.. js:attribute:: .schedulers[].ignore_reqnodenotavail
965973

reframe/core/schedulers/slurm.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def __init__(self):
112112
self._job_submit_timeout = rt.runtime().get_option(
113113
f'schedulers/@{self.registered_name}/job_submit_timeout'
114114
)
115+
self._use_nodes_opt = rt.runtime().get_option(
116+
f'schedulers/@{self.registered_name}/use_nodes_option'
117+
)
115118

116119
def completion_time(self, job):
117120
if (self._completion_time or
@@ -182,6 +185,10 @@ def emit_preamble(self, job):
182185
self._format_option(job.sched_exclusive_access, '--exclusive')
183186
)
184187

188+
if self._use_nodes_opt:
189+
num_nodes = job.num_tasks // job.num_tasks_per_node
190+
preamble.append(self._format_option(num_nodes, '--nodes={0}'))
191+
185192
if job.use_smt is None:
186193
hint = None
187194
else:

reframe/schemas/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@
279279
},
280280
"ignore_reqnodenotavail": {"type": "boolean"},
281281
"job_submit_timeout": {"type": "number"},
282-
"target_systems": {"$ref": "#/defs/system_ref"}
282+
"target_systems": {"$ref": "#/defs/system_ref"},
283+
"use_nodes_option": {"type": "boolean"}
283284
},
284285
"required": ["name"],
285286
"additionalProperties": false
@@ -424,6 +425,7 @@
424425
"schedulers/ignore_reqnodenotavail": false,
425426
"schedulers/job_submit_timeout": 60,
426427
"schedulers/target_systems": ["*"],
428+
"schedulers/use_nodes_option": false,
427429
"systems/descr": "",
428430
"systems/modules_system": "nomod",
429431
"systems/modules": [],

unittests/test_schedulers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ def test_prepare_without_smt(fake_job, slurm_only):
261261
assert re.search(r'--hint=nomultithread', fp.read()) is not None
262262

263263

264+
def test_prepare_nodes_option(temp_runtime, make_job, slurm_only):
265+
rt = temp_runtime(fixtures.TEST_CONFIG_FILE, 'generic',
266+
{'schedulers/use_nodes_option': True})
267+
next(rt)
268+
job = make_job()
269+
job.num_tasks = 16
270+
job.num_tasks_per_node = 2
271+
prepare_job(job)
272+
with open(job.script_filename) as fp:
273+
assert re.search(r'--nodes=8', fp.read()) is not None
274+
275+
264276
def test_submit(make_job, exec_ctx):
265277
minimal_job = make_job(sched_access=exec_ctx.access)
266278
prepare_job(minimal_job)

0 commit comments

Comments
 (0)