diff --git a/cscs-checks/libraries/petsc/petsc_helloworld.py b/cscs-checks/libraries/petsc/petsc_helloworld.py index 308d731065..d6d2f484f8 100644 --- a/cscs-checks/libraries/petsc/petsc_helloworld.py +++ b/cscs-checks/libraries/petsc/petsc_helloworld.py @@ -7,30 +7,39 @@ import reframe.utility.sanity as sn -@rfm.parameterized_test(['dynamic'], ['static']) +@rfm.simple_test class PetscPoisson2DCheck(rfm.RegressionTest): - def __init__(self, linkage): + linkage = parameter(['dynamic', 'static']) + valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] + valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', 'PrgEnv-intel'] + modules = ['cray-petsc'] + build_system = 'SingleSource' + sourcepath = 'poisson2d.c' + num_tasks = 16 + num_tasks_per_node = 8 + executable_opts = ['-da_grid_x 4', '-da_grid_y 4', '-ksp_monitor'] + tags = {'production', 'craype'} + maintainers = ['AJ', 'CB'] + + @run_after('init') + def set_description(self): self.descr = (f'Compile/run PETSc 2D Poisson example with cray-petsc ' - f'({linkage} linking)') - self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] - self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', - 'PrgEnv-intel'] - self.sourcepath = 'poisson2d.c' - self.modules = ['cray-petsc'] - self.num_tasks = 16 - self.num_tasks_per_node = 8 - self.build_system = 'SingleSource' + f'({self.linkage} linking)') + + @run_before('compile') + def set_variables(self): + self.variables = {'CRAYPE_LINK_TYPE': self.linkage} + + @run_before('compile') + def intel_workaround(self): # FIXME: static compilation yields a link error in case of # PrgEnv-intel (Cray Bug #255701) workaround use C++ compiler - if linkage == 'static': + if self.linkage == 'static': self.build_system.cc = 'CC' - self.variables = {'CRAYPE_LINK_TYPE': linkage} - self.executable_opts = ['-da_grid_x 4', '-da_grid_y 4', '-ksp_monitor'] - + @sanity_function + def assert_convergence(self): # Check the final residual norm for convergence norm = sn.extractsingle(r'\s+\d+\s+KSP Residual norm\s+(?P\S+)', self.stdout, 'norm', float, -1) - self.sanity_patterns = sn.assert_lt(norm, 1.0e-5) - self.tags = {'production', 'craype'} - self.maintainers = ['AJ', 'CB'] + return sn.assert_lt(norm, 1.0e-5)