Skip to content
30 changes: 29 additions & 1 deletion easybuild/easyblocks/i/impi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@
@author: Pieter De Baets (Ghent University)
@author: Jens Timmerman (Ghent University)
@author: Damian Alvarez (Forschungszentrum Juelich GmbH)
@author: Alex Domingo (Vrije Universiteit Brussel)
"""
import os
from distutils.version import LooseVersion

import easybuild.tools.toolchain as toolchain
from easybuild.easyblocks.generic.intelbase import IntelBase, ACTIVATION_NAME_2012, LICENSE_FILE_NAME_2012
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import apply_regex_substitutions, change_dir, extract_file, mkdir, write_file
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import get_shared_lib_ext
from easybuild.tools.toolchain.mpi import get_mpi_cmd_template


class EB_impi(IntelBase):
Expand Down Expand Up @@ -210,7 +213,32 @@ def sanity_check_step(self):
'dirs': [],
}

super(EB_impi, self).sanity_check_step(custom_paths=custom_paths)
custom_commands = []

if LooseVersion(self.version) >= LooseVersion('2017'):
# Add minimal test program to sanity checks
impi_testsrc = os.path.join(self.installdir, 'test/test.c')
impi_testexe = os.path.join(self.builddir, 'mpi_test')
self.log.info("Adding minimal MPI test program to sanity checks: %s", impi_testsrc)

# Build test program with appropriate compiler from current toolchain
comp_fam = self.toolchain.comp_family()
if comp_fam == toolchain.INTELCOMP:
build_comp = 'mpiicc'
else:
build_comp = 'mpicc'
build_cmd = "%s %s -o %s" % (build_comp, impi_testsrc, impi_testexe)

# Execute test program with appropriate MPI executable for target toolchain
params = {'nr_ranks': self.cfg['parallel'], 'cmd': impi_testexe}
mpi_cmd_tmpl, params = get_mpi_cmd_template(toolchain.INTELMPI, params, mpi_version=self.version)

custom_commands.extend([
build_cmd, # build test program
mpi_cmd_tmpl % params, # run test program
])

super(EB_impi, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)

def make_module_req_guess(self):
"""
Expand Down