Skip to content

Commit

Permalink
Merge pull request #4135 from boegel/oneapi_auto_enable
Browse files Browse the repository at this point in the history
auto-enable use of oneAPI C/C++ compilers for intel-compilers >= 2022.2.0
  • Loading branch information
branfosj authored Dec 8, 2022
2 parents a5a188a + e5e58d1 commit 0d89c85
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 4 deletions.
35 changes: 32 additions & 3 deletions easybuild/toolchains/compiler/intel_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class IntelCompilers(IntelIccIfort):
"""

COMPILER_MODULE_NAME = ['intel-compilers']
COMPILER_UNIQUE_OPTS = dict(IntelIccIfort.COMPILER_UNIQUE_OPTS,
oneapi=(False, "Use oneAPI compilers icx/icpx/ifx instead of classic compilers"))
COMPILER_UNIQUE_OPTS = dict(IntelIccIfort.COMPILER_UNIQUE_OPTS)
COMPILER_UNIQUE_OPTS.update({
'oneapi': (False, "Use oneAPI compilers icx/icpx/ifx instead of classic compilers"),
'oneapi_c_cxx': (None, "Use oneAPI C/C++ compilers icx/icpx instead of classic Intel C/C++ compilers "
"(auto-enabled for Intel compilers version 2022.2.0, or newer)"),
'oneapi_fortran': (False, "Use oneAPI Fortran compiler ifx instead of classic Intel Fortran compiler"),
})

def _set_compiler_vars(self):
"""Intel compilers-specific adjustments after setting compiler variables."""
Expand All @@ -63,15 +68,39 @@ def _set_compiler_vars(self):
def set_variables(self):
"""Set the variables."""

oneapi = False

# auto-enable use of oneAPI C/C++ compilers for sufficiently recent versions of Intel compilers
comp_ver = self.get_software_version(self.COMPILER_MODULE_NAME)[0]
if LooseVersion(comp_ver) >= LooseVersion('2022.2.0'):
if self.options.get('oneapi_c_cxx', None) is None:
self.options['oneapi_c_cxx'] = True

if self.options.get('oneapi', False):
oneapi = True
self.COMPILER_CXX = 'icpx'
self.COMPILER_CC = 'icx'
self.COMPILER_F77 = 'ifx'
self.COMPILER_F90 = 'ifx'
self.COMPILER_FC = 'ifx'

# if both 'oneapi' and 'oneapi_*' are set, the latter are ignored
else:
if self.options.get('oneapi_c_cxx', False):
oneapi = True
self.COMPILER_CC = 'icx'
self.COMPILER_CXX = 'icpx'

if self.options.get('oneapi_fortran', False):
oneapi = True
self.COMPILER_F77 = 'ifx'
self.COMPILER_F90 = 'ifx'
self.COMPILER_FC = 'ifx'

if oneapi:
# fp-model source is not supported by icx but is equivalent to precise
self.options.options_map['defaultprec'] = ['fp-speculation=safe', 'fp-model precise']
if LooseVersion(self.get_software_version(self.COMPILER_MODULE_NAME)[0]) >= LooseVersion('2022'):
if LooseVersion(comp_ver) >= LooseVersion('2022'):
self.options.options_map['defaultprec'].insert(0, 'ftz')
# icx doesn't like -fp-model fast=1; fp-model fast is equivalent
self.options.options_map['loose'] = ['fp-model fast']
Expand Down
2 changes: 1 addition & 1 deletion test/framework/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@


# number of modules included for testing purposes
TEST_MODULES_COUNT = 91
TEST_MODULES_COUNT = 92


class ModulesTest(EnhancedTestCase):
Expand Down
41 changes: 41 additions & 0 deletions test/framework/modules/intel-compilers/2022.2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#%Module
proc ModulesHelp { } {
puts stderr {

Description
===========
Intel C, C++ & Fortran compilers (classic and oneAPI)


More information
================
- Homepage: https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit.html
}
}

module-whatis {Description: Intel C, C++ & Fortran compilers (classic and oneAPI)}
module-whatis {Homepage: https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit.html}
module-whatis {URL: https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit.html}

set root /tmp/intel-compilers/2022.2.0

conflict intel-compilers

prepend-path CPATH $root/tbb/2022.2.0/include
prepend-path LD_LIBRARY_PATH $root/compiler/2022.2.0/linux/lib
prepend-path LD_LIBRARY_PATH $root/compiler/2022.2.0/linux/lib/x64
prepend-path LD_LIBRARY_PATH $root/compiler/2022.2.0/linux/compiler/lib/intel64_lin
prepend-path LD_LIBRARY_PATH $root/tbb/2022.2.0/lib/intel64/gcc4.8
prepend-path LIBRARY_PATH $root/compiler/2022.2.0/linux/lib
prepend-path LIBRARY_PATH $root/compiler/2022.2.0/linux/lib/x64
prepend-path LIBRARY_PATH $root/compiler/2022.2.0/linux/compiler/lib/intel64_lin
prepend-path LIBRARY_PATH $root/tbb/2022.2.0/lib/intel64/gcc4.8
prepend-path OCL_ICD_FILENAMES $root/compiler/2022.2.0/linux/lib/x64/libintelocl.so
prepend-path PATH $root/compiler/2022.2.0/linux/bin
prepend-path PATH $root/compiler/2022.2.0/linux/bin/intel64
prepend-path TBBROOT $root/tbb/2022.2.0
setenv EBROOTINTELMINCOMPILERS "$root"
setenv EBVERSIONINTELMINCOMPILERS "2022.2.0"
setenv EBDEVELINTELMINCOMPILERS "$root/easybuild/Core-intel-compilers-2022.2.0-easybuild-devel"

# Built with EasyBuild version 4.5.0dev
61 changes: 61 additions & 0 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,67 @@ def test_intel_toolchain_oneapi(self):
self.assertEqual(os.getenv('MPIF90'), 'mpiifort')
self.assertEqual(os.getenv('MPIFC'), 'mpiifort')

self.modtool.purge()
tc = self.get_toolchain('intel-compilers', version='2022.2.0')
tc.prepare()

# by default (for version >= 2022.2.0): oneAPI C/C++ compiler + classic Fortran compiler
self.assertEqual(os.getenv('CC'), 'icx')
self.assertEqual(os.getenv('CXX'), 'icpx')
self.assertEqual(os.getenv('F77'), 'ifort')
self.assertEqual(os.getenv('F90'), 'ifort')
self.assertEqual(os.getenv('FC'), 'ifort')

self.modtool.purge()
tc = self.get_toolchain('intel-compilers', version='2022.2.0')
tc.set_options({'oneapi_fortran': True})
tc.prepare()
self.assertEqual(os.getenv('CC'), 'icx')
self.assertEqual(os.getenv('CXX'), 'icpx')
self.assertEqual(os.getenv('F77'), 'ifx')
self.assertEqual(os.getenv('F90'), 'ifx')
self.assertEqual(os.getenv('FC'), 'ifx')

self.modtool.purge()
tc = self.get_toolchain('intel-compilers', version='2022.2.0')
tc.set_options({'oneapi_c_cxx': False, 'oneapi_fortran': True})
tc.prepare()
self.assertEqual(os.getenv('CC'), 'icc')
self.assertEqual(os.getenv('CXX'), 'icpc')
self.assertEqual(os.getenv('F77'), 'ifx')
self.assertEqual(os.getenv('F90'), 'ifx')
self.assertEqual(os.getenv('FC'), 'ifx')

self.modtool.purge()
tc = self.get_toolchain('intel', version='2021b')
tc.set_options({'oneapi_c_cxx': True})
tc.prepare()
self.assertEqual(os.getenv('CC'), 'icx')
self.assertEqual(os.getenv('CXX'), 'icpx')
self.assertEqual(os.getenv('F77'), 'ifort')
self.assertEqual(os.getenv('F90'), 'ifort')
self.assertEqual(os.getenv('FC'), 'ifort')

self.modtool.purge()
tc = self.get_toolchain('intel', version='2021b')
tc.set_options({'oneapi_fortran': True})
tc.prepare()
self.assertEqual(os.getenv('CC'), 'icc')
self.assertEqual(os.getenv('CXX'), 'icpc')
self.assertEqual(os.getenv('F77'), 'ifx')
self.assertEqual(os.getenv('F90'), 'ifx')
self.assertEqual(os.getenv('FC'), 'ifx')

self.modtool.purge()
tc = self.get_toolchain('intel', version='2021b')
tc.set_options({'oneapi_c_cxx': True, 'oneapi_fortran': True})
tc.prepare()
self.assertEqual(os.getenv('CC'), 'icx')
self.assertEqual(os.getenv('CXX'), 'icpx')
self.assertEqual(os.getenv('F77'), 'ifx')
self.assertEqual(os.getenv('F90'), 'ifx')
self.assertEqual(os.getenv('FC'), 'ifx')

def test_toolchain_verification(self):
"""Test verification of toolchain definition."""
tc = self.get_toolchain('foss', version='2018a')
Expand Down

0 comments on commit 0d89c85

Please sign in to comment.