Skip to content

Commit

Permalink
use mixin class for gromacs
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Moors committed Oct 13, 2024
1 parent bb83565 commit c5a5156
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 48 deletions.
10 changes: 5 additions & 5 deletions eessi/testsuite/eessi_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from reframe.core.builtins import parameter, run_after
from reframe.core.builtins import parameter, run_after, variable
from reframe.core.exceptions import ReframeFatalError
from reframe.core.pipeline import RegressionMixin
from reframe.utility.sanity import make_performance_function
Expand All @@ -25,18 +25,18 @@ class EESSI_Mixin(RegressionMixin):
All EESSI tests should derive from this mixin class unless they have a very good reason not to.
To run correctly, tests inheriting from this class need to define variables and parameters that are used here.
That definition needs to be done 'on time', i.e. early enough in the execution of the ReFrame pipeline.
Here, we list which class attributes need to be defined by the child class, and by (the end of) what phase:
Here, we list which class attributes must be defined by the child class, and by (the end of) what phase:
- Init phase: device_type, scale, module_name
- Init phase: device_type, scale, module_name, bench_name (if bench_name_ci is set)
- Setup phase: compute_unit, required_mem_per_node
The child class may also overwrite the following attributes:
- Init phase: time_limit, measure_memory_usage
- Init phase: time_limit, measure_memory_usage, bench_name_ci
"""

# Set defaults for these class variables, can be overwritten by child class if desired
measure_memory_usage = False
measure_memory_usage = variable(bool, value=False)
scale = parameter(SCALES.keys())
bench_name = None
bench_name_ci = None
Expand Down
69 changes: 26 additions & 43 deletions eessi/testsuite/tests/apps/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,43 @@
from hpctestlib.sciapps.gromacs.benchmarks import gromacs_check

from eessi.testsuite import hooks
from eessi.testsuite.constants import SCALES, TAGS
from eessi.testsuite.constants import COMPUTE_UNIT, DEVICE_TYPES, SCALES
from eessi.testsuite.eessi_mixin import EESSI_Mixin
from eessi.testsuite.utils import find_modules, log


class EESSI_GROMACS_base(gromacs_check):
@run_after('init')
def set_device_type(self):
self.device_type = self.nb_impl


@rfm.simple_test
class EESSI_GROMACS(gromacs_check):
class EESSI_GROMACS(EESSI_GROMACS_base, EESSI_Mixin):
# class EESSI_GROMACS(gromacs_check, EESSI_Mixin):
scale = parameter(SCALES.keys())
valid_prog_environs = ['default']
valid_systems = ['*']
time_limit = '30m'
module_name = parameter(find_modules('GROMACS'))
bench_name_ci = 'HECBioSim/Crambin'
# measure_memory_usage = True

@run_after('init')
def run_after_init(self):
"""Hooks to run after the init phase"""

# Filter on which scales are supported by the partitions defined in the ReFrame configuration
hooks.filter_supported_scales(self)

# Make sure that GPU tests run in partitions that support running on a GPU,
# and that CPU-only tests run in partitions that support running CPU-only.
# Also support setting valid_systems on the cmd line.
hooks.filter_valid_systems_by_device_type(self, required_device_type=self.nb_impl)
def required_mem_per_node(self):
return self.num_tasks_per_node * 1024

# Support selecting modules on the cmd line.
hooks.set_modules(self)

# Support selecting scales on the cmd line via tags.
hooks.set_tag_scale(self)
def __init__(self):
# self.device_type must be set before the @run_after('init') hooks of the EESSI_Mixin class
self.device_type = self.nb_impl

@run_after('init')
def set_tag_ci(self):
"""Set tag CI on smallest benchmark, so it can be selected on the cmd line via --tag CI"""
# Crambin input is smallest input (20K atoms), cfr. https://www.hecbiosim.ac.uk/access-hpc/benchmarks
if self.benchmark_info[0] == 'HECBioSim/Crambin':
self.tags.add(TAGS['CI'])
log(f'tags set to {self.tags}')
def set_compute_unit(self):
"""Set the compute unit to which tasks will be assigned"""
if self.device_type == DEVICE_TYPES['CPU']:
self.compute_unit = COMPUTE_UNIT['CPU']
elif self.device_type == DEVICE_TYPES['GPU']:
self.compute_unit = COMPUTE_UNIT['GPU']
else:
msg = f"No mapping of device type {self.device_type} to a COMPUTE_UNIT was specified in this test"
raise NotImplementedError(msg)

@run_after('setup')
def set_executable_opts(self):
Expand All @@ -86,15 +86,6 @@ def set_executable_opts(self):
self.executable_opts += ['-dlb', 'yes', '-npme', '-1']
log(f'executable_opts set to {self.executable_opts}')

@run_after('setup')
def run_after_setup(self):
"""Hooks to run after the setup phase"""

# Calculate default requested resources based on the scale:
# 1 task per CPU for CPU-only tests, 1 task per GPU for GPU tests.
# Also support setting the resources on the cmd line.
hooks.assign_tasks_per_compute_unit(test=self, compute_unit=self.nb_impl)

@run_after('setup')
def set_omp_num_threads(self):
"""
Expand All @@ -113,11 +104,3 @@ def set_omp_num_threads(self):

self.env_vars['OMP_NUM_THREADS'] = omp_num_threads
log(f'env_vars set to {self.env_vars}')

@run_after('setup')
def set_binding_policy(self):
"""
Default process binding may depend on the launcher used. We've seen some variable performance.
Better set it explicitely to make sure process migration cannot cause such variations.
"""
hooks.set_compact_process_binding(self)

0 comments on commit c5a5156

Please sign in to comment.