diff --git a/cscs-checks/tools/profiling_and_debugging/gdb4hpc.py b/cscs-checks/tools/profiling_and_debugging/gdb4hpc.py new file mode 100644 index 0000000000..125d737fd1 --- /dev/null +++ b/cscs-checks/tools/profiling_and_debugging/gdb4hpc.py @@ -0,0 +1,84 @@ +import os + +import reframe as rfm +import reframe.utility.sanity as sn + + +class Gdb4hpcCheck(rfm.RegressionTest): + def __init__(self, lang, extension): + super().__init__() + self.name = type(self).__name__ + '_' + lang.replace('+', 'p') + self.descr = 'Cray gdb4hpc check for %s' % lang + self.lang = lang + self.extension = extension + self.build_system = 'Make' + # NOTE: Restrict concurrency to allow creation of Fortran modules + if lang == 'F90': + self.build_system.max_concurrency = 1 + + self.executable = 'gdb4hpc' + self.executable_opts = ['-v'] + self.target_executable = './jacobi' + self.gdbcmds = './%s.in' % self.executable + self.gdbslm = '%s.slm' % self.executable + self.gdbrpt = '%s.rpt' % self.executable + self.sourcesdir = os.path.join('src', lang) + self.valid_prog_environs = ['PrgEnv-gnu'] + self.modules = ['gdb4hpc'] + self.prgenv_flags = ['-g', '-O2', '-fopenmp'] + self.build_system.cflags = self.prgenv_flags + self.build_system.cxxflags = self.prgenv_flags + self.build_system.fflags = self.prgenv_flags + self.num_tasks = 1 + self.num_tasks_per_node = 1 + self.num_cpus_per_task = 4 + self.num_tasks_per_core = 1 + self.num_iterations = 5 + self.variables = { + 'CRAYPE_LINK_TYPE': 'dynamic', + 'OMP_NUM_THREADS': str(self.num_cpus_per_task), + 'ITERATIONS': str(self.num_iterations), + 'OMP_PROC_BIND': 'true', + } + self.maintainers = ['JG'] + self.tags = {'production'} + # gdb4hpc has its own way to launch a debugging job and needs an + # additional jobscript. The reframe jobscript can be copied for that + # purpose, by adding the cray_debug_ comments around the job launch + # command to be debugged, gdb4hpc is then activated by removing the + # #GDB4HPC comments in the next (post_run) step. + self.pre_run = [ + '#GDB4HPC #cray_debug_start', + '#GDB4HPC srun %s' % self.target_executable, + '#GDB4HPC #cray_debug_end' + ] + + def setup(self, partition, environ, **job_opts): + super().setup(partition, environ, **job_opts) + # create extra jobscript for gdb4hpc: + self.post_run = [ + 'sed "s-#GDB4HPC --" %s | ' + 'egrep -v "output=|error=|^gdb4hpc" &> %s' % + (self.job.script_filename, self.gdbslm), + 'gdb4hpc -b %s &> %s' % (self.gdbcmds, self.gdbrpt) + ] + + +@rfm.required_version('>=2.14') +@rfm.parameterized_test(['F90', 'F90']) +class Gdb4hpcCpuCheck(Gdb4hpcCheck): + def __init__(self, lang, extension): + super().__init__(lang, extension) + self.valid_systems = ['dom:gpu', 'dom:mc'] + self.sanity_patterns = sn.all([ + sn.assert_reference(sn.extractsingle( + r'^tst\{0\}:\s+(?P\d+.\d+[eE]-\d+)', + 'gdb4hpc.rpt', 'result', float), + 2.572e-6, -1e-1, 1.0e-1), + + sn.assert_found(r'gdb4hpc \d\.\d - Cray Line Mode Parallel Debug', + 'gdb4hpc.rpt'), + + sn.assert_found(r'Shutting down debugger and killing application', + 'gdb4hpc.rpt') + ]) diff --git a/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.in b/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.in new file mode 100644 index 0000000000..843c582094 --- /dev/null +++ b/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.in @@ -0,0 +1,28 @@ +# this line is mandatory (cray case #224617): +maint set sync on +# 1 MPI * x OpenMP: +launch $tst{1} ./jacobi --sbatch=./gdb4hpc.slm +break _jacobi.F90:90 +# ----1 +continue +list 90,91 +print residual +# ----2 +continue +print residual +# ----3 +continue +print residual +# ----4 +continue +print residual +# ----5 +continue +print residual +quit + +# can use printf with gdb4hpc only in gdbmode: +# printf "(_jacobi.F90:90)] residual:%f\n", residual +# CASE #227672 - GDB4HPC: PRINTF SUPPORT + +# TODO: tracepoints diff --git a/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.slm b/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.slm new file mode 100644 index 0000000000..d059d3c0a7 --- /dev/null +++ b/cscs-checks/tools/profiling_and_debugging/src/F90/gdb4hpc.slm @@ -0,0 +1,27 @@ +#!/bin/bash -l +#SBATCH --job-name="rfm_GDB4HPC_Check_F90_job" +#SBATCH --time=0:1:0 + +#SBATCH --ntasks=1 +#SBATCH --ntasks-per-node=1 +#SBATCH --cpus-per-task=4 +#SBATCH --ntasks-per-core=1 + +#SBATCH --output=o +#SBATCH --error=o +#SBATCH --constraint=gpu + +module load daint-gpu +module unload PrgEnv-cray +module load PrgEnv-gnu +module load gdb4hpc +module list -t + +export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK +export ITERATIONS=5 +export OMP_PROC_BIND=true + +#cray_debug_start +srun ./jacobi +#cray_debug_end +