Skip to content

Commit

Permalink
Merge pull request #413 from xylar/switch_steps_to_slurm_terminology
Browse files Browse the repository at this point in the history
Switch `Step` attributes from `cores` to `ntasks` and `cpus_per_task`
  • Loading branch information
xylar authored Aug 16, 2022
2 parents d7ce14d + e01ee2d commit 9b29ac3
Show file tree
Hide file tree
Showing 120 changed files with 1,193 additions and 1,063 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def __init__(self, test_group, mesh, calving, velo):
subdir = f'{mesh}.{calving}.{velo}'
super().__init__(test_group=test_group, name=self.name, subdir=subdir)

cores = 36
min_cores = 4
ntasks = 36
min_tasks = 4

# Do fewer runs if FO solver
if velo == 'FO':
Expand All @@ -49,7 +49,8 @@ def __init__(self, test_group, mesh, calving, velo):
calving=calving,
velo=velo,
calv_dt_frac=frac,
cores=cores, min_cores=min_cores, threads=1)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=1)
self.add_step(step)

# no configure() method is needed
Expand Down
25 changes: 13 additions & 12 deletions compass/landice/tests/calving_dt_convergence/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RunModel(Step):
``streams.landice.rst``
"""
def __init__(self, test_case, name, mesh, calving, velo, calv_dt_frac,
subdir=None, cores=1, min_cores=None, threads=1,
subdir=None, ntasks=1, min_tasks=None, openmp_threads=1,
suffixes=None):
"""
Create a new test case
Expand Down Expand Up @@ -52,17 +52,17 @@ def __init__(self, test_case, name, mesh, calving, velo, calv_dt_frac,
subdir : str, optional
the subdirectory for the step. The default is ``name``
cores : int, optional
the number of cores the step would ideally use. If fewer cores
ntasks : int, optional
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
cores as long as this is not below ``min_cores``
tasks as long as this is not below ``min_tasks``
min_cores : int, optional
the number of cores the step requires. If the system has fewer
than this number of cores, the step will fail
min_tasks : int, optional
the number of tasks the step requires. If the system has fewer
than this number of tasks, the step will fail
threads : int, optional
the number of threads the step will use
openmp_threads : int, optional
the number of OpenMP threads the step will use
suffixes : list of str, optional
a list of suffixes for namelist and streams files produced
Expand All @@ -76,10 +76,11 @@ def __init__(self, test_case, name, mesh, calving, velo, calv_dt_frac,
if suffixes is None:
suffixes = ['landice']
self.suffixes = suffixes
if min_cores is None:
min_cores = cores
if min_tasks is None:
min_tasks = ntasks
super().__init__(test_case=test_case, name=name, subdir=subdir,
cores=cores, min_cores=min_cores, threads=threads)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

# download and link the mesh
if mesh == 'mismip+':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, test_group, mesh_type):
for procs in [1, 4]:
name = '{}proc_run'.format(procs)
self.add_step(
RunModel(test_case=self, name=name, subdir=name, cores=procs,
threads=1))
RunModel(test_case=self, name=name, subdir=name, ntasks=procs,
openmp_threads=1))

