Skip to content

Commit fa8ff69

Browse files
authored
Merge pull request #448 from msimberg/mpi-tests-slurm-flag
Set `--mpi` slurm flag appropriately flag on some MPI tests
2 parents b960bdb + 0fc262c commit fa8ff69

File tree

5 files changed

+78
-29
lines changed

5 files changed

+78
-29
lines changed

checks/microbenchmarks/mpi/osu/osu_run.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
#
44
# SPDX-License-Identifier: BSD-3-Clause
55

6+
import pathlib
7+
import sys
8+
69
import reframe as rfm
710
import reframe.utility.sanity as sn
811

12+
sys.path.append(str(pathlib.Path(__file__).parent.parent.parent.parent / 'mixins'))
13+
from uenv_slurm_mpi_options import UenvSlurmMpiOptionsMixin
14+
915

10-
class BaseCheck(rfm.RunOnlyRegressionTest):
16+
class BaseCheck(rfm.RunOnlyRegressionTest, UenvSlurmMpiOptionsMixin):
1117
valid_systems = ['+remote']
1218
valid_prog_environs = ['+osu-micro-benchmarks +uenv']
1319
sourcesdir = None
1420
num_tasks = 2
1521
num_tasks_per_node = 1
16-
pmi = variable(str, value='')
1722
env_vars = {
1823
# Disable GPU support for mpich
1924
'MPIR_CVAR_ENABLE_GPU': 0,
@@ -38,11 +43,6 @@ def prepare_test(self):
3843
processor = self.current_partition.processor
3944
self.num_cpus_per_task = processor.num_cpus_per_socket
4045

41-
@run_after('setup')
42-
def set_launcher_options(self):
43-
if self.pmi != '':
44-
self.job.launcher.options = [f'--mpi={self.pmi}']
45-
4646
@sanity_function
4747
def assert_sanity(self):
4848
# Only check for the last entry in the latency test,

checks/microbenchmarks/xccl/xccl_tests.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
sys.path.append(str(pathlib.Path(__file__).parent.parent.parent / 'mixins'))
1313

1414
from container_engine import ContainerEngineMixin # noqa: E402
15+
from slurm_mpi_pmix import SlurmMpiPmixMixin
16+
from uenv_slurm_mpi_options import UenvSlurmMpiOptionsMixin
1517

1618

1719
class XCCLTestsBase(rfm.RunOnlyRegressionTest):
@@ -88,36 +90,17 @@ def set_perf(self):
8890
}
8991

9092

91-
class XCCLTestsBaseCE(XCCLTestsBase, ContainerEngineMixin):
93+
class XCCLTestsBaseCE(XCCLTestsBase, ContainerEngineMixin, SlurmMpiPmixMixin):
9294
container_env_table = {
9395
'annotations.com.hooks': {
9496
'aws_ofi_nccl.enabled': 'true'
9597
}
9698
}
9799

98-
@run_before('run')
99-
def set_pmix(self):
100-
self.job.launcher.options += ['--mpi=pmix']
101100

102-
# Disable MCA components to avoid warnings
103-
self.env_vars.update(
104-
{
105-
'PMIX_MCA_psec': '^munge',
106-
'PMIX_MCA_gds': '^shmem2'
107-
}
108-
)
109-
110-
111-
class XCCLTestsBaseUENV(XCCLTestsBase):
101+
class XCCLTestsBaseUENV(XCCLTestsBase, UenvSlurmMpiOptionsMixin):
112102
tags.add('bencher')
113103

114-
@run_before('run')
115-
def set_pmix(self):
116-
# Some clusters, like clariden, don't use cray_shasta as default.
117-
# cray_shasta is required for cray-mpich, which most uenvs use. This
118-
# will need to be updated when uenvs can have OpenMPI in them.
119-
self.job.launcher.options += ['--mpi=cray_shasta']
120-
121104

122105
def _set_xccl_uenv_env_vars(env_vars):
123106
env_vars.update(

checks/mixins/slurm_mpi_pmix.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2016-2023 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
8+
9+
class SlurmMpiPmixMixin(rfm.RegressionMixin):
10+
"""
11+
Set slurm --mpi flags for containers that require PMIx.
12+
13+
Containers that use OpenMPI require the --mpi=pmix flag.
14+
15+
Additionally silence some warnings triggered by OpenMPI.
16+
"""
17+
18+
@run_after('setup')
19+
def set_slurm_mpi_pmix(self):
20+
self.job.launcher.options += ['--mpi=pmix']
21+
22+
# Disable MCA components to avoid warnings
23+
self.env_vars.update(
24+
{
25+
'PMIX_MCA_psec': 'native',
26+
'PMIX_MCA_gds': '^shmem2'
27+
}
28+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2016-2023 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
8+
9+
class UenvSlurmMpiOptionsMixin(rfm.RegressionMixin):
10+
"""
11+
Set slurm --mpi flags based on uenv features.
12+
13+
For uenvs that announce that they use OpenMPI, --mpi=pmix needs to be used.
14+
For uenvs that advertise Cray MPICH, or uenvs that don't specify, we assume
15+
that --mpi=cray_shasta is required.
16+
17+
Additionally for OpenMPI we silence some warnings.
18+
"""
19+
20+
@run_after('setup')
21+
def set_uenv_slurm_mpi_options(self):
22+
features = self.current_environ.features
23+
if "openmpi" in features:
24+
self.job.launcher.options += ['--mpi=pmix']
25+
26+
# Disable MCA components to avoid warnings
27+
self.env_vars.update(
28+
{
29+
'PMIX_MCA_psec': 'native',
30+
'PMIX_MCA_gds': '^shmem2'
31+
}
32+
)
33+
elif "cray-mpich" in features:
34+
self.job.launcher.options += ['--mpi=cray_shasta']
35+
else:
36+
# Assume cray-mpich is used if nothing is specified.
37+
self.job.launcher.options += ['--mpi=cray_shasta']

checks/prgenv/helloworld.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
sys.path.append(str(pathlib.Path(__file__).parent.parent / 'mixins'))
1212
from extra_launcher_options import ExtraLauncherOptionsMixin
1313
from container_engine import ContainerEngineCPEMixin
14+
from uenv_slurm_mpi_options import UenvSlurmMpiOptionsMixin
1415

1516

1617
class HelloWorldBaseTest(rfm.RegressionTest, ExtraLauncherOptionsMixin,
17-
ContainerEngineCPEMixin):
18+
ContainerEngineCPEMixin, UenvSlurmMpiOptionsMixin):
1819
linking = parameter(['dynamic'])
1920
lang = parameter(['c', 'cpp', 'F90'])
2021
sourcesdir = 'src/hello'

0 commit comments

Comments
 (0)