Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update imkl easyblock to support oneAPI versions (>= 2021.x) #2407

Merged
merged 3 commits into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 83 additions & 50 deletions easybuild/easyblocks/i/imkl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
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, remove_dir
from easybuild.tools.filetools import apply_regex_substitutions, change_dir, remove_dir, write_file
from easybuild.tools.modules import get_software_root
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import get_shared_lib_ext
Expand Down Expand Up @@ -147,21 +147,31 @@ def make_module_req_guess(self):
if self.cfg['m32']:
raise EasyBuildError("32-bit not supported yet for IMKL v%s (>= 10.3)", self.version)
else:
if LooseVersion(self.version) >= LooseVersion('2021'):
compiler_subdir = os.path.join('compiler', self.version, 'linux', 'compiler', 'lib', 'intel64_lin')
mkl_subdir = os.path.join('mkl', self.version)
pkg_config_path = [os.path.join(mkl_subdir, 'tools', 'pkgconfig')]
else:
compiler_subdir = os.path.join('lib', 'intel64')
mkl_subdir = 'mkl'
pkg_config_path = [os.path.join(mkl_subdir, 'bin', 'pkgconfig')]
guesses['MANPATH'] = ['man', 'man/en_US']
if LooseVersion(self.version) >= LooseVersion('11.0'):
if LooseVersion(self.version) >= LooseVersion('11.3'):
guesses['MIC_LD_LIBRARY_PATH'] = ['lib/intel64_lin_mic', 'mkl/lib/mic']
elif LooseVersion(self.version) >= LooseVersion('11.1'):
guesses['MIC_LD_LIBRARY_PATH'] = ['lib/mic', 'mkl/lib/mic']
else:
guesses['MIC_LD_LIBRARY_PATH'] = ['compiler/lib/mic', 'mkl/lib/mic']
library_path = [compiler_subdir, os.path.join(mkl_subdir, 'lib', 'intel64')]
cpath = [os.path.join(mkl_subdir, 'include'), os.path.join(mkl_subdir, 'include', 'fftw')]
guesses.update({
'PATH': [],
'LD_LIBRARY_PATH': ['lib/intel64', 'mkl/lib/intel64'],
'LIBRARY_PATH': ['lib/intel64', 'mkl/lib/intel64'],
'MANPATH': ['man', 'man/en_US'],
'CPATH': ['mkl/include', 'mkl/include/fftw'],
'PKG_CONFIG_PATH': ['mkl/bin/pkgconfig'],
'LD_LIBRARY_PATH': library_path,
'LIBRARY_PATH': library_path,
'CPATH': cpath,
'PKG_CONFIG_PATH': pkg_config_path,
})
if LooseVersion(self.version) >= LooseVersion('11.0'):
if LooseVersion(self.version) >= LooseVersion('11.3'):
guesses['MIC_LD_LIBRARY_PATH'] = ['lib/intel64_lin_mic', 'mkl/lib/mic']
elif LooseVersion(self.version) >= LooseVersion('11.1'):
guesses['MIC_LD_LIBRARY_PATH'] = ['lib/mic', 'mkl/lib/mic']
else:
guesses['MIC_LD_LIBRARY_PATH'] = ['compiler/lib/mic', 'mkl/lib/mic']
else:
if self.cfg['m32']:
guesses.update({
Expand All @@ -183,7 +193,13 @@ def make_module_req_guess(self):
def make_module_extra(self):
"""Overwritten from Application to add extra txt"""
txt = super(EB_imkl, self).make_module_extra()
txt += self.module_generator.set_environment('MKLROOT', os.path.join(self.installdir, 'mkl'))

if LooseVersion(self.version) >= LooseVersion('2021'):
mklroot = os.path.join(self.installdir, 'mkl', self.version)
else:
mklroot = os.path.join(self.installdir, 'mkl')

txt += self.module_generator.set_environment('MKLROOT', mklroot)
return txt

def post_install_step(self):
Expand Down Expand Up @@ -216,7 +232,11 @@ def post_install_step(self):
'libmkl_cdft.a': 'GROUP (libmkl_cdft_core.a)'
}

if LooseVersion(self.version) >= LooseVersion('10.3'):
loosever = LooseVersion(self.version)

if loosever >= LooseVersion('2021'):
libsubdir = os.path.join('mkl', self.version, 'lib', 'intel64')
elif loosever >= LooseVersion('10.3'):
libsubdir = os.path.join('mkl', 'lib', 'intel64')
else:
if self.cfg['m32']:
Expand All @@ -227,18 +247,15 @@ def post_install_step(self):
for fil, txt in extra.items():
dest = os.path.join(self.installdir, libsubdir, fil)
if not os.path.exists(dest):
try:
f = open(dest, 'w')
f.write(txt)
f.close()
self.log.info("File %s written" % dest)
except IOError as err:
raise EasyBuildError("Can't write file %s: %s", dest, err)
write_file(dest, txt)

# build the mkl interfaces, if desired
if self.cfg['interfaces']:

if LooseVersion(self.version) >= LooseVersion('10.3'):
if loosever >= LooseVersion('2021'):
intsubdir = os.path.join('mkl', self.version, 'interfaces')
inttarget = 'libintel64'
elif loosever >= LooseVersion('10.3'):
intsubdir = os.path.join('mkl', 'interfaces')
inttarget = 'libintel64'
else:
Expand All @@ -262,16 +279,16 @@ def post_install_step(self):
compopt = None
# determine whether we're using a non-Intel GCC-based or PGI-based toolchain
# can't use toolchain.comp_family, because of system toolchain used when installing imkl
if get_software_root('icc') is None:
if get_software_root('icc') or get_software_root('intel-compilers'):
compopt = 'compiler=intel'
else:
# check for PGI first, since there's a GCC underneath PGI too...
if get_software_root('PGI'):
compopt = 'compiler=pgi'
elif get_software_root('GCC'):
compopt = 'compiler=gnu'
else:
raise EasyBuildError("Not using Intel/GCC/PGI compilers, don't know how to build wrapper libs")
else:
compopt = 'compiler=intel'

# patch makefiles for cdft wrappers when PGI is used as compiler
if get_software_root('PGI'):
Expand Down Expand Up @@ -366,15 +383,15 @@ def sanity_check_step(self):
extralibs = ['libmkl_blacs_intelmpi_%(suff)s.' + shlib_ext, 'libmkl_scalapack_%(suff)s.' + shlib_ext]

if self.cfg['interfaces']:
compsuff = '_intel'
if get_software_root('icc') is None:
# check for PGI first, since there's a GCC underneath PGI too...
if get_software_root('PGI'):
compsuff = '_pgi'
elif get_software_root('GCC'):
compsuff = '_gnu'
else:
raise EasyBuildError("Not using Intel/GCC/PGI, don't know compiler suffix for FFTW libraries.")
if get_software_root('icc') or get_software_root('intel-compilers'):
compsuff = '_intel'
# check for PGI first, since there's a GCC underneath PGI too...
elif get_software_root('PGI'):
compsuff = '_pgi'
elif get_software_root('GCC'):
compsuff = '_gnu'
else:
raise EasyBuildError("Not using Intel/GCC/PGI, don't know compiler suffix for FFTW libraries.")

precs = ['_double', '_single']
if ver < LooseVersion('11'):
Expand All @@ -399,23 +416,39 @@ def sanity_check_step(self):
bits = ['']
libs += ['libfftw%s%s%s.a' % x for x in itertools.product(fftw_cdft_vers, bits, pics)]

if ver >= LooseVersion('10.3'):
if self.cfg['m32']:
raise EasyBuildError("Sanity check for 32-bit not implemented yet for IMKL v%s (>= 10.3)", self.version)
if ver >= LooseVersion('10.3') and self.cfg['m32']:
raise EasyBuildError("Sanity check for 32-bit not implemented yet for IMKL v%s (>= 10.3)", self.version)

if ver >= LooseVersion('2021'):
basedir = os.path.join('mkl', self.version)

mkldirs = [
os.path.join(basedir, 'bin'),
os.path.join(basedir, 'lib', 'intel64'),
os.path.join(basedir, 'include'),
]
libs += [lib % {'suff': suff} for lib in extralibs for suff in ['lp64', 'ilp64']]

mklfiles = [
os.path.join(basedir, 'lib', 'intel64', 'libmkl_core.%s' % shlib_ext),
os.path.join(basedir, 'include', 'mkl.h'),
]
mklfiles.extend([os.path.join(basedir, 'lib', 'intel64', lib) for lib in libs])

elif ver >= LooseVersion('10.3'):
mkldirs = ['bin', 'mkl/bin', 'mkl/lib/intel64', 'mkl/include']
if ver < LooseVersion('11.3'):
mkldirs.append('mkl/bin/intel64')
libs += [lib % {'suff': suff} for lib in extralibs for suff in ['lp64', 'ilp64']]
mklfiles = ['mkl/lib/intel64/libmkl.%s' % shlib_ext, 'mkl/include/mkl.h'] + \
['mkl/lib/intel64/%s' % lib for lib in libs]
if ver >= LooseVersion('10.3.4') and ver < LooseVersion('11.1'):
mkldirs += ['compiler/lib/intel64']
else:
mkldirs = ['bin', 'mkl/bin', 'mkl/lib/intel64', 'mkl/include']
if ver < LooseVersion('11.3'):
mkldirs.append('mkl/bin/intel64')
libs += [lib % {'suff': suff} for lib in extralibs for suff in ['lp64', 'ilp64']]
mklfiles = ['mkl/lib/intel64/libmkl.%s' % shlib_ext, 'mkl/include/mkl.h'] + \
['mkl/lib/intel64/%s' % lib for lib in libs]
if ver >= LooseVersion('10.3.4') and ver < LooseVersion('11.1'):
mkldirs += ['compiler/lib/intel64']
if ver >= LooseVersion('2017.0.0'):
mkldirs += ['lib/intel64_lin']
else:
if ver >= LooseVersion('2017.0.0'):
mkldirs += ['lib/intel64_lin']
else:
mkldirs += ['lib/intel64']
mkldirs += ['lib/intel64']

else:
if self.cfg['m32']:
Expand Down