Skip to content

Commit b6b4395

Browse files
authored
Merge pull request #3917 from Crivella/fix-hpl
Make HPL awayblock intel-aware + allow running the `xhpl` benchmark as a test
2 parents 7429645 + 71b61e6 commit b6b4395

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

easybuild/easyblocks/h/hpl.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@
3030
@author: Kenneth Hoste (Ghent University)
3131
@author: Pieter De Baets (Ghent University)
3232
@author: Jens Timmerman (Ghent University)
33+
@author: Davide Grassano (CECAM - EPFL)
3334
"""
3435

36+
import re
3537
import os
3638

39+
import easybuild.tools.toolchain as toolchain
3740
from easybuild.easyblocks.generic.configuremake import ConfigureMake
3841
from easybuild.tools.build_log import EasyBuildError
42+
from easybuild.tools.config import build_option
3943
from easybuild.tools.filetools import change_dir, copy_file, mkdir, remove_file, symlink
4044
from easybuild.tools.run import run_shell_cmd
4145

@@ -104,10 +108,74 @@ def build_step(self, topdir=None):
104108
# C compilers flags
105109
extra_makeopts += "CCFLAGS='$(HPL_DEFS) %s' " % os.getenv('CFLAGS')
106110

111+
comp_fam = self.toolchain.comp_family()
112+
if comp_fam in [toolchain.INTELCOMP]:
113+
# Explicitly disable optimization, since Intel compilers apply some default
114+
# level not shown on the command line.
115+
# This breaks the result comparison, resulting in all tests failing residual checks.
116+
# See https://github.com/easybuilders/easybuild-easyconfigs/pull/23704#issuecomment-3202392904
117+
extra_makeopts += 'CCNOOPT=\'$(HPL_DEFS) -O0\' '
118+
107119
# set options and build
108120
self.cfg.update('buildopts', extra_makeopts)
109121
super().build_step()
110122

123+
def test_step(self):
124+
"""Test by running xhpl"""
125+
srcdir = os.path.join(self.cfg['start_dir'], 'bin', 'UNKNOWN')
126+
change_dir(srcdir)
127+
128+
pre_cmd = ""
129+
post_cmd = ""
130+
131+
# xhpl needs atleast 4 processes to run the test suite
132+
req_cpus = 4
133+
134+
mpi_fam = self.toolchain.mpi_family()
135+
if mpi_fam is None:
136+
self.report_test_failure("Toolchain does not include an MPI implementation, cannot run tests")
137+
138+
parallel = self.cfg.parallel
139+
if not build_option('mpi_tests'):
140+
self.log.info("MPI tests disabled from buildoption. Setting parallel to 1")
141+
parallel = 1
142+
143+
if parallel < req_cpus:
144+
self.log.info("Running tests with 1 oversubscribed process")
145+
146+
pin_str = ','.join(["0"] * req_cpus)
147+
if mpi_fam in [toolchain.INTELMPI]:
148+
pre_cmd = f"I_MPI_PIN_PROCESSOR_LIST=\"{pin_str}\" I_MPI_PIN=on "
149+
elif mpi_fam in [toolchain.OPENMPI]:
150+
post_cmd = f"--cpu-set {pin_str}"
151+
elif mpi_fam in [toolchain.MPICH]:
152+
post_cmd = f"-bind-to user:{pin_str}"
153+
else:
154+
self.report_test_failure("Don't know how to oversubscribe for `%s` MPI family" % mpi_fam)
155+
156+
cmd = self.toolchain.mpi_cmd_for(f'{post_cmd} ./xhpl', req_cpus)
157+
cmd = f'{pre_cmd} {cmd}'
158+
res = run_shell_cmd(cmd)
159+
out = res.output
160+
161+
passed_rgx = re.compile(r'(\d+) tests completed and passed')
162+
failed_rgx = re.compile(r'(\d+) tests completed and failed')
163+
164+
nfailed = 0
165+
passed_mch = passed_rgx.search(out)
166+
failed_mch = failed_rgx.search(out)
167+
if passed_mch:
168+
npassed = int(passed_mch.group(1))
169+
self.log.info("%d tests passed residual checks in xhpl output" % npassed)
170+
else:
171+
self.report_test_failure("Could not find test results in output of xhpl")
172+
173+
if failed_mch:
174+
nfailed = int(failed_mch.group(1))
175+
176+
if nfailed > 0:
177+
self.report_test_failure("%d tests failed residual checks in xhpl output" % nfailed)
178+
111179
def install_step(self):
112180
"""
113181
Install by copying files to install dir

0 commit comments

Comments
 (0)