From 452f03c4c4740cf41e6646116fb4222e6ec92653 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Tue, 6 Dec 2022 22:07:21 +0100 Subject: [PATCH 1/4] auto-enable use of oneAPI C/C++ compilers for intel-compilers >= 2022.2.0 --- .../toolchains/compiler/intel_compilers.py | 43 +++++++++++++++++-- .../modules/intel-compilers/2022.2.0 | 41 ++++++++++++++++++ test/framework/toolchain.py | 38 ++++++++++++++++ 3 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 test/framework/modules/intel-compilers/2022.2.0 diff --git a/easybuild/toolchains/compiler/intel_compilers.py b/easybuild/toolchains/compiler/intel_compilers.py index 231f0e2bc6..c0215dfde7 100644 --- a/easybuild/toolchains/compiler/intel_compilers.py +++ b/easybuild/toolchains/compiler/intel_compilers.py @@ -41,8 +41,15 @@ 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': (None, "Use oneAPI C compiler icx instead of classic Intel C compiler " + "(auto-enabled for Intel compilers version 2022.2.0, or newer)"), + 'oneapi_cxx': (None, "Use oneAPI C++ compiler icpx instead of classic Intel C++ compiler " + "(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.""" @@ -63,15 +70,45 @@ 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] + print(comp_ver) + if LooseVersion(comp_ver) >= LooseVersion('2022.2.0'): + if self.options.get('oneapi_c', None) is None: + self.options['oneapi_c'] = True + if self.options.get('oneapi_cxx', None) is None: + self.options['oneapi_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 'oenapi' and 'oneapi_*' are set, the latter are ignored + else: + if self.options.get('oneapi_c', False): + oneapi = True + self.COMPILER_CC = 'icx' + + if self.options.get('oneapi_cxx', False): + oneapi = True + 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'] diff --git a/test/framework/modules/intel-compilers/2022.2.0 b/test/framework/modules/intel-compilers/2022.2.0 new file mode 100644 index 0000000000..9baabe34ca --- /dev/null +++ b/test/framework/modules/intel-compilers/2022.2.0 @@ -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 diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 3103135a04..4923198b70 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -1448,6 +1448,44 @@ 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') + + 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') + + tc = self.get_toolchain('intel-compilers', version='2022.2.0') + tc.set_options({'oneapi_cxx': False, 'oneapi_fortran': True}) + tc.prepare() + self.assertEqual(os.getenv('CC'), 'icx') + self.assertEqual(os.getenv('CXX'), 'icpc') + self.assertEqual(os.getenv('F77'), 'ifx') + self.assertEqual(os.getenv('F90'), 'ifx') + self.assertEqual(os.getenv('FC'), 'ifx') + + tc = self.get_toolchain('intel-compilers', version='2022.2.0') + tc.set_options({'oneapi_c': False, 'oneapi_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') + def test_toolchain_verification(self): """Test verification of toolchain definition.""" tc = self.get_toolchain('foss', version='2018a') From 3a181e35acad3b4e74c4e4961b31b38c4fcd8eca Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 7 Dec 2022 18:26:01 +0100 Subject: [PATCH 2/4] fix test modules count --- test/framework/modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/modules.py b/test/framework/modules.py index 0b1013fdc9..eeb3d4732a 100644 --- a/test/framework/modules.py +++ b/test/framework/modules.py @@ -54,7 +54,7 @@ # number of modules included for testing purposes -TEST_MODULES_COUNT = 91 +TEST_MODULES_COUNT = 92 class ModulesTest(EnhancedTestCase): From eaabfa432b7bb0f287c454be64fded325f365182 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 8 Dec 2022 18:01:49 +0100 Subject: [PATCH 3/4] combine toolchain options 'oneapi_c' and 'oneapi_cxx' into 'oneapi_c_cxx' --- .../toolchains/compiler/intel_compilers.py | 20 +++++--------- test/framework/toolchain.py | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/easybuild/toolchains/compiler/intel_compilers.py b/easybuild/toolchains/compiler/intel_compilers.py index c0215dfde7..737022bb27 100644 --- a/easybuild/toolchains/compiler/intel_compilers.py +++ b/easybuild/toolchains/compiler/intel_compilers.py @@ -44,10 +44,8 @@ class IntelCompilers(IntelIccIfort): 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': (None, "Use oneAPI C compiler icx instead of classic Intel C compiler " - "(auto-enabled for Intel compilers version 2022.2.0, or newer)"), - 'oneapi_cxx': (None, "Use oneAPI C++ compiler icpx instead of classic Intel C++ compiler " - "(auto-enabled for Intel compilers version 2022.2.0, or newer)"), + '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"), }) @@ -74,12 +72,9 @@ def set_variables(self): # 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] - print(comp_ver) if LooseVersion(comp_ver) >= LooseVersion('2022.2.0'): - if self.options.get('oneapi_c', None) is None: - self.options['oneapi_c'] = True - if self.options.get('oneapi_cxx', None) is None: - self.options['oneapi_cxx'] = True + if self.options.get('oneapi_c_cxx', None) is None: + self.options['oneapi_c_cxx'] = True if self.options.get('oneapi', False): oneapi = True @@ -89,14 +84,11 @@ def set_variables(self): self.COMPILER_F90 = 'ifx' self.COMPILER_FC = 'ifx' - # if both 'oenapi' and 'oneapi_*' are set, the latter are ignored + # if both 'oneapi' and 'oneapi_*' are set, the latter are ignored else: - if self.options.get('oneapi_c', False): + if self.options.get('oneapi_c_cxx', False): oneapi = True self.COMPILER_CC = 'icx' - - if self.options.get('oneapi_cxx', False): - oneapi = True self.COMPILER_CXX = 'icpx' if self.options.get('oneapi_fortran', False): diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 4923198b70..bd889266cc 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -1469,16 +1469,25 @@ def test_intel_toolchain_oneapi(self): self.assertEqual(os.getenv('FC'), 'ifx') tc = self.get_toolchain('intel-compilers', version='2022.2.0') - tc.set_options({'oneapi_cxx': False, 'oneapi_fortran': True}) + tc.set_options({'oneapi_c_cxx': False, 'oneapi_fortran': True}) tc.prepare() - self.assertEqual(os.getenv('CC'), 'icx') + 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') - tc = self.get_toolchain('intel-compilers', version='2022.2.0') - tc.set_options({'oneapi_c': False, 'oneapi_cxx': False, 'oneapi_fortran': True}) + 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') + + 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') @@ -1486,6 +1495,15 @@ def test_intel_toolchain_oneapi(self): self.assertEqual(os.getenv('F90'), 'ifx') self.assertEqual(os.getenv('FC'), 'ifx') + 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') From e5e58d13b9949d211dcce0ba543e6415e64e3c24 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 8 Dec 2022 20:28:43 +0100 Subject: [PATCH 4/4] purge loaded modules in between test cases in test_intel_toolchain_oneapi --- test/framework/toolchain.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index bd889266cc..8d3356e0be 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -1459,6 +1459,7 @@ def test_intel_toolchain_oneapi(self): 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() @@ -1468,6 +1469,7 @@ def test_intel_toolchain_oneapi(self): 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() @@ -1477,6 +1479,7 @@ def test_intel_toolchain_oneapi(self): 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() @@ -1486,6 +1489,7 @@ def test_intel_toolchain_oneapi(self): 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() @@ -1495,6 +1499,7 @@ def test_intel_toolchain_oneapi(self): 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()