From 16ea44250248e5ae900c25089f9a24d38b0cfd20 Mon Sep 17 00:00:00 2001 From: crivella Date: Fri, 12 Jul 2024 16:08:17 +0200 Subject: [PATCH 1/9] Added benchmark tests for MetalWalls --- hpctestlib/sciapps/metalwalls/benchmarks.py | 267 ++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 hpctestlib/sciapps/metalwalls/benchmarks.py diff --git a/hpctestlib/sciapps/metalwalls/benchmarks.py b/hpctestlib/sciapps/metalwalls/benchmarks.py new file mode 100644 index 0000000000..450a06d877 --- /dev/null +++ b/hpctestlib/sciapps/metalwalls/benchmarks.py @@ -0,0 +1,267 @@ +"""ReFrame benchmark for MetalWalls""" +import re +from typing import TypeVar + +import reframe as rfm +import reframe.utility.sanity as sn +from reframe.core.builtins import (performance_function, run_after, run_before, + sanity_function) +from reframe.core.parameters import TestParam as parameter +from reframe.core.variables import TestVar as variable + +R = TypeVar('R') + +address_tpl = ( + 'https://gitlab.com/ampere2/metalwalls/-/raw/{version}/{bench}/{file}' + '?ref_type=tags\&inline=false' +) + +extract_fields = [ + ####### + ('Ions->Atoms Coulomb potential', 'long range', 'I->A Cpot'), + ('Ions->Atoms Coulomb potential', 'k==0', 'I->A Cpot'), + ('Ions->Atoms Coulomb potential', 'short range', 'I->A Cpot'), + + ####### + ('Atoms->Atoms Coulomb potential', 'long range', 'A->A Cpot'), + ('Atoms->Atoms Coulomb potential', 'k==0', 'A->A Cpot'), + ('Atoms->Atoms Coulomb potential', 'short range', 'A->A Cpot'), + ('Atoms->Atoms Coulomb potential', 'self', 'A->A Cpot'), + + ####### + ('Atoms->Atoms Coulomb grad Q', 'long range', 'A->A gradQ'), + ('Atoms->Atoms Coulomb grad Q', 'k==0', 'A->A gradQ'), + ('Atoms->Atoms Coulomb grad Q', 'short range', 'A->A gradQ'), + ('Atoms->Atoms Coulomb grad Q', 'self', 'A->A gradQ'), + + ####### + ('Ions Coulomb forces', 'long range', 'Ions Cfrc'), + ('Ions Coulomb forces', 'k==0', 'Ions Cfrc'), + ('Ions Coulomb forces', 'short range', 'Ions Cfrc'), + ('Ions Coulomb forces', 'intramolecular', 'Ions Cfrc'), + + ####### + ('Ions Coulomb potential', 'long range', 'Ions Cpot'), + ('Ions Coulomb potential', 'k==0', 'Ions Cpot'), + ('Ions Coulomb potential', 'short range', 'Ions Cpot'), + ('Ions Coulomb potential', 'intramolecular', 'Ions Cpot'), + ('Ions Coulomb potential', 'self', 'Ions Cpot'), + + ####### + ( + 'Ions Coulomb electric field (due to charges)', + 'long range', + 'Ions Cfield(charges)' + ), + ( + 'Ions Coulomb electric field (due to charges)', + 'k==0', + 'Ions Cfield(charges)' + ), + ( + 'Ions Coulomb electric field (due to charges)', + 'short range', + 'Ions Cfield(charges)' + ), + ( + 'Ions Coulomb electric field (due to charges)', + 'intramolecular', + 'Ions Cfield(charges)' + ), + + ####### + ( + 'Ions Coulomb electric field (due to dipoles)', + 'long range', + 'Ions Cfield(dipoles)' + ), + ( + 'Ions Coulomb electric field (due to dipoles)', + 'k==0', + 'Ions Cfield(dipoles)' + ), + ( + 'Ions Coulomb electric field (due to dipoles)', + 'short range', + 'Ions Cfield(dipoles)' + ), + ( + 'Ions Coulomb electric field (due to dipoles)', + 'intramolecular', + 'Ions Cfield(dipoles)' + ), + ( + 'Ions Coulomb electric field (due to dipoles)', + 'self', + 'Ions Cfield(dipoles)' + ), + + ####### + ('Ions Coulomb electric field gradient', 'long range', 'Ions Cfield grad'), + ('Ions Coulomb electric field gradient', 'short range', 'Ions Cfield grad'), + ('Ions Coulomb electric field gradient', 'self', 'Ions Cfield grad'), + + ####### + ('Ions Coulomb gradient mu', 'long range', 'Ions C mu_grad'), + ('Ions Coulomb gradient mu', 'k==0', 'Ions C mu_grad'), + ('Ions Coulomb gradient mu', 'short range', 'Ions C mu_grad'), + ('Ions Coulomb gradient mu', 'self', 'Ions C mu_grad'), + + ####### + ('Rattle', 'positions', 'Rattle'), + ('Rattle', 'velocities', 'Rattle'), + + ####### + ('van der Waals', 'vdW forces', 'van der Waals'), + ('van der Waals', 'vdW potential', 'van der Waals'), + + ####### + ('Intramolecular', 'Intramolecular forces', 'Intramolecular'), + ('Intramolecular', 'Intramolecular potential', 'Intramolecular'), + + ####### + ('Additional degrees', 'Electrode charge computation', 'Deg of freedom'), + ('Additional degrees', 'Inversion of the matrix', 'Deg of freedom'), + ('Additional degrees', 'One matrix-vector product', 'Deg of freedom'), + ('Additional degrees', 'Melt dipoles computation', 'Deg of freedom'), + ('Additional degrees', 'Inversion of the matrix', 'Deg of freedom'), + ('Additional degrees', 'One matrix-vector product', 'Deg of freedom'), + ('Additional degrees', 'AIM DOFs computation', 'Deg of freedom'), + + ####### + ('Diagnostics', 'diagnostics computations', 'Diagnostics'), + ('Diagnostics', 'IO', 'Diagnostics'), +] + +@rfm.simple_test +class MetalWallsCheck(rfm.RunOnlyRegressionTest): + """MetalWalls benchmark test. + + `MetalWalls `__ is a molecular + dynamics code dedicated to the modelling of electrochemical systems. + Its main originality is the inclusion of a series of methods allowing to + apply a constant potential within the electrode materials. + + The benchmarks consist of a set of different inputs files that vary in the + number of atoms and the type of simulation performed. + They can be found in the following repository, which is also versioned: + https://gitlab.com/ampere2/metalwalls/. + + """ + + #: The name of the output files to keep. + #: + #: :type: :class:`List[str]` + #: :default: ``'run.out'`` + keep_files = ['run.out', ] + + #: The version of the benchmark suite to use. + #: + #: :type: :class:`str` + #: :default: ``'21.06.1'`` + benchmark_version = variable(str, value='21.06.1', loggable=True) + + #: Collect and report detailed performance metrics. + #: + #: :type: :class:`bool` + #: :default: ``False`` + debug_metrics = variable(bool, value=False, loggable=True) + + #: Parameter pack encoding the benchmark information. + #: + #: The first element of the tuple refers to the benchmark name, + #: + #: :type: `Tuple[str,]` + #: :values: + benchmark_info = parameter([ + ('hackathonGPU/benchmark',), + ('hackathonGPU/benchmark2',), + ('hackathonGPU/benchmark3',), + ('hackathonGPU/benchmark4',), + ('hackathonGPU/benchmark5',), + ('hackathonGPU/benchmark6',), + ], fmt=lambda x: x[0], loggable=True) + + @run_after('init') + def prepare_test(self): + """Hook to the set the downloading of the pseudo-potentials""" + self.__bench, = self.benchmark_info + self.descr = f'MetalWalls {self.__bench} benchmark' + files_addresses = [ + address_tpl.format( + version=self.benchmark_version, + bench=self.__bench, + file=_ + ) for _ in ['data.inpt', 'runtime.inpt'] + ] + self.prerun_cmds += [ + f"curl -LJO '{_}'" for _ in files_addresses + ] + + @performance_function('s') + def total_elapsed_time(self): + """Extract the total elapsed time from the output file""" + return sn.extractsingle( + r'Total elapsed time:\s+(?P