input_dir = name
name = 'visualize_{}'.format(name)
Expand Down
25 changes: 13 additions & 12 deletions compass/landice/tests/circular_shelf/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RunModel(Step):
``streams.landice.rst``
"""
def __init__(self, test_case, name='run_model',
subdir=None, cores=1, min_cores=None, threads=1,
subdir=None, ntasks=1, min_tasks=None, openmp_threads=1,
suffixes=None):
"""
Create a new test case
Expand All @@ -34,17 +34,17 @@ def __init__(self, test_case, name='run_model',
subdir : str, optional
the subdirectory for the step. The default is ``name``
cores : int, optional
the number of cores the step would ideally use. If fewer cores
ntasks : int, optional
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
cores as long as this is not below ``min_cores``
tasks as long as this is not below ``min_tasks``
min_cores : int, optional
the number of cores the step requires. If the system has fewer
than this number of cores, the step will fail
min_tasks : int, optional
the number of tasks the step requires. If the system has fewer
than this number of tasks, the step will fail
threads : int, optional
the number of threads the step will use
openmp_threads : int, optional
the number of OpenMP threads the step will use
suffixes : list of str, optional
a list of suffixes for namelist and streams files produced
Expand All @@ -57,10 +57,11 @@ def __init__(self, test_case, name='run_model',
if suffixes is None:
suffixes = ['landice']
self.suffixes = suffixes
if min_cores is None:
min_cores = cores
if min_tasks is None:
min_tasks = ntasks
super().__init__(test_case=test_case, name=name, subdir=subdir,
cores=cores, min_cores=min_cores, threads=threads)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

for suffix in suffixes:
self.add_namelist_file(
Expand Down
4 changes: 2 additions & 2 deletions compass/landice/tests/dome/decomposition_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, test_group, velo_solver, mesh_type):
for procs in [1, 4]:
name = '{}proc_run'.format(procs)
self.add_step(
RunModel(test_case=self, name=name, subdir=name, cores=procs,
threads=1, velo_solver=velo_solver,
RunModel(test_case=self, name=name, subdir=name, ntasks=procs,
openmp_threads=1, velo_solver=velo_solver,
mesh_type=mesh_type))

input_dir = name
Expand Down
8 changes: 4 additions & 4 deletions compass/landice/tests/dome/restart_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, test_group, velo_solver, mesh_type):
SetupMesh(test_case=self, mesh_type=mesh_type))

name = 'full_run'
step = RunModel(test_case=self, name=name, subdir=name, cores=4,
threads=1, velo_solver=velo_solver,
step = RunModel(test_case=self, name=name, subdir=name, ntasks=4,
openmp_threads=1, velo_solver=velo_solver,
mesh_type=mesh_type)
# modify the namelist options and streams file
step.add_namelist_file(
Expand All @@ -62,8 +62,8 @@ def __init__(self, test_group, velo_solver, mesh_type):
self.add_step(step, run_by_default=False)

name = 'restart_run'
step = RunModel(test_case=self, name=name, subdir=name, cores=4,
threads=1, velo_solver=velo_solver,
step = RunModel(test_case=self, name=name, subdir=name, ntasks=4,
openmp_threads=1, velo_solver=velo_solver,
mesh_type=mesh_type,
suffixes=['landice', 'landice.rst'])

Expand Down
25 changes: 13 additions & 12 deletions compass/landice/tests/dome/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RunModel(Step):
``streams.landice.rst``
"""
def __init__(self, test_case, velo_solver, mesh_type, name='run_model',
subdir=None, cores=1, min_cores=None, threads=1,
subdir=None, ntasks=1, min_tasks=None, openmp_threads=1,
suffixes=None):
"""
Create a new test case
Expand All @@ -45,17 +45,17 @@ def __init__(self, test_case, velo_solver, mesh_type, name='run_model',
subdir : str, optional
the subdirectory for the step. The default is ``name``
cores : int, optional
the number of cores the step would ideally use. If fewer cores
ntasks : int, optional
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
cores as long as this is not below ``min_cores``
tasks as long as this is not below ``min_tasks``
min_cores : int, optional
the number of cores the step requires. If the system has fewer
than this number of cores, the step will fail
min_tasks : int, optional
the number of tasks the step requires. If the system has fewer
than this number of tasks, the step will fail
threads : int, optional
the number of threads the step will use
openmp_threads : int, optional
the number of OpenMP threads the step will use
suffixes : list of str, optional
a list of suffixes for namelist and streams files produced
Expand All @@ -72,10 +72,11 @@ def __init__(self, test_case, velo_solver, mesh_type, name='run_model',
if suffixes is None:
suffixes = ['landice']
self.suffixes = suffixes
if min_cores is None:
min_cores = cores
if min_tasks is None:
min_tasks = ntasks
super().__init__(test_case=test_case, name=name, subdir=subdir,
cores=cores, min_cores=min_cores, threads=threads)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

for suffix in suffixes:
self.add_namelist_file(
Expand Down
8 changes: 6 additions & 2 deletions compass/landice/tests/dome/smoke_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class SmokeTest(TestCase):
----------
mesh_type : str
The resolution or type of mesh of the test case
velo_solver : {'sia', 'FO'}
The velocity solver to use for the test case
"""

def __init__(self, test_group, velo_solver, mesh_type):
Expand Down Expand Up @@ -40,8 +43,9 @@ def __init__(self, test_group, velo_solver, mesh_type):
self.add_step(
SetupMesh(test_case=self, mesh_type=mesh_type))

step = RunModel(test_case=self, cores=4, threads=1, name='run_step',
velo_solver=velo_solver, mesh_type=mesh_type)
step = RunModel(test_case=self, ntasks=4, openmp_threads=1,
name='run_step', velo_solver=velo_solver,
mesh_type=mesh_type)
if velo_solver == 'sia':
step.add_namelist_options(
{'config_run_duration': "'0200-00-00_00:00:00'"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def __init__(self, test_group, thermal_solver):
for procs in [1, 4]:
name = '{}proc_run'.format(procs)
step = RunExperiment(test_case=self, name=name, subdir=name,
cores=procs, threads=1, experiment=experiment)
ntasks=procs, openmp_threads=1,
experiment=experiment)

step.add_namelist_options(options)

Expand Down
8 changes: 4 additions & 4 deletions compass/landice/tests/eismint2/restart_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, test_group, thermal_solver):
experiment = 'f'

name = 'full_run'
step = RunExperiment(test_case=self, name=name, subdir=name, cores=4,
threads=1, experiment=experiment)
step = RunExperiment(test_case=self, name=name, subdir=name, ntasks=4,
openmp_threads=1, experiment=experiment)

options = {'config_thermal_solver': "'{}'".format(thermal_solver)}

Expand All @@ -54,8 +54,8 @@ def __init__(self, test_group, thermal_solver):
self.add_step(step)

name = 'restart_run'
step = RunExperiment(test_case=self, name=name, subdir=name, cores=4,
threads=1, experiment=experiment,
step = RunExperiment(test_case=self, name=name, subdir=name, ntasks=4,
openmp_threads=1, experiment=experiment,
suffixes=['landice', 'landice.rst'])

# modify the namelist options and streams file
Expand Down
25 changes: 13 additions & 12 deletions compass/landice/tests/eismint2/run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RunExperiment(Step):
``streams.landice.rst``
"""
def __init__(self, test_case, experiment, name='run_model', subdir=None,
cores=1, min_cores=None, threads=1, suffixes=None):
ntasks=1, min_tasks=None, openmp_threads=1, suffixes=None):
"""
Create a new test case
Expand All @@ -44,17 +44,17 @@ def __init__(self, test_case, experiment, name='run_model', subdir=None,
subdir : str, optional
the subdirectory for the step. The default is ``name``
cores : int, optional
the number of cores the step would ideally use. If fewer cores
ntasks : int, optional
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
cores as long as this is not below ``min_cores``
tasks as long as this is not below ``min_tasks``
min_cores : int, optional
the number of cores the step requires. If the system has fewer
than this number of cores, the step will fail
min_tasks : int, optional
the number of tasks the step requires. If the system has fewer
than this number of tasks, the step will fail
threads : int, optional
the number of threads the step will use
openmp_threads : int, optional
the number of OpenMP threads the step will use
suffixes : list of str, optional
a list of suffixes for namelist and streams files produced
Expand All @@ -68,10 +68,11 @@ def __init__(self, test_case, experiment, name='run_model', subdir=None,
if suffixes is None:
suffixes = ['landice']
self.suffixes = suffixes
if min_cores is None:
min_cores = cores
if min_tasks is None:
min_tasks = ntasks
super().__init__(test_case=test_case, name=name, subdir=subdir,
cores=cores, min_cores=min_cores, threads=threads)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

for suffix in suffixes:
self.add_namelist_file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self, test_group):
for experiment in ['a', 'b', 'c', 'd', 'f', 'g']:
name = 'experiment_{}'.format(experiment)
self.add_step(
RunExperiment(test_case=self, name=name, subdir=name, cores=4,
threads=1, experiment=experiment))
RunExperiment(test_case=self, name=name, subdir=name, ntasks=4,
openmp_threads=1, experiment=experiment))

self.add_step(
Visualize(test_case=self))
Expand Down
5 changes: 3 additions & 2 deletions compass/landice/tests/enthalpy_benchmark/A/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def __init__(self, test_group):
'../phase2/restart.150000.nc']
for index, restart_filename in enumerate(restart_filenames):
name = 'phase{}'.format(index+1)
step = RunModel(test_case=self, cores=1, threads=1, name=name,
subdir=name, restart_filename=restart_filename)
step = RunModel(test_case=self, ntasks=1, openmp_threads=1,
name=name, subdir=name,
restart_filename=restart_filename)

suffix = 'landice{}'.format(index+1)
step.add_namelist_file(module, 'namelist.{}'.format(suffix))
Expand Down
3 changes: 2 additions & 1 deletion compass/landice/tests/enthalpy_benchmark/B/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def __init__(self, test_group):
self.add_step(
SetupMesh(test_case=self))
self.add_step(
RunModel(test_case=self, name='run_model', cores=1, threads=1))
RunModel(test_case=self, name='run_model', ntasks=1,
openmp_threads=1))
self.add_step(
Visualize(test_case=self))

Expand Down
25 changes: 13 additions & 12 deletions compass/landice/tests/enthalpy_benchmark/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RunModel(Step):
The name of a restart file to continue the run from
"""
def __init__(self, test_case, name, restart_filename=None, subdir=None,
cores=1, min_cores=None, threads=1):
ntasks=1, min_tasks=None, openmp_threads=1):
"""
Create a new test case
Expand All @@ -33,23 +33,24 @@ def __init__(self, test_case, name, restart_filename=None, subdir=None,
subdir : str, optional
the subdirectory for the step. The default is ``name``
cores : int, optional
the number of cores the step would ideally use. If fewer cores
ntasks : int, optional
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
cores as long as this is not below ``min_cores``
tasks as long as this is not below ``min_tasks``
min_cores : int, optional
the number of cores the step requires. If the system has fewer
than this number of cores, the step will fail
min_tasks : int, optional
the number of tasks the step requires. If the system has fewer
than this number of tasks, the step will fail
threads : int, optional
the number of threads the step will use
openmp_threads : int, optional
the number of OpenMP threads the step will use
"""
self.restart_filename = restart_filename
if min_cores is None:
min_cores = cores
if min_tasks is None:
min_tasks = ntasks
super().__init__(test_case=test_case, name=name, subdir=subdir,
cores=cores, min_cores=min_cores, threads=threads)
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

self.add_namelist_file('compass.landice.tests.enthalpy_benchmark',
'namelist.landice')
Expand Down
Loading

0 comments on commit 9b29ac3

Please sign in to comment.