diff --git a/cscs-checks/tools/profiling_and_debugging/ddt.py b/cscs-checks/tools/profiling_and_debugging/ddt.py index 36040d8849..453ae7b23e 100644 --- a/cscs-checks/tools/profiling_and_debugging/ddt.py +++ b/cscs-checks/tools/profiling_and_debugging/ddt.py @@ -1,28 +1,33 @@ import os +import reframe as rfm import reframe.utility.sanity as sn + from reframe.core.launchers import LauncherWrapper -from reframe.core.pipeline import RegressionTest -class DdtCheck(RegressionTest): - def __init__(self, lang, extension, **kwargs): - super().__init__('ddt_check_' + lang.replace('+', 'p'), - os.path.dirname(__file__), **kwargs) +class DdtCheck(rfm.RegressionTest): + def __init__(self, lang, extension): + super().__init__() + self.name = 'DDtCheck_' + lang.replace('+', 'p') + self.descr = 'DDt Check for %s' % lang self.lang = lang self.extension = extension - self.makefile = 'Makefile' + self.build_system = 'Make' + # NOTE: Restrict concurrency to allow creation of Fortran modules + if lang == 'F90': + self.build_system.max_concurrency = 1 + self.executable = './jacobi' self.sourcesdir = os.path.join('src', lang) self.valid_prog_environs = ['PrgEnv-gnu'] self.modules = ['ddt'] self.prgenv_flags = { # 'PrgEnv-cray': ' -O2 -homp', - 'PrgEnv-gnu': ' -O2 -fopenmp', + 'PrgEnv-gnu': ['-g', '-O2', '-fopenmp'], # 'PrgEnv-intel': ' -O2 -qopenmp', # 'PrgEnv-pgi': ' -O2 -mp' } - self.flags = ' -g' self.num_tasks = 1 self.num_tasks_per_node = 1 self.num_cpus_per_task = 4 @@ -41,34 +46,27 @@ def __init__(self, lang, extension, **kwargs): self.maintainers = ['MK', 'JG'] self.tags = {'production'} self.post_run = ['ddt -V ; which ddt ;'] - self.ddt_options = [] self.keep_files = ['ddtreport.txt'] - def _set_compiler_flags(self): - prgenv_flags = self.prgenv_flags[self.current_environ.name] - self.current_environ.cflags = self.flags + prgenv_flags - self.current_environ.cxxflags = self.flags + prgenv_flags - self.current_environ.fflags = self.flags + prgenv_flags - self.current_environ.ldflags = self.flags + prgenv_flags - - def compile(self, **job_opts): - self._set_compiler_flags() - super().compile(makefile=self.makefile, **job_opts) - def setup(self, partition, environ, **job_opts): super().setup(partition, environ, **job_opts) + prgenv_flags = self.prgenv_flags[self.current_environ.name] + self.build_system.cflags = prgenv_flags + self.build_system.cxxflags = prgenv_flags + self.build_system.fflags = prgenv_flags self.job.launcher = LauncherWrapper(self.job.launcher, 'ddt', self.ddt_options) +@rfm.parameterized_test(['F90', 'F90'], ['C', 'c'], ['C++', 'cc']) class DdtCpuCheck(DdtCheck): - def __init__(self, lang, extension, **kwargs): - super().__init__(lang, extension, **kwargs) + def __init__(self, lang, extension): + super().__init__(lang, extension) self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc', 'kesch:cn'] if self.current_system.name == 'kesch' and self.lang == 'C': - self.flags += ' -lm ' + self.build_system.ldflags = ['-lm'] residual_pattern = '_jacobi.%s:%d,residual' self.ddt_options = [ @@ -89,17 +87,17 @@ def __init__(self, lang, extension, **kwargs): ]) +@rfm.parameterized_test(['Cuda', 'cu']) class DdtGpuCheck(DdtCheck): - def __init__(self, lang, extension, **kwargs): - super().__init__(lang, extension, **kwargs) + def __init__(self, lang, extension): + super().__init__(lang, extension) self.valid_systems = ['daint:gpu', 'dom:gpu', 'kesch:cn'] self.num_gpus_per_node = 1 self.num_tasks_per_node = 1 self.system_modules = { 'daint': ['craype-accel-nvidia60'], - 'dom': ['craype-accel-nvidia60', - 'cudatoolkit/9.0.103_3.7-6.0.4.1_2.1__g72b395b'], + 'dom': ['craype-accel-nvidia60'], 'kesch': ['cudatoolkit'] } sysname = self.current_system.name @@ -115,6 +113,15 @@ def __init__(self, lang, extension, **kwargs): '--trace-at _jacobi-cuda-kernel.cu:111,residue' ] + self.build_system.cppflags = ['-DUSE_MPI', '-D_CSCS_ITMAX=5'] + + if self.current_system.name == 'kesch': + arch = 'sm_37' + self.build_system.ldflags = ['-lm', '-lcudart'] + else: + arch = 'sm_60' + self.build_system.options = ['NVCCFLAGS="-g -arch=%s"' % arch] + self.sanity_patterns = sn.all([ sn.assert_found('MPI implementation', 'ddtreport.txt'), sn.assert_found('Evaluate', 'ddtreport.txt'), @@ -127,22 +134,3 @@ def __init__(self, lang, extension, **kwargs): sn.assert_found(r'Every process in your program has terminated\.', 'ddtreport.txt') ]) - - def compile(self): - self.flags += ' -DUSE_MPI' - self.flags += ' -D_CSCS_ITMAX=5' - - if self.current_system.name == 'kesch': - arch = 'sm_37' - self.flags += ' -lm -lcudart' - else: - arch = 'sm_60' - options = ' NVCCFLAGS="-g -arch=%s"' % arch - super().compile(options=options) - - -def _get_checks(**kwargs): - return [DdtCpuCheck('F90', 'F90', **kwargs), - DdtCpuCheck('C', 'c', **kwargs), - DdtCpuCheck('C++', 'cc', **kwargs), - DdtGpuCheck('Cuda', 'cu', **kwargs)] diff --git a/cscs-checks/tools/profiling_and_debugging/src/C++/Makefile_ddt b/cscs-checks/tools/profiling_and_debugging/src/C++/Makefile_ddt deleted file mode 100644 index 7b090205b7..0000000000 --- a/cscs-checks/tools/profiling_and_debugging/src/C++/Makefile_ddt +++ /dev/null @@ -1,17 +0,0 @@ -LD = $(CXX) - -OBJ = _jacobi.o _main.o -OBJ2 = $(subst _,$(PE_ENV)_,$(OBJ)) -LIB = - -.SUFFIXES: .o .cc - -%.o: %.cc - $(CXX) $(CXXFLAGS) $(DDTFLAGS) -c $< -o $(PE_ENV)$@ - -ddt_check: $(OBJ) - $(LD) $(LDFLAGS) $(OBJ2) $(LIB) -o $@ - -clean: - rm -f *.o o_* *.mod ddt_check_cc - rm -fr *.ptx *.opt *.cg *.ap2 *.rpt *.cub *.lst *.xf diff --git a/cscs-checks/tools/profiling_and_debugging/src/C/Makefile_ddt b/cscs-checks/tools/profiling_and_debugging/src/C/Makefile_ddt deleted file mode 100644 index 7aae321877..0000000000 --- a/cscs-checks/tools/profiling_and_debugging/src/C/Makefile_ddt +++ /dev/null @@ -1,17 +0,0 @@ -LD = $(CC) - -OBJ = _jacobi.o _main.o -OBJ2 = $(subst _,$(PE_ENV)_,$(OBJ)) -LIB = - -.SUFFIXES: .o .c - -%.o: %.c - $(CC) $(CFLAGS) $(DDTFLAGS) -c $< -o $(PE_ENV)$@ - -ddt_check: $(OBJ) - $(LD) $(LDFLAGS) $(OBJ2) $(LIB) -o $@ - -clean: - rm -f *.o o_* *.mod ddt_check_c - rm -fr *.ptx *.opt *.cg *.ap2 *.rpt *.cub *.lst *.xf diff --git a/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile b/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile index e6cab09070..a45b6e820b 100644 --- a/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile +++ b/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile @@ -14,7 +14,7 @@ LIB = $(PREP) nvcc $(NVCCFLAGS) $(DDTFLAGS) -c $< -o $@ %.o: %.c - $(PREP) $(CC) $(CFLAGS) $(DDTFLAGS) -c $< -o $@ + $(PREP) $(CC) $(CPPFLAGS) $(CFLAGS) $(DDTFLAGS) -c $< -o $@ $(EXECUTABLE): $(OBJS) $(PREP) $(LD) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIB) -o $@ diff --git a/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile_ddt b/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile_ddt deleted file mode 100644 index d5217674b5..0000000000 --- a/cscs-checks/tools/profiling_and_debugging/src/Cuda/Makefile_ddt +++ /dev/null @@ -1,22 +0,0 @@ -LD = $(CC) - -OBJ = _jacobi-cuda-kernel.o _jacobi-cuda.o -OBJ2 = $(subst _,$(PE_ENV)_,$(OBJ)) -LIB = - -.SUFFIXES: .o .cu - -%.o: %.cu - nvcc $(NVCCFLAGS) $(DDTFLAGS) -c $< -o $(PE_ENV)$@ - -.SUFFIXES: .o .c - -%.o: %.c - $(CC) $(CFLAGS) $(DDTFLAGS) -c $< -o $(PE_ENV)$@ - -ddt_check: $(OBJ) - $(LD) $(LDFLAGS) $(OBJ2) $(LIB) -o $@ - -clean: - rm -f *.o o_* *.mod ddt_check_cu - rm -fr *.ptx *.opt *.cg *.ap2 *.rpt *.cub *.lst *.xf diff --git a/cscs-checks/tools/profiling_and_debugging/src/F90/Makefile_ddt b/cscs-checks/tools/profiling_and_debugging/src/F90/Makefile_ddt deleted file mode 100644 index 15788a53f2..0000000000 --- a/cscs-checks/tools/profiling_and_debugging/src/F90/Makefile_ddt +++ /dev/null @@ -1,17 +0,0 @@ -LD = $(FC) - -OBJ = _variableDef.o _jacobiddt.o _main.o -OBJ2 = $(subst _,$(PE_ENV)_,$(OBJ)) -LIB = - -.SUFFIXES: .o .F90 - -%.o: %.F90 - $(FC) $(FFLAGS) $(DDTFLAGS) -c $< -o $(PE_ENV)$@ - -ddt_check: $(OBJ) - $(LD) $(LDFLAGS) $(OBJ2) $(LIB) -o $@ - -clean: - rm -f *.o o_* *.mod ddt_check_F90 - rm -fr *.ptx *.opt *.cg *.ap2 *.rpt *.cub *.lst *.xf