Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ System Partition Configuration
:default: ``false``

Always emit the ``--nodes`` Slurm option in the preamble of the job script.
This option is relevant to Slurm backends only.

This option is relevant for the Slurm backends only.

Expand Down
2 changes: 1 addition & 1 deletion reframe/core/schedulers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __call__(cls, *args, **kwargs):
obj = cls.__new__(cls, *args, **kwargs)
if part_name:
obj._config_prefix = (
f'systems/0/paritions/@{part_name}/sched_options'
f'systems/0/partitions/@{part_name}/sched_options'
)
else:
obj._config_prefix = 'systems/0/sched_options'
Expand Down
3 changes: 2 additions & 1 deletion reframe/core/schedulers/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def emit_preamble(self, job):
)

if self._use_nodes_opt:
num_nodes = job.num_tasks // job.num_tasks_per_node
num_tasks_per_node = job.num_tasks_per_node or 1
num_nodes = job.num_tasks // num_tasks_per_node
preamble.append(self._format_option(num_nodes, '--nodes={0}'))

if job.use_smt is None:
Expand Down
36 changes: 19 additions & 17 deletions reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@
}
]
},
"sched_options": {
"type": "object",
"properties": {
"ignore_reqnodenotavail": {"type": "boolean"},
"job_submit_timeout": {"type": "number"},
"resubmit_on_errors": {
"type": "array",
"items": {"type": "string"}
},
"use_nodes_option": {"type": "boolean"}
},
"additionalProperties": false
},
"stream_handler": {
"allOf": [
{"$ref": "#/defs/handler_common"},
Expand Down Expand Up @@ -242,6 +255,7 @@
"stagedir": {"type": "string"},
"outputdir": {"type": "string"},
"resourcesdir": {"type": "string"},
"sched_options": {"$ref": "#/defs/sched_options"},
"partitions": {
"type": "array",
"items": {
Expand All @@ -256,19 +270,7 @@
"sge", "slurm", "squeue", "torque"
]
},
"sched_options": {
"type": "object",
"properties": {
"ignore_reqnodenotavail": {"type": "boolean"},
"job_submit_timeout": {"type": "number"},
"resubmit_on_errors": {
"type": "array",
"items": {"type": "string"}
},
"use_nodes_option": {"type": "boolean"}
},
"additionalProperties": false
},
"sched_options": {"$ref": "#/defs/sched_options"},
"launcher": {
"type": "string"
},
Expand Down Expand Up @@ -601,9 +603,9 @@
"systems/partitions/time_limit": null,
"systems/partitions/devices": [],
"systems/partitions/extras": {},
"systems*/sched_options/ignore_reqnodenotavail": false,
"systems*/sched_options/job_submit_timeout": 60,
"systems*/sched_options/resubmit_on_errors": [],
"systems*/sched_options/use_nodes_option": false
"{systems,systems/partitions}/sched_options/ignore_reqnodenotavail": false,
"{systems,systems/partitions}/sched_options/job_submit_timeout": 60,
"{systems,systems/partitions}/sched_options/resubmit_on_errors": [],
"{systems,systems/partitions}/sched_options/use_nodes_option": false
}
}
5 changes: 4 additions & 1 deletion unittests/resources/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
'resourcesdir': '.rfm_testing/resources',
'modules': ['foo/1.0'],
'env_vars': [['FOO_CMD', 'foobar']],
'sched_options': {
'job_submit_timeout': 10
},
'partitions': [
{
'name': 'login',
Expand Down Expand Up @@ -63,7 +66,7 @@
'environs': ['PrgEnv-gnu', 'builtin'],
'max_jobs': 10,
'sched_options': {
'use_nodes_option': False
'use_nodes_option': True
},
'processor': {
'arch': 'skylake',
Expand Down
5 changes: 4 additions & 1 deletion unittests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ def test_select_subconfig(site_config):
[['FOO_GPU', 'yes']])
assert site_config.get('systems/0/partitions/0/max_jobs') == 10
assert site_config.get('systems/0/partitions/0/sched_options') == {
'use_nodes_option': False
'use_nodes_option': True
}
assert site_config.get('systems/0/sched_options') == {
'job_submit_timeout': 10
}
assert site_config.get('environments/@PrgEnv-gnu/cc') == 'cc'
assert site_config.get('environments/1/cxx') == 'CC'
Expand Down
19 changes: 14 additions & 5 deletions unittests/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ def exec_ctx(make_exec_ctx, scheduler):

@pytest.fixture
def make_job(scheduler, launcher, tmp_path):
def _make_job(**jobargs):
def _make_job(sched_opts=None, **jobargs):
sched = scheduler(**sched_opts) if sched_opts else scheduler()
return Job.create(
scheduler(), launcher(),
sched, launcher(),
name='testjob',
workdir=tmp_path,
script_filename=str(tmp_path / 'job.sh'),
Expand Down Expand Up @@ -377,16 +378,24 @@ def test_prepare_without_smt(fake_job, slurm_only):


def test_prepare_nodes_option(make_exec_ctx, make_job, slurm_only):
make_exec_ctx(test_util.TEST_CONFIG_FILE, 'generic',
{'systems*/sched_options/use_nodes_option': True})
job = make_job()
make_exec_ctx(test_util.TEST_CONFIG_FILE, 'testsys')
job = make_job(sched_opts={'part_name': 'gpu'})
job.num_tasks = 16
job.num_tasks_per_node = 2
prepare_job(job)
with open(job.script_filename) as fp:
assert re.search(r'--nodes=8', fp.read()) is not None


def test_prepare_nodes_option_minimal(make_exec_ctx, make_job, slurm_only):
make_exec_ctx(test_util.TEST_CONFIG_FILE, 'testsys')
job = make_job(sched_opts={'part_name': 'gpu'})
job.num_tasks = 16
prepare_job(job)
with open(job.script_filename) as fp:
assert re.search(r'--nodes=16', fp.read()) is not None


def test_submit(make_job, exec_ctx):
minimal_job = make_job(sched_access=exec_ctx.access)
prepare_job(minimal_job)
Expand Down