Skip to content

Commit e488f73

Browse files
committed
limit parallelism of OpenBLAS tests with parallel property
1 parent d9dec7f commit e488f73

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

easybuild/easyblocks/o/openblas.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,16 @@ def test_step(self):
223223
run_tests += [self.cfg['runtest']]
224224

225225
for runtest in run_tests:
226-
cmd = f"{self.cfg['pretestopts']} make {runtest} {self.cfg['testopts']}"
226+
# Try to limit parallelism for the tests. If OMP_NUM_THREADS or OPENBLAS_NUM_THREADS is already set,
227+
# use the existing value. If not, we'll set OMP_NUM_THREADS for OpenBLAS built with OpenMP, and
228+
# OPENBLAS_NUM_THREADS if built with threads.
229+
parallelism_env = ''
230+
if "USE_OPENMP='1'" in self.cfg['testopts'] and 'OMP_NUM_THREADS' not in self.cfg['pretestopts']:
231+
parallelism_env += f'OMP_NUM_THREADS={self.cfg.parallel} '
232+
if "USE_THREAD='1'" in self.cfg['testopts'] and 'OPENBLAS_NUM_THREADS' not in self.cfg['pretestopts']:
233+
parallelism_env += f'OPENBLAS_NUM_THREADS={self.cfg.parallel} '
234+
235+
cmd = f"{parallelism_env} {self.cfg['pretestopts']} make {runtest} {self.cfg['testopts']}"
227236
res = run_shell_cmd(cmd)
228237

229238
# Raise an error if any test failed

0 commit comments

Comments
 (0)