Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpe in ce #257

Closed
wants to merge 1 commit into from
Closed
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
73 changes: 73 additions & 0 deletions checks/mixins/container_engine_cpe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2024 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause

import reframe as rfm
import reframe.utility.typecheck as typ


class ContainerEngineMixinCPE(rfm.RegressionMixin):
Copy link
Collaborator

@ekouts ekouts Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on slack, I am not sure we need to have a special class for this. I think we can re-use the container engine mixin and make it pass the options in both compilation and run scripts

#: The container image to use.
#:
#: :default: ``required``
container_image = variable(str)

#: The working directory of the container.
#:
#: Setting to `None` will not set any workdir for the container
#:
#: :default: ``'/rfm_workdir/'``
container_workdir = variable(str, type(None), value='/rfm_workdir')

#: A list of the container mounts following the <src dir>:<target dir>
#: convention.
#: The test stage directory is always mounted on `/rfm_workdir`.
#:
#: :default: ``[]``
container_mounts = variable(typ.List[str], value=[])

#: A dictionary of key/values to pass to the container environment.
#:
#: :default: ``{}``
container_env_key_values = variable(typ.Dict[str, str], value={})

#: A dictionary of tables to pass to the container environment.
#: For each key, a dictionary of key/value pairs is given.
#:
#: :default: ``{}``
container_env_table= variable(typ.Dict[str, typ.Dict[str, str]], value={})

@run_before('compile')
def create_env_file(self):
mounts = ',\n'.join(f'"{m}"' for m in self.container_mounts)
toml_lines = [
f'image = "{self.container_image}"',
f'mounts = [',
f'"{self.stagedir}:/rfm_workdir",',
f'"{self.stagedir}:{self.stagedir}",',
mounts,
f']',
]
toml_lines += [f'workdir = "{self.stagedir}"']

for k, v in self.container_env_key_values.items():
toml_lines.append(f'{k} = "{v}"')

for table_name, values in self.container_env_table.items():
if values:
toml_lines.append(f'[{table_name}]')
for k, v in values.items():
toml_lines.append(f'{k} = "{v}"')

self.env_file = f'{self.stagedir}/rfm_env.toml'
with open(self.env_file, 'w') as f:
f.write('\n'.join(l for l in toml_lines if l))

@run_before('compile')
def set_sbatch(self):
self.build_job.options += [f'--environment={self.env_file}']

@run_before('run')
def set_container_engine_env_launcher_options(self):
self.job.options += [f'--environment={self.env_file}']
23 changes: 14 additions & 9 deletions checks/prgenv/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@
# SPDX-License-Identifier: BSD-3-Clause

import os
import pathlib
import sys

import reframe as rfm
import reframe.utility.sanity as sn

sys.path.append(str(pathlib.Path(__file__).parent.parent / 'mixins'))
from container_engine_cpe import ContainerEngineMixinCPE # noqa: E402


@rfm.simple_test
class MpiInitTest(rfm.RegressionTest):
class MpiInitTest(rfm.RegressionTest, ContainerEngineMixinCPE):
'''
This test checks the value returned by calling MPI_Init_thread.
'''
required_threads = ['funneled', 'serialized', 'multiple']
valid_prog_environs = ['+mpi']
valid_systems = ['+remote']
valid_systems = ['+ce']
valid_prog_environs = ['*']
container_image = '/capstor/scratch/cscs/anfink/cpe/cpe-gnu.sqsh'
#ko? container_image = variable(str, value='/capstor/scratch/cscs/anfink/cpe/cpe-gnu.sqsh')
build_system = 'Make'
sourcesdir = 'src/mpi_thread'
executable = 'mpi_init_thread_single.exe'
time_limit = '2m'
build_locally = False
tags = {'production', 'craype', 'uenv'}

@run_before('run')
def set_job_parameters(self):
# To avoid: "MPIR_pmi_init(83)....: PMI2_Job_GetId returned 14"
self.job.launcher.options += (
self.current_environ.extras.get('launcher_options', [])
)
@run_after('setup')
def set_modules(self):
self.prebuild_cmds = self.prerun_cmds = ['pwd', 'module list']
# self.prerun_cmds = ['pwd', 'module list']

@run_before('run')
def pre_launch(self):
Expand Down