|
6 | 6 |
|
7 | 7 | class HelloWorldBaseTest(rfm.RegressionTest): |
8 | 8 | def __init__(self, variant, lang, linkage): |
9 | | - super().__init__() |
10 | 9 | self.variables = {'CRAYPE_LINK_TYPE': linkage} |
11 | 10 | self.prgenv_flags = {} |
12 | 11 | self.lang_names = { |
@@ -36,71 +35,77 @@ def __init__(self, variant, lang, linkage): |
36 | 35 | self.maintainers = ['VH', 'EK'] |
37 | 36 | self.tags = {'production', 'craype'} |
38 | 37 |
|
39 | | - def setup(self, partition, environ, **job_opts): |
40 | 38 | result = sn.findall(r'Hello World from thread \s*(\d+) out ' |
41 | 39 | r'of \s*(\d+) from process \s*(\d+) out of ' |
42 | 40 | r'\s*(\d+)', self.stdout) |
43 | 41 |
|
| 42 | + num_tasks = sn.getattr(self, 'num_tasks') |
| 43 | + num_cpus_per_task = sn.getattr(self, 'num_cpus_per_task') |
| 44 | + |
| 45 | + def tid(match): |
| 46 | + return int(match.group(1)) |
| 47 | + |
| 48 | + def num_threads(match): |
| 49 | + return int(match.group(2)) |
| 50 | + |
| 51 | + def rank(match): |
| 52 | + return int(match.group(3)) |
| 53 | + |
| 54 | + def num_ranks(match): |
| 55 | + return int(match.group(4)) |
| 56 | + |
44 | 57 | self.sanity_patterns = sn.all( |
45 | | - sn.chain([sn.assert_eq(sn.count(result), self.num_tasks * |
46 | | - self.num_cpus_per_task)], |
47 | | - sn.map( |
48 | | - lambda x: sn.assert_lt(int(x.group(1)), |
49 | | - int(x.group(2))), |
50 | | - result), |
51 | | - sn.map( |
52 | | - lambda x: sn.assert_lt(int(x.group(3)), |
53 | | - int(x.group(4))), |
54 | | - result), |
55 | | - sn.map( |
56 | | - lambda x: sn.assert_lt(int(x.group(1)), |
57 | | - self.num_cpus_per_task), |
58 | | - result), |
59 | | - sn.map( |
60 | | - lambda x: sn.assert_eq(int(x.group(2)), |
61 | | - self.num_cpus_per_task), |
62 | | - result), |
63 | | - sn.map( |
64 | | - lambda x: sn.assert_lt(int(x.group(3)), |
65 | | - self.num_tasks), |
66 | | - result), |
67 | | - sn.map( |
68 | | - lambda x: sn.assert_eq(int(x.group(4)), |
69 | | - self.num_tasks), |
70 | | - result), |
71 | | - ) |
| 58 | + sn.chain( |
| 59 | + [sn.assert_eq(sn.count(result), num_tasks*num_cpus_per_task)], |
| 60 | + sn.map(lambda x: sn.assert_lt(tid(x), num_threads(x)), result), |
| 61 | + sn.map(lambda x: sn.assert_lt(rank(x), num_ranks(x)), result), |
| 62 | + sn.map( |
| 63 | + lambda x: sn.assert_lt(tid(x), num_cpus_per_task), result |
| 64 | + ), |
| 65 | + sn.map( |
| 66 | + lambda x: sn.assert_eq(num_threads(x), num_cpus_per_task), |
| 67 | + result |
| 68 | + ), |
| 69 | + sn.map(lambda x: sn.assert_lt(rank(x), num_tasks), result), |
| 70 | + sn.map( |
| 71 | + lambda x: sn.assert_eq(num_ranks(x), num_tasks), result |
| 72 | + ), |
| 73 | + ) |
72 | 74 | ) |
73 | | - |
74 | 75 | self.perf_patterns = { |
75 | 76 | 'compilation_time': sn.getattr(self, 'compilation_time_seconds') |
76 | 77 | } |
77 | 78 | self.reference = { |
78 | 79 | '*': { |
79 | | - 'compilation_time': (60, None, 0.1) |
| 80 | + 'compilation_time': (60, None, 0.1, 's') |
80 | 81 | } |
81 | 82 | } |
82 | 83 |
|
83 | | - envname = environ.name.replace('-nompi', '') |
| 84 | + @rfm.run_before('compile') |
| 85 | + def setflags(self): |
| 86 | + envname = self.current_environ.name.replace('-nompi', '') |
84 | 87 | prgenv_flags = self.prgenv_flags[envname] |
85 | 88 | self.build_system.cflags = prgenv_flags |
86 | 89 | self.build_system.cxxflags = prgenv_flags |
87 | 90 | self.build_system.fflags = prgenv_flags |
88 | | - super().setup(partition, environ, **job_opts) |
89 | 91 |
|
90 | | - def compile(self): |
| 92 | + @rfm.run_before('compile') |
| 93 | + def compile_timer_start(self): |
91 | 94 | self.compilation_time_seconds = datetime.now() |
92 | | - super().compile() |
93 | | - self.compilation_time_seconds = ( |
94 | | - datetime.now() - self.compilation_time_seconds).total_seconds() |
| 95 | + |
| 96 | + @rfm.run_after('compile') |
| 97 | + def compile_timer_end(self): |
| 98 | + elapsed = datetime.now() - self.compilation_time_seconds |
| 99 | + self.compilation_time_seconds = elapsed.total_seconds() |
95 | 100 |
|
96 | 101 |
|
97 | 102 | @rfm.required_version('>=2.14') |
98 | 103 | @rfm.parameterized_test(*([lang, linkage] |
99 | 104 | for lang in ['cpp', 'c', 'f90'] |
100 | 105 | for linkage in ['dynamic', 'static'])) |
101 | 106 | class HelloWorldTestSerial(HelloWorldBaseTest): |
102 | | - def __init__(self, lang, linkage, **kwargs): |
103 | | - super().__init__('serial', lang, linkage, **kwargs) |
| 107 | + def __init__(self, lang, linkage): |
| 108 | + super().__init__('serial', lang, linkage) |
104 | 109 | self.valid_systems += ['kesch:pn'] |
105 | 110 | self.sourcepath += '_serial.' + lang |
106 | 111 | self.descr += ' Serial ' + linkage.capitalize() |
|
0 commit comments