From f1fa1a15805cbf7c5273f43516b3389bada4ad24 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 21 Dec 2022 12:41:52 +0100 Subject: [PATCH 1/4] use -march=x86-64 -mtune=generic instead of -xSSE2 when using Intel oneAPI compilers --- easybuild/toolchains/compiler/intel_compilers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/easybuild/toolchains/compiler/intel_compilers.py b/easybuild/toolchains/compiler/intel_compilers.py index 737022bb27..660f607679 100644 --- a/easybuild/toolchains/compiler/intel_compilers.py +++ b/easybuild/toolchains/compiler/intel_compilers.py @@ -31,6 +31,7 @@ from distutils.version import LooseVersion +import easybuild.tools.systemtools as systemtools from easybuild.toolchains.compiler.inteliccifort import IntelIccIfort from easybuild.tools.toolchain.compiler import Compiler @@ -109,5 +110,12 @@ def set_variables(self): # recommended in porting guide self.options.options_map['openmp'] = ['fiopenmp'] + # -xSSE2 is not supported by Intel oneAPI compilers, + # so use -march=x86-64 -mtune=generic when using optarch=GENERIC + self.COMPILER_GENERIC_OPTION = { + (systemtools.X86_64, systemtools.AMD): 'march=x86-64 -mtune=generic', + (systemtools.X86_64, systemtools.INTEL): 'march=x86-64 -mtune=generic', + } + # skip IntelIccIfort.set_variables (no longer relevant for recent versions) Compiler.set_variables(self) From 621f20777376a191b1b9f16c2f709cd5f438a1b2 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 21 Dec 2022 18:13:44 +0100 Subject: [PATCH 2/4] make test_optarch_generic aware of change in compiler options for oneAPI Intel compilers --- test/framework/toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 8d3356e0be..2605ef50f2 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -709,7 +709,7 @@ def test_optarch_generic(self): tcs = { 'gompi': ('2018a', "-march=x86-64 -mtune=generic"), 'iccifort': ('2018.1.163', "-xSSE2 -ftz -fp-speculation=safe -fp-model source"), - 'intel-compilers': ('2021.4.0', "-xSSE2 -fp-speculation=safe -fp-model precise"), + 'intel-compilers': ('2021.4.0', "-march=x86-64 -mtune=generic -fp-speculation=safe -fp-model precise"), } for tcopt_optarch in [False, True]: for tcname in tcs: From 848293daaed1525243fa3b15052bcaa01950059a Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 Dec 2022 16:47:48 +0100 Subject: [PATCH 3/4] test both with old/recent version of intel-compilers and with/without oneapi toolchain option in test_optarch_generic --- test/framework/toolchain.py | 42 +++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 6085f6f205..a26ff0c86f 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -702,29 +702,49 @@ def test_override_optarch(self): def test_optarch_generic(self): """Test whether --optarch=GENERIC works as intended.""" + + intel_generic_flags_classic = "-xSSE2 -ftz -fp-speculation=safe -fp-model source" + intel_generic_flags_oneapi_old = "-march=x86-64 -mtune=generic -fp-speculation=safe -fp-model precise" + intel_generic_flags_oneapi_new = "-march=x86-64 -mtune=generic -ftz -fp-speculation=safe -fp-model precise" + for generic in [False, True]: if generic: init_config(build_options={'optarch': 'GENERIC', 'silent': True}) flag_vars = ['CFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'F90FLAGS'] tcs = { - 'gompi': ('2018a', "-march=x86-64 -mtune=generic"), - 'iccifort': ('2018.1.163', "-xSSE2 -ftz -fp-speculation=safe -fp-model source"), - 'intel-compilers': ('2021.4.0', "-march=x86-64 -mtune=generic -fp-speculation=safe -fp-model precise"), + 'gompi': ('2018a', "-march=x86-64 -mtune=generic", {}), + 'iccifort': ('2018.1.163', "-xSSE2 -ftz -fp-speculation=safe -fp-model source", {}), + # check generic compiler flags for old versions of intel-compilers with/without opting in to oneapi + 'intel-compilers@old-default': ('2021.4.0', intel_generic_flags_classic, {}), + 'intel-compilers@old-oneapi-false': ('2021.4.0', intel_generic_flags_classic, {'oneapi': False}), + 'intel-compilers@old-oneapi-true': ('2021.4.0', intel_generic_flags_oneapi_old, {'oneapi': True}), + # check generic compiler flags for recent versions of intel-compilers with/without opting in to oneapi + 'intel-compilers@new-default': ('2022.2.0', intel_generic_flags_oneapi_new, {}), + 'intel-compilers@new-oneapi-true': ('2022.2.0', intel_generic_flags_oneapi_new, {'oneapi': True}), + 'intel-compilers@new-oneapi-false': ('2022.2.0', intel_generic_flags_classic, {'oneapi': False}), } for tcopt_optarch in [False, True]: - for tcname in tcs: - tcversion, generic_flags = tcs[tcname] + for key in tcs: + tcname = key.split('@')[0] + tcversion, generic_flags, custom_tcopts = tcs[key] tc = self.get_toolchain(tcname, version=tcversion) - if tcname == 'intel-compilers': - tc.set_options({'optarch': tcopt_optarch, 'oneapi': True}) - else: - tc.set_options({'optarch': tcopt_optarch}) + + tcopts = {'optarch': tcopt_optarch} + tcopts.update(custom_tcopts) + tc.set_options(tcopts) + tc.prepare() for var in flag_vars: + val = tc.get_variable(var) + tup = (key, tcversion, tcopts, generic_flags, val) if generic: - self.assertTrue(generic_flags in tc.get_variable(var)) + error_msg = "(%s, %s, %s) '%s' flags should be found in: '%s'" + self.assertTrue(generic_flags in val, error_msg % tup) else: - self.assertFalse(generic_flags in tc.get_variable(var)) + error_msg = "(%s, %s, %s) '%s' flags should not be found in: '%s'" + self.assertFalse(generic_flags in val, error_msg % tup) + + modules.modules_tool().purge() def test_optarch_aarch64_heuristic(self): """Test whether AArch64 pre-GCC-6 optimal architecture flag heuristic works.""" From 63099bf88b7fd40130ed45797ae4296d16c2a88d Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 Dec 2022 16:47:52 +0100 Subject: [PATCH 4/4] only take into account oneapi_c_cxx/oneapi_fortran toolchain options if oneapi toolchain option is not set to True or False --- easybuild/toolchains/compiler/intel_compilers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/easybuild/toolchains/compiler/intel_compilers.py b/easybuild/toolchains/compiler/intel_compilers.py index bb12633cd6..50950f0552 100644 --- a/easybuild/toolchains/compiler/intel_compilers.py +++ b/easybuild/toolchains/compiler/intel_compilers.py @@ -43,7 +43,7 @@ class IntelCompilers(IntelIccIfort): COMPILER_MODULE_NAME = ['intel-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': (None, "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"), @@ -76,7 +76,8 @@ def set_variables(self): if self.options.get('oneapi_c_cxx', None) is None: self.options['oneapi_c_cxx'] = True - if self.options.get('oneapi', False): + oneapi_tcopt = self.options.get('oneapi') + if oneapi_tcopt: oneapi = True self.COMPILER_CXX = 'icpx' self.COMPILER_CC = 'icx' @@ -85,7 +86,7 @@ def set_variables(self): self.COMPILER_FC = 'ifx' # if both 'oneapi' and 'oneapi_*' are set, the latter are ignored - else: + elif oneapi_tcopt is None: if self.options.get('oneapi_c_cxx', False): oneapi = True self.COMPILER_CC = 'icx'