|
30 | 30 | @author: Kenneth Hoste (Ghent University) |
31 | 31 | @author: Pieter De Baets (Ghent University) |
32 | 32 | @author: Jens Timmerman (Ghent University) |
| 33 | +@author: Davide Grassano (CECAM - EPFL) |
33 | 34 | """ |
34 | 35 |
|
| 36 | +import re |
35 | 37 | import os |
36 | 38 |
|
| 39 | +import easybuild.tools.toolchain as toolchain |
37 | 40 | from easybuild.easyblocks.generic.configuremake import ConfigureMake |
38 | 41 | from easybuild.tools.build_log import EasyBuildError |
| 42 | +from easybuild.tools.config import build_option |
39 | 43 | from easybuild.tools.filetools import change_dir, copy_file, mkdir, remove_file, symlink |
40 | 44 | from easybuild.tools.run import run_shell_cmd |
41 | 45 |
|
@@ -104,10 +108,74 @@ def build_step(self, topdir=None): |
104 | 108 | # C compilers flags |
105 | 109 | extra_makeopts += "CCFLAGS='$(HPL_DEFS) %s' " % os.getenv('CFLAGS') |
106 | 110 |
|
| 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 | + |
107 | 119 | # set options and build |
108 | 120 | self.cfg.update('buildopts', extra_makeopts) |
109 | 121 | super().build_step() |
110 | 122 |
|
| 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 | + |
111 | 179 | def install_step(self): |
112 | 180 | """ |
113 | 181 | Install by copying files to install dir |
|
0 commit comments