summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Cohn <robert.s.cohn@intel.com>2022-05-31 15:02:25 -0700
committerGitHub <noreply@github.com>2022-05-31 15:02:25 -0700
commitf3af38ba9b888b4b81a764912124796ec605b426 (patch)
tree3f294c46cada8a34c9f8a14c33d1fc3ee65db577
parentadc9f887eac78a81bb8189d603f4dc45ed3509c1 (diff)
downloadspack-f3af38ba9b888b4b81a764912124796ec605b426.tar.gz
spack-f3af38ba9b888b4b81a764912124796ec605b426.tar.bz2
spack-f3af38ba9b888b4b81a764912124796ec605b426.tar.xz
spack-f3af38ba9b888b4b81a764912124796ec605b426.zip
Fix module support for oneapi compilers (#28901)
Updates to improve Spack-generated modules for Intel oneAPI compilers: * intel-oneapi-compilers set CC etc. * Add a new package intel-oneapi-compilers-classic which can be used to generate a module which sets CC etc. to older compilers (e.g. icc) * lmod module logic now updated to treat the intel-oneapi-compilers* packages as compilers
-rw-r--r--lib/spack/spack/modules/lmod.py8
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py50
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py19
3 files changed, 77 insertions, 0 deletions
diff --git a/lib/spack/spack/modules/lmod.py b/lib/spack/spack/modules/lmod.py
index 97f79cfd28..a64c05e880 100644
--- a/lib/spack/spack/modules/lmod.py
+++ b/lib/spack/spack/modules/lmod.py
@@ -196,6 +196,14 @@ class LmodConfiguration(BaseConfiguration):
if self.spec.name == 'llvm-amdgpu':
provides['compiler'] = spack.spec.CompilerSpec(str(self.spec))
provides['compiler'].name = 'rocmcc'
+ # Special case for oneapi
+ if self.spec.name == 'intel-oneapi-compilers':
+ provides['compiler'] = spack.spec.CompilerSpec(str(self.spec))
+ provides['compiler'].name = 'oneapi'
+ # Special case for oneapi classic
+ if self.spec.name == 'intel-oneapi-compilers-classic':
+ provides['compiler'] = spack.spec.CompilerSpec(str(self.spec))
+ provides['compiler'].name = 'intel'
# All the other tokens in the hierarchy must be virtual dependencies
for x in self.hierarchy_tokens:
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py b/var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py
new file mode 100644
index 0000000000..635d79c705
--- /dev/null
+++ b/var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py
@@ -0,0 +1,50 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+@IntelOneApiPackage.update_description
+class IntelOneapiCompilersClassic(Package):
+ """Relies on intel-oneapi-compilers to install the compilers, and
+ configures modules for icc/icpc/ifort.
+
+ """
+
+ maintainers = ['rscohn2']
+
+ homepage = "https://software.intel.com/content/www/us/en/develop/tools/oneapi.html"
+
+ has_code = False
+
+ phases = []
+
+ for ver in ['2022.1.0',
+ '2022.0.2',
+ '2022.0.1',
+ '2021.4.0',
+ '2021.3.0',
+ '2021.2.0',
+ '2021.1.2']:
+ version(ver)
+ depends_on('intel-oneapi-compilers@' + ver, when='@' + ver, type='run')
+
+ def setup_run_environment(self, env):
+ """Adds environment variables to the generated module file.
+
+ These environment variables come from running:
+
+ .. code-block:: console
+
+ $ source {prefix}/{component}/{version}/env/vars.sh
+
+ and from setting CC/CXX/F77/FC
+ """
+ bin = join_path(self.spec['intel-oneapi-compilers'].prefix,
+ 'compile', 'linux', 'bin', 'intel64')
+ env.set('CC', join_path(bin, 'icc'))
+ env.set('CXX', join_path(bin, 'icpc'))
+ env.set('F77', join_path(bin, 'ifort'))
+ env.set('FC', join_path(bin, 'ifort'))
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py b/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
index aeb9482e4c..2d0807fd60 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
@@ -143,3 +143,22 @@ class IntelOneapiCompilers(IntelOneApiPackage):
# Try to patch all files, patchelf will do nothing if
# file should not be patched
subprocess.call(['patchelf', '--set-rpath', rpath, file])
+
+ def setup_run_environment(self, env):
+ """Adds environment variables to the generated module file.
+
+ These environment variables come from running:
+
+ .. code-block:: console
+
+ $ source {prefix}/{component}/{version}/env/vars.sh
+
+ and from setting CC/CXX/F77/FC
+ """
+ super(IntelOneapiCompilers, self).setup_run_environment(env)
+
+ bin = join_path(self.component_path, 'linux', 'bin')
+ env.set('CC', join_path(bin, 'icx'))
+ env.set('CXX', join_path(bin, 'icpx'))
+ env.set('F77', join_path(bin, 'ifx'))
+ env.set('FC', join_path(bin, 'ifx'))