Skip to content

Commit

Permalink
Add Slurm exclusive flag (hu-macsy#157)
Browse files Browse the repository at this point in the history
* Add Slurm exclusive flag
* Add exclusive flag to docs
* Edit schema to allow num_nodes and exclusive
* Fix is_effective_exclusive
* Change schema to only allow exclusive flag to be set for experiments
* Exclusive flag and num_threads can both be set.
  • Loading branch information
nizomovs authored Feb 1, 2024
1 parent db4bd66 commit 1a01ae3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
5 changes: 3 additions & 2 deletions docs/experiments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ Currently, simexpal supports the following three ``sbatch`` parameters by using
the ``experiments.yml``:

- ``procs_per_node``: number of tasks to invoke on each node (slurm: ``--ntasks-per-node=n``)
- ``num_threads``: number of cpus required per task (slurm: ``-c``, ``--cpus-per-task=ncpus``)
- ``num_nodes``: number of nodes on which to run (N = min[-max]) (slurm: ``-N``, ``--nodes=N``)
- ``num_threads``: number of cpus required per task (slurm: ``-c``, ``--cpus-per-task=ncpus``)
- ``num_nodes``: number of nodes on which to run (N = min[-max]) (slurm: ``-N``, ``--nodes=N``)
- ``exclusive``: boolean flag to run an experiment exclusively on specified computing resources (slurm: ``--exclusive``)

.. code-block:: YAML
:linenos:
Expand Down
20 changes: 14 additions & 6 deletions simexpal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,10 @@ def process_settings(self):
def thread_settings(self):
return extract_thread_settings(self.variant_yml)

@property
def is_exclusive(self):
return self.variant_yml.get('exclusive', None)

@property
def slurm_args(self):
return self.variant_yml.get('slurm_args', [])
Expand Down Expand Up @@ -1114,6 +1118,10 @@ def process_settings(self):
@property
def thread_settings(self):
return extract_thread_settings(self._exp_yml)

@property
def is_exclusive(self):
return self._exp_yml.get('exclusive', None)

@property
def slurm_args(self):
Expand Down Expand Up @@ -1204,9 +1212,7 @@ def effective_process_settings(self):
))
s = variant

if s is not None:
return s.process_settings
return self.info.process_settings
return s.process_settings if s is not None else self.info.process_settings

@property
def effective_thread_settings(self):
Expand All @@ -1221,9 +1227,11 @@ def effective_thread_settings(self):
))
s = variant

if s is not None:
return s.thread_settings
return self.info.thread_settings
return s.thread_settings if s is not None else self.info.thread_settings

@property
def is_exclusive(self):
return self.info.is_exclusive

@property
def display_name(self):
Expand Down
6 changes: 4 additions & 2 deletions simexpal/launch/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ def _represents_int(x):
sbatch_args = ['sbatch', '-J', experiment.display_name]
if self.queue:
sbatch_args += ['-p', self.queue]
if experiment.is_exclusive:
sbatch_args += ['--exclusive']
if ts and ts['num_threads']:
sbatch_args += ['-c', str(ts['num_threads'])]
if ps and ps['num_nodes']:
sbatch_args += ['-N', str(ps['num_nodes'])]
if ps and ps['procs_per_node']:
sbatch_args += ['--ntasks-per-node', str(ps['procs_per_node'])]
if ts and ts['num_threads']:
sbatch_args += ['-c', str(ts['num_threads'])]
log_pattern = '%A-%a' if use_array else '%A'
sbatch_args.extend(['-o', os.path.join(cfg.basedir, 'aux/_slurm/' + log_pattern + '.out'),
'-e', os.path.join(cfg.basedir, 'aux/_slurm/' + log_pattern + '.err')])
Expand Down
6 changes: 5 additions & 1 deletion simexpal/schemes/experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
"type": ["integer", "string"],
"minimum": 1
},
"slurm_args": {"$ref": "#/definitions/str_or_str_list"}
"slurm_args": {"$ref": "#/definitions/str_or_str_list"},
"exclusive": {
"type": "boolean"
}
}
}
},
Expand Down Expand Up @@ -445,6 +448,7 @@
"num_nodes": {},
"procs_per_node": {},
"num_threads": {},
"exclusive": {},
"slurm_args": {}
},
"additionalProperties": false
Expand Down

0 comments on commit 1a01ae3

Please sign in to comment.