diff --git a/eessi/testsuite/tests/apps/lammps/lammps.py b/eessi/testsuite/tests/apps/lammps/lammps.py index cc972696..1651d704 100644 --- a/eessi/testsuite/tests/apps/lammps/lammps.py +++ b/eessi/testsuite/tests/apps/lammps/lammps.py @@ -21,6 +21,7 @@ class EESSI_LAMMPS(rfm.RunOnlyRegressionTest): # Parameterize over all modules that start with LAMMPS module_name = parameter(utils.find_modules('LAMMPS')) + sourcesdir= 'src/lj' executable = 'lmp -in in.lj' # Set sanity step @@ -103,3 +104,97 @@ def set_omp_num_threads(self): omp_num_threads = self.num_cpus_per_task self.env_vars['OMP_NUM_THREADS'] = omp_num_threads utils.log(f'env_vars set to {self.env_vars}') + + +@rfm.simple_test +class EESSI_LAMMPS_rhodo(rfm.RunOnlyRegressionTest): + scale = parameter(SCALES.keys()) + valid_prog_environs = ['default'] + valid_systems = ['*'] + time_limit = '30m' + device_type = parameter([DEVICE_TYPES[CPU], DEVICE_TYPES[GPU]]) + + # Parameterize over all modules that start with LAMMPS + module_name = parameter(utils.find_modules('LAMMPS')) + sourcesdir= 'src/rhodo' + readonly_files = ["data.rhodo"] + executable = 'lmp -in in.rhodo' + + # Set sanity step + @deferrable + def assert_lammps_openmp_treads(self): + '''Assert that OpenMP thread(s) per MPI task is set''' + n_threads = sn.extractsingle( + r'^ using (?P[0-9]+) OpenMP thread\(s\) per MPI task', self.stdout, 'threads', int) + utils.log(f'OpenMP thread(s) is {n_threads}') + + return sn.assert_eq(n_threads, self.num_cpus_per_task) + + @deferrable + def assert_lammps_processor_grid(self): + '''Assert that the processor grid is set correctly''' + grid = list(sn.extractall( + '^ (?P[0-9]+) by (?P[0-9]+) by (?P[0-9]+) MPI processor grid', self.stdout, tag=['x', 'y', 'z'])) + n_cpus = int(grid[0][0]) * int(grid[0][1]) * int(grid[0][2]) + + return sn.assert_eq(n_cpus, self.num_tasks) + + @deferrable + def assert_total_nr_neigbors(self): + '''Assert that the test calulated the right number of neighbours''' + neighbours = list(sn.extractall( + r'^Total # of neighbors = (?P\S+)', self.stdout, 'neighbours')) + n_neighbours = int(neighbours[0]) + + return sn.assert_eq(n_neighbours, 12028093) + + + @sanity_function + def assert_sanity(self): + '''Check all sanity criteria''' + return sn.all([ + self.assert_lammps_openmp_treads(), + self.assert_lammps_processor_grid(), + self.assert_total_nr_neigbors(), + ]) + + @performance_function('img/s') + def perf(self): + return sn.extractsingle(r'^(?P[.0-9]+)% CPU use with [0-9]+ MPI tasks x [0-9]+ OpenMP threads', self.stdout, 'perf', float) + + @run_after('init') + def run_after_init(self): + """hooks to run after init phase""" + + # Filter on which scales are supported by the partitions defined in the ReFrame configuration + hooks.filter_supported_scales(self) + + hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type) + + hooks.set_modules(self) + + # Set scales as tags + hooks.set_tag_scale(self) + + @run_after('setup') + def run_after_setup(self): + """hooks to run after the setup phase""" + # TODO: Have not tested with GPUs yet + if self.device_type == 'cpu': + hooks.assign_tasks_per_compute_unit(test=self, compute_unit=COMPUTE_UNIT['CPU']) + elif self.device_type == 'gpu': + hooks.assign_tasks_per_compute_unit(test=self, compute_unit=COMPUTE_UNIT['GPU']) + else: + raise NotImplementedError(f'Failed to set number of tasks and cpus per task for device {self.device_type}') + + @run_after('setup') + def set_omp_num_threads(self): + """ + Set number of OpenMP threads. + Set OMP_NUM_THREADS. + Set default number of OpenMP threads equal to number of CPUs per task. + """ + + omp_num_threads = self.num_cpus_per_task + self.env_vars['OMP_NUM_THREADS'] = omp_num_threads + utils.log(f'env_vars set to {self.env_vars}') diff --git a/eessi/testsuite/tests/apps/lammps/src/in.lj b/eessi/testsuite/tests/apps/lammps/src/lj/in.lj similarity index 100% rename from eessi/testsuite/tests/apps/lammps/src/in.lj rename to eessi/testsuite/tests/apps/lammps/src/lj/in.lj diff --git a/eessi/testsuite/tests/apps/lammps/data.rhodo b/eessi/testsuite/tests/apps/lammps/src/rhodo/data.rhodo similarity index 100% rename from eessi/testsuite/tests/apps/lammps/data.rhodo rename to eessi/testsuite/tests/apps/lammps/src/rhodo/data.rhodo diff --git a/eessi/testsuite/tests/apps/lammps/src/in.rhodo b/eessi/testsuite/tests/apps/lammps/src/rhodo/in.rhodo similarity index 100% rename from eessi/testsuite/tests/apps/lammps/src/in.rhodo rename to eessi/testsuite/tests/apps/lammps/src/rhodo/in.rhodo