Skip to content

Commit 18c81b9

Browse files
authored
Merge pull request #2601 from casparvl/develop
enhance PETSc easyblock to run tests in parallel
2 parents be7ba1c + c30a827 commit 18c81b9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

easybuild/easyblocks/p/petsc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ def extra_options():
7777
'papi_inc': ['/usr/include', "Path for PAPI include files", CUSTOM],
7878
'papi_lib': ['/usr/lib64/libpapi.so', "Path for PAPI library", CUSTOM],
7979
'runtest': ['test', "Make target to test build", BUILD],
80+
'test_parallel': [
81+
None,
82+
"Number of parallel PETSc tests launched. If unset, 'parallel' will be used",
83+
CUSTOM
84+
],
8085
'download_deps_static': [[], "Dependencies that should be downloaded and installed static", CUSTOM],
8186
'download_deps_shared': [[], "Dependencies that should be downloaded and installed shared", CUSTOM],
8287
'download_deps': [[], "Dependencies that should be downloaded and installed", CUSTOM]
@@ -297,6 +302,10 @@ def configure_step(self):
297302
cmd = "./config/configure.py %s" % self.get_cfg('configopts')
298303
run_cmd(cmd, log_all=True, simple=True)
299304

305+
# Make sure to set test_parallel before self.cfg['parallel'] is set to None
306+
if self.cfg['test_parallel'] is None and self.cfg['parallel']:
307+
self.cfg['test_parallel'] = self.cfg['parallel']
308+
300309
# PETSc > 3.5, make does not accept -j
301310
# to control parallel build, we need to specify MAKE_NP=... as argument to 'make' command
302311
if LooseVersion(self.version) >= LooseVersion("3.5"):
@@ -305,6 +314,25 @@ def configure_step(self):
305314

306315
# default make should be fine
307316

317+
def test_step(self):
318+
"""
319+
Test the compilation
320+
"""
321+
322+
# Each PETSc test may use multiple threads, so running "self.cfg['parallel']" of them may lead to
323+
# some oversubscription every now and again. Not a big deal, but if needed a reduced parallelism
324+
# can be specified with test_parallel - and it takes priority
325+
paracmd = ''
326+
self.log.info("In test_step: %s" % self.cfg['test_parallel'])
327+
if self.cfg['test_parallel'] is not None:
328+
paracmd = "-j %s" % self.cfg['test_parallel']
329+
330+
if self.cfg['runtest']:
331+
cmd = "%s make %s %s %s" % (self.cfg['pretestopts'], paracmd, self.cfg['runtest'], self.cfg['testopts'])
332+
(out, _) = run_cmd(cmd, log_all=True, simple=False)
333+
334+
return out
335+
308336
def install_step(self):
309337
"""
310338
Install using make install (for non-source installations),

0 commit comments

Comments
 (0)