|
| 1 | +# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich) |
| 2 | +# ReFrame Project Developers. See the top-level LICENSE file for details. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: BSD-3-Clause |
| 5 | + |
| 6 | +import reframe as rfm |
| 7 | +import reframe.utility.sanity as sn |
| 8 | + |
| 9 | + |
| 10 | +@rfm.simple_test |
| 11 | +class StreamMultiSysTest(rfm.RegressionTest): |
| 12 | + valid_systems = ['*'] |
| 13 | + valid_prog_environs = ['cray', 'gnu', 'intel', 'pgi'] |
| 14 | + prebuild_cmds = [ |
| 15 | + 'wget http://www.cs.virginia.edu/stream/FTP/Code/stream.c', |
| 16 | + ] |
| 17 | + build_system = 'SingleSource' |
| 18 | + sourcepath = 'stream.c' |
| 19 | + variables = { |
| 20 | + 'OMP_NUM_THREADS': '4', |
| 21 | + 'OMP_PLACES': 'cores' |
| 22 | + } |
| 23 | + reference = { |
| 24 | + 'catalina': { |
| 25 | + 'Copy': (25200, -0.05, 0.05, 'MB/s'), |
| 26 | + 'Scale': (16800, -0.05, 0.05, 'MB/s'), |
| 27 | + 'Add': (18500, -0.05, 0.05, 'MB/s'), |
| 28 | + 'Triad': (18800, -0.05, 0.05, 'MB/s') |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + # Flags per programming environment |
| 33 | + flags = variable(dict, value={ |
| 34 | + 'cray': ['-fopenmp', '-O3', '-Wall'], |
| 35 | + 'gnu': ['-fopenmp', '-O3', '-Wall'], |
| 36 | + 'intel': ['-qopenmp', '-O3', '-Wall'], |
| 37 | + 'pgi': ['-mp', '-O3'] |
| 38 | + }) |
| 39 | + |
| 40 | + # Number of cores for each system |
| 41 | + cores = variable(dict, value={ |
| 42 | + 'catalina:default': 4, |
| 43 | + 'daint:gpu': 12, |
| 44 | + 'daint:mc': 36, |
| 45 | + 'daint:login': 10 |
| 46 | + }) |
| 47 | + |
| 48 | + @run_before('compile') |
| 49 | + def set_compiler_flags(self): |
| 50 | + self.build_system.cppflags = ['-DSTREAM_ARRAY_SIZE=$((1 << 25))'] |
| 51 | + environ = self.current_environ.name |
| 52 | + self.build_system.cflags = self.flags.get(environ, []) |
| 53 | + |
| 54 | + @run_before('run') |
| 55 | + def set_num_threads(self): |
| 56 | + num_threads = self.cores.get(self.current_partition.fullname, 1) |
| 57 | + self.num_cpus_per_task = num_threads |
| 58 | + self.variables = { |
| 59 | + 'OMP_NUM_THREADS': str(num_threads), |
| 60 | + 'OMP_PLACES': 'cores' |
| 61 | + } |
| 62 | + |
| 63 | + @sanity_function |
| 64 | + def validate_solution(self): |
| 65 | + return sn.assert_found(r'Solution Validates', self.stdout) |
| 66 | + |
| 67 | + @performance_function('MB/s') |
| 68 | + def extract_bw(self, kind='Copy'): |
| 69 | + if kind not in {'Copy', 'Scale', 'Add', 'Triad'}: |
| 70 | + raise ValueError(f'illegal value in argument kind ({kind!r})') |
| 71 | + |
| 72 | + return sn.extractsingle(rf'{kind}:\s+(\S+)\s+.*', |
| 73 | + self.stdout, 1, float) |
| 74 | + |
| 75 | + @run_before('performance') |
| 76 | + def set_perf_variables(self): |
| 77 | + self.perf_variables = { |
| 78 | + 'Copy': self.extract_bw(), |
| 79 | + 'Scale': self.extract_bw('Scale'), |
| 80 | + 'Add': self.extract_bw('Add'), |
| 81 | + 'Triad': self.extract_bw('Triad'), |
| 82 | + } |
0 commit comments