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

simplify executable_opts with new variable user_executable_opts #249

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions eessi/testsuite/eessi_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class EESSI_Mixin(RegressionMixin):
# Set defaults for these class variables, can be overwritten by child class if desired
measure_memory_usage = variable(bool, value=False)
exact_memory = variable(bool, value=False)
user_executable_opts = variable(str, value='')
scale = parameter(SCALES.keys())
bench_name = None
bench_name_ci = None
Expand Down Expand Up @@ -202,6 +203,13 @@ def log_runtime_info(self):
get_full_modpath = f'echo "FULL_MODULEPATH: $(module --location show {self.module_name})"'
self.postrun_cmds.append(get_full_modpath)

@run_before('run', always_last=True)
def mixin_set_user_executable_opts(self):
"Override executable_opts with user_executable_opts if set on the cmd line"
if self.user_executable_opts:
self.executable_opts = [self.user_executable_opts]
log(f'executable_opts set to {self.executable_opts}')

@run_after('run')
def extract_runtime_info_from_log(self):
"""Extracts the printed runtime info from the job log and logs it as reframe variables"""
Expand Down
8 changes: 0 additions & 8 deletions eessi/testsuite/tests/apps/espresso/espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def set_tag_ci(self):
@run_after('init')
def set_executable_opts(self):
"""Set executable opts based on device_type parameter"""
num_default = 0 # If this test already has executable opts, they must have come from the command line
hooks.check_custom_executable_opts(self, num_default=num_default)
# By default we run weak scaling since the strong scaling sizes need to change based on max node size and a
# corresponding min node size has to be chozen.
self.executable_opts += ['--size', str(self.default_weak_scaling_system_size), '--weak-scaling']
Expand Down Expand Up @@ -175,12 +173,6 @@ def set_tag_ci(self):

self.tags.add('particles_lj')

@run_after('init')
def set_executable_opts(self):
"""Allow executable opts to be overwritten from command line"""
num_default = 0 # If this test already has executable opts, they must have come from the command line
hooks.check_custom_executable_opts(self, num_default=num_default)

@run_after('setup')
def set_mem(self):
""" Setting an extra job option of memory. Here the assumption made is that HPC systems will contain at
Expand Down
16 changes: 2 additions & 14 deletions eessi/testsuite/tests/apps/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

from hpctestlib.sciapps.gromacs.benchmarks import gromacs_check

from eessi.testsuite import hooks
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
Expand All @@ -54,6 +53,8 @@ class EESSI_GROMACS(EESSI_GROMACS_base, EESSI_Mixin):
bench_name_ci = 'HECBioSim/Crambin'
# input files are downloaded
readonly_files = ['']
# executable_opts in addition to those set by the hpctestlib
executable_opts = ['-dlb', 'yes', '-npme', '-1']

def required_mem_per_node(self):
return self.num_tasks_per_node * 1024
Expand All @@ -76,19 +77,6 @@ def set_compute_unit(self):
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):
"""
Add extra executable_opts, unless specified via --setvar executable_opts=<x>
Set default executable_opts and support setting custom executable_opts on the cmd line.
"""

num_default = 4 # normalized number of executable opts added by parent class (gromacs_check)
hooks.check_custom_executable_opts(self, num_default=num_default)
if not self.has_custom_executable_opts:
self.executable_opts += ['-dlb', 'yes', '-npme', '-1']
log(f'executable_opts set to {self.executable_opts}')

@run_after('setup')
def set_omp_num_threads(self):
"""
Expand Down
64 changes: 27 additions & 37 deletions eessi/testsuite/tests/apps/lammps/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import reframe as rfm
import reframe.utility.sanity as sn

from eessi.testsuite import hooks, utils
from eessi.testsuite import utils
from eessi.testsuite.constants import * # noqa
from eessi.testsuite.eessi_mixin import EESSI_Mixin

