Skip to content

Commit d192c3f

Browse files
committed
Add sanity check on expected final energy and temperature
1 parent 15e7966 commit d192c3f

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

hpctestlib/sciapps/metalwalls/benchmarks.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,25 @@ class MetalWallsCheck(rfm.RunOnlyRegressionTest):
176176
#: Parameter pack encoding the benchmark information.
177177
#:
178178
#: The first element of the tuple refers to the benchmark name,
179+
#: the second is the final kinetic energy the third is the related
180+
#: tolerance, the fourth is the absolute temperature and the fifth is
181+
#: the related tolerance
179182
#:
180-
#: :type: `Tuple[str,]`
183+
#: :type: `Tuple[str, float, float, float, float]`
181184
#: :values:
182185
benchmark_info = parameter([
183-
('hackathonGPU/benchmark',),
184-
('hackathonGPU/benchmark2',),
185-
('hackathonGPU/benchmark3',),
186-
('hackathonGPU/benchmark4',),
187-
('hackathonGPU/benchmark5',),
188-
('hackathonGPU/benchmark6',),
186+
('hackathonGPU/benchmark', 14.00, 0.05, 301.74, 0.5),
187+
('hackathonGPU/benchmark2', 14.00, 0.05, 301.74, 0.5),
188+
('hackathonGPU/benchmark3', 16.08, 0.05, 293.42, 0.5),
189+
('hackathonGPU/benchmark4', 16.08, 0.05, 293.42, 0.5),
190+
('hackathonGPU/benchmark5', 25.72, 0.05, 297.47, 0.5),
191+
('hackathonGPU/benchmark6', 25.72, 0.05, 297.47, 0.5),
189192
], fmt=lambda x: x[0], loggable=True)
190193

191194
@run_after('init')
192195
def prepare_test(self):
193196
"""Hook to the set the downloading of the pseudo-potentials"""
194-
self.__bench, = self.benchmark_info
197+
self.__bench, _, _, _, _ = self.benchmark_info
195198
self.descr = f'MetalWalls {self.__bench} benchmark'
196199
files_addresses = [
197200
address_tpl.format(
@@ -210,6 +213,21 @@ def total_elapsed_time(self):
210213
return sn.extractsingle(
211214
r'Total elapsed time:\s+(?P<time>\S+)', 'run.out', 'time', float
212215
)
216+
217+
@sn.deferrable
218+
def extract_kinetic_energy(self):
219+
"""Extract the final kinetic energy from the output file"""
220+
rgx = r'\|step\| +kinetic energy: +(?P<flag>\S+)'
221+
app = sn.extractall(rgx, 'run.out', 'flag', float)
222+
return app[-1]
223+
224+
@sn.deferrable
225+
def extract_temperature(self):
226+
"""Extract the final temperature from the output file"""
227+
rgx = r'\|step\| +temperature: +(?P<flag>\S+)'
228+
app = sn.extractall(rgx, 'run.out', 'flag', float)
229+
return app[-1]
230+
213231

214232
@performance_function('s')
215233
def extract_time(
@@ -273,4 +291,13 @@ def set_perf_variables(self):
273291
@sanity_function
274292
def assert_job_finished(self):
275293
"""Check if the job finished successfully"""
276-
return sn.assert_found(r'Total elapsed time', 'run.out')
294+
energy = self.extract_kinetic_energy()
295+
temp = self.extract_temperature()
296+
_, energy_ref, energy_tol, temp_ref, temp_tol = self.benchmark_info
297+
en_rtol = energy_tol / energy_ref
298+
t_rtol = temp_tol / temp_ref
299+
return sn.all([
300+
sn.assert_found(r'Total elapsed time', 'run.out'),
301+
sn.assert_reference(energy, energy_ref, -en_rtol, en_rtol),
302+
sn.assert_reference(temp, temp_ref, -t_rtol, t_rtol)
303+
])

0 commit comments

Comments
 (0)