diff --git a/eessi/testsuite/eessi_mixin.py b/eessi/testsuite/eessi_mixin.py index e87d5311..7d4ce278 100644 --- a/eessi/testsuite/eessi_mixin.py +++ b/eessi/testsuite/eessi_mixin.py @@ -1,10 +1,10 @@ -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 from eessi.testsuite import hooks -from eessi.testsuite.constants import DEVICE_TYPES, SCALES, COMPUTE_UNIT +from eessi.testsuite.constants import DEVICE_TYPES, SCALES, COMPUTE_UNIT, TAGS # Hooks from the Mixin class seem to be executed _before_ those of the child class @@ -25,19 +25,21 @@ 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 # Note that the error for an empty parameter is a bit unclear for ReFrame 4.6.2, but that will hopefully improve # see https://github.com/reframe-hpc/reframe/issues/3254 @@ -113,6 +115,16 @@ def measure_mem_usage(self): # instead of the @performance_function decorator self.perf_variables['memory'] = make_performance_function(hooks.extract_memory_usage, 'MiB', self) + @run_after('init', always_last=True) + def set_tag_ci(self): + "Set CI tag if bench_name_ci and bench_name are set and are equal" + if self.bench_name_ci: + if not self.bench_name: + msg = "Attribute bench_name_ci is set, but bench_name is not set" + raise ReframeFatalError(msg) + if self.bench_name == self.bench_name_ci: + self.tags.add(TAGS['CI']) + @run_after('setup') def validate_setup(self): """Check that all variables that have to be set for subsequent hooks in the setup phase have been set""" diff --git a/eessi/testsuite/tests/apps/cp2k/cp2k.py b/eessi/testsuite/tests/apps/cp2k/cp2k.py index 30fe0867..77c1a98b 100644 --- a/eessi/testsuite/tests/apps/cp2k/cp2k.py +++ b/eessi/testsuite/tests/apps/cp2k/cp2k.py @@ -4,13 +4,13 @@ from reframe.core.builtins import parameter, run_after, performance_function, sanity_function import reframe.utility.sanity as sn -from eessi.testsuite import hooks -from eessi.testsuite.constants import SCALES, TAGS, COMPUTE_UNIT, DEVICE_TYPES, CPU -from eessi.testsuite.utils import find_modules, log +from eessi.testsuite.constants import SCALES, COMPUTE_UNIT, DEVICE_TYPES, CPU +from eessi.testsuite.eessi_mixin import EESSI_Mixin +from eessi.testsuite.utils import find_modules @rfm.simple_test -class EESSI_CP2K(rfm.RunOnlyRegressionTest): +class EESSI_CP2K(rfm.RunOnlyRegressionTest, EESSI_Mixin): benchmark_info = parameter([ # (bench_name, energy_ref, energy_tol) @@ -24,8 +24,18 @@ class EESSI_CP2K(rfm.RunOnlyRegressionTest): executable = 'cp2k.popt' time_limit = '2h' - valid_systems = ['*'] - valid_prog_environs = ['default'] + device_type = DEVICE_TYPES[CPU] + compute_unit = COMPUTE_UNIT[CPU] + bench_name_ci = 'QS/H2O-32' # set CI on smallest benchmark + + def required_mem_per_node(self): + mems = { + 'QS/H2O-32': {'intercept': 0.5, 'slope': 0.15}, + 'QS/H2O-128': {'intercept': 5, 'slope': 0.15}, + 'QS/H2O-512': {'intercept': 34, 'slope': 0.20}, + } + mem = mems[self.bench_name] + return (self.num_tasks_per_node * mem['slope'] + mem['intercept']) * 1024 @run_after('init') def prepare_test(self): @@ -51,39 +61,9 @@ def assert_energy(self): def time(self): return sn.extractsingle(r'^ CP2K(\s+[\d\.]+){4}\s+(?P