summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2022-11-07 21:50:16 -0800
committerGitHub <noreply@github.com>2022-11-07 21:50:16 -0800
commitc9561c5a0e962a7c17eb961d21bfd4f7728e656b (patch)
treecb58d0eb0c5430e8f7db88f07cd0e5ac4cabe156 /var
parentf099a68e65f3db5f33cb73b9ab9b798b37f4e4cf (diff)
downloadspack-c9561c5a0e962a7c17eb961d21bfd4f7728e656b.tar.gz
spack-c9561c5a0e962a7c17eb961d21bfd4f7728e656b.tar.bz2
spack-c9561c5a0e962a7c17eb961d21bfd4f7728e656b.tar.xz
spack-c9561c5a0e962a7c17eb961d21bfd4f7728e656b.zip
intel oneapi classic bootstrapping (#31285)
The `intel` compiler at versions > 20 is provided by the `intel-oneapi-compilers-classic` package (a thin wrapper around the `intel-oneapi-compilers` package), and the `oneapi` compiler is provided by the `intel-oneapi-compilers` package. Prior to this work, neither of these compilers could be bootstrapped by Spack as part of an install with `install_missing_compilers: True`. Changes made to make these two packages bootstrappable: 1. The `intel-oneapi-compilers-classic` package includes a bin directory and symlinks to the compiler executables, not just logical pointers in Spack. 2. Spack can look for bootstrapped compilers in directories other than `$prefix/bin`, defined on a per-package basis 3. `intel-oneapi-compilers` specifies a non-default search directory for the compiler executables. 4. The `spack.compilers` module now can make more advanced associations between packages and compilers, not just simple name translations 5. Spack support for lmod hierarchies accounts for differences between package names and the associated compiler names for `intel-oneapi-compilers/oneapi`, `intel-oneapi-compilers-classic/intel@20:`, `llvm+clang/clang`, and `llvm-amdgpu/rocmcc`. - [x] full end-to-end testing - [x] add unit tests
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin.mock/packages/intel-oneapi-compilers/package.py28
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py41
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py6
3 files changed, 71 insertions, 4 deletions
diff --git a/var/spack/repos/builtin.mock/packages/intel-oneapi-compilers/package.py b/var/spack/repos/builtin.mock/packages/intel-oneapi-compilers/package.py
new file mode 100644
index 0000000000..3ab49f1e1c
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/intel-oneapi-compilers/package.py
@@ -0,0 +1,28 @@
+# 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.package import *
+
+
+class IntelOneapiCompilers(Package):
+ """Simple compiler package."""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/oneapi-1.0.tar.gz"
+
+ version("1.0", "0123456789abcdef0123456789abcdef")
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("3.0", "def0123456789abcdef0123456789abc")
+
+ @property
+ def compiler_search_prefix(self):
+ return self.prefix.foo.bar.baz.bin
+
+ def install(self, spec, prefix):
+ # Create the minimal compiler that will fool `spack compiler find`
+ mkdirp(self.compiler_search_prefix)
+ with open(self.compiler_search_prefix.icx, "w") as f:
+ f.write('#!/bin/bash\necho "oneAPI DPC++ Compiler %s"' % str(spec.version))
+ set_executable(self.compiler_search_prefix.icx)
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
index 61b634fb9b..1b81e0ff63 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-compilers-classic/package.py
@@ -2,6 +2,9 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+from llnl.util.link_tree import LinkTree
from spack.package import *
@@ -19,8 +22,6 @@ class IntelOneapiCompilersClassic(Package):
has_code = False
- phases = []
-
# Versions before 2021 are in the `intel` package
# intel-oneapi versions before 2022 use intel@19.0.4
for ver, oneapi_ver in {
@@ -35,8 +36,19 @@ class IntelOneapiCompilersClassic(Package):
version(ver)
depends_on("intel-oneapi-compilers@" + oneapi_ver, when="@" + ver, type="run")
+ @property
+ def oneapi_compiler_prefix(self):
+ oneapi_version = self.spec["intel-oneapi-compilers"].version
+ return self.spec["intel-oneapi-compilers"].prefix.compiler.join(str(oneapi_version))
+
def setup_run_environment(self, env):
- """Adds environment variables to the generated module file."""
+ """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
+ """
oneapi_pkg = self.spec["intel-oneapi-compilers"].package
oneapi_pkg.setup_run_environment(env)
@@ -46,3 +58,26 @@ class IntelOneapiCompilersClassic(Package):
env.set("CXX", bin_prefix.icpc)
env.set("F77", bin_prefix.ifort)
env.set("FC", bin_prefix.ifort)
+
+ def install(self, spec, prefix):
+ # If we symlink top-level directories directly, files won't show up in views
+ # Create real dirs and symlink files instead
+ self.symlink_dir(self.oneapi_compiler_prefix.linux.bin.intel64, prefix.bin)
+ self.symlink_dir(self.oneapi_compiler_prefix.linux.lib, prefix.lib)
+ self.symlink_dir(self.oneapi_compiler_prefix.linux.include, prefix.include)
+ self.symlink_dir(self.oneapi_compiler_prefix.linux.compiler, prefix.compiler)
+ self.symlink_dir(self.oneapi_compiler_prefix.documentation.en.man, prefix.man)
+
+ def symlink_dir(self, src, dest):
+ # Create a real directory at dest
+ mkdirp(dest)
+
+ # Symlink all files in src to dest keeping directories as dirs
+ for entry in os.listdir(src):
+ src_path = os.path.join(src, entry)
+ dest_path = os.path.join(dest, entry)
+ if os.path.isdir(src_path) and os.access(src_path, os.X_OK):
+ link_tree = LinkTree(src_path)
+ link_tree.merge(dest_path)
+ else:
+ os.symlink(src_path, dest_path)
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 c596074289..4869fc63d8 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
@@ -149,6 +149,10 @@ class IntelOneapiCompilers(IntelOneApiPackage):
def component_dir(self):
return "compiler"
+ @property
+ def compiler_search_prefix(self):
+ return self.prefix.compiler.join(str(self.version)).linux.bin
+
def setup_run_environment(self, env):
"""Adds environment variables to the generated module file.
@@ -169,7 +173,7 @@ class IntelOneapiCompilers(IntelOneApiPackage):
def install(self, spec, prefix):
# Copy instead of install to speed up debugging
- # install_tree('/opt/intel/oneapi/compiler', self.prefix)
+ # install_tree("/opt/intel/oneapi/compiler", self.prefix)
# install cpp
super(IntelOneapiCompilers, self).install(spec, prefix)