Expand Down Expand Up @@ -103,24 +103,19 @@ def assert_sanity(self):
@run_after('setup')
def set_executable_opts(self):
"""Set executable opts based on device_type parameter"""
num_default = 0 # If this test already has executable opts, they must have come from the command line
hooks.check_custom_executable_opts(self, num_default=num_default)
if not self.has_custom_executable_opts:
# should also check if the lammps is installed with kokkos.
# Because this exutable opt is only for that case.
if self.device_type == "gpu":
if 'kokkos' in self.module_name:
self.executable_opts += [
f'-kokkos on t {self.num_cpus_per_task} g {self.num_gpus_per_node}',
'-suffix kk',
'-package kokkos newton on neigh half',
]
utils.log(f'executable_opts set to {self.executable_opts}')
else:
self.executable_opts += [
f'-suffix gpu -package gpu {self.num_gpus_per_node}',
]
utils.log(f'executable_opts set to {self.executable_opts}')
# should also check if the lammps is installed with kokkos.
# Because this executable opt is only for that case.
if self.device_type == "gpu":
if 'kokkos' in self.module_name:
self.executable_opts += [
f'-kokkos on t {self.num_cpus_per_task} g {self.num_gpus_per_node}',
'-suffix kk',
'-package kokkos newton on neigh half',
]
utils.log(f'executable_opts set to {self.executable_opts}')
else:
self.executable_opts += [f'-suffix gpu -package gpu {self.num_gpus_per_node}']
utils.log(f'executable_opts set to {self.executable_opts}')


@rfm.simple_test
Expand Down Expand Up @@ -163,21 +158,16 @@ def assert_sanity(self):
@run_after('setup')
def set_executable_opts(self):
"""Set executable opts based on device_type parameter"""
num_default = 0 # If this test already has executable opts, they must have come from the command line
hooks.check_custom_executable_opts(self, num_default=num_default)
if not self.has_custom_executable_opts:
# should also check if the lammps is installed with kokkos.
# Because this exutable opt is only for that case.
if self.device_type == "gpu":
if 'kokkos' in self.module_name:
self.executable_opts += [
f'-kokkos on t {self.num_cpus_per_task} g {self.num_gpus_per_node}',
'-suffix kk',
'-package kokkos newton on neigh half',
]
utils.log(f'executable_opts set to {self.executable_opts}')
else:
self.executable_opts += [
f'-suffix gpu -package gpu {self.num_gpus_per_node}',
]
utils.log(f'executable_opts set to {self.executable_opts}')
# should also check if the lammps is installed with kokkos.
# Because this executable opt is only for that case.
if self.device_type == "gpu":
if 'kokkos' in self.module_name:
self.executable_opts += [
f'-kokkos on t {self.num_cpus_per_task} g {self.num_gpus_per_node}',
'-suffix kk',
'-package kokkos newton on neigh half',
]
utils.log(f'executable_opts set to {self.executable_opts}')
else:
self.executable_opts += [f'-suffix gpu -package gpu {self.num_gpus_per_node}']
utils.log(f'executable_opts set to {self.executable_opts}')
16 changes: 6 additions & 10 deletions eessi/testsuite/tests/apps/tensorflow/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from reframe.core.builtins import deferrable, parameter, run_after, sanity_function, performance_function
import reframe.utility.sanity as sn

from eessi.testsuite import hooks, utils
from eessi.testsuite import utils
from eessi.testsuite.constants import COMPUTE_UNIT, CPU, CPU_SOCKET, DEVICE_TYPES, GPU
from eessi.testsuite.eessi_mixin import EESSI_Mixin

Expand Down Expand Up @@ -72,11 +72,8 @@ def perf(self):
@run_after('init')
def set_executable_opts(self):
"""Set executable opts based on device_type parameter"""
num_default = 0 # If this test already has executable opts, they must have come from the command line
hooks.check_custom_executable_opts(self, num_default=num_default)
if not self.has_custom_executable_opts:
self.executable_opts += ['--device', self.device_type]
utils.log(f'executable_opts set to {self.executable_opts}')
self.executable_opts += ['--device', self.device_type]
utils.log(f'executable_opts set to {self.executable_opts}')

@run_after('init')
def set_test_descr(self):
Expand All @@ -97,7 +94,6 @@ def set_compute_unit(self):
@run_after('setup')
def set_thread_count_args(self):
"""Set executable opts defining the thread count"""
if not self.has_custom_executable_opts:
self.executable_opts += ['--intra-op-parallelism', '%s' % self.num_cpus_per_task]
self.executable_opts += ['--inter-op-parallelism', '1']
utils.log(f'executable_opts set to {self.executable_opts}')
self.executable_opts += ['--intra-op-parallelism', '%s' % self.num_cpus_per_task]
self.executable_opts += ['--inter-op-parallelism', '1']
utils.log(f'executable_opts set to {self.executable_opts}')
Loading