summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc8
l---------lib/spack/env/cce/case-insensitive/crayCC1
l---------lib/spack/env/cce/craycc1
l---------lib/spack/env/cce/crayftn1
-rw-r--r--lib/spack/spack/compilers/cce.py47
-rw-r--r--lib/spack/spack/platforms/cray.py51
-rw-r--r--lib/spack/spack/test/architecture.py26
7 files changed, 105 insertions, 30 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index bef7209bfa..ffdddfc0df 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -241,28 +241,28 @@ case "$command" in
mode=cpp
debug_flags="-g"
;;
- cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang|cl.exe)
+ cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang|cl.exe|craycc)
command="$SPACK_CC"
language="C"
comp="CC"
lang_flags=C
debug_flags="-g"
;;
- c++|CC|g++|clang++|armclang++|icpc|icpx|dpcpp|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++)
+ c++|CC|g++|clang++|armclang++|icpc|icpx|dpcpp|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++|crayCC)
command="$SPACK_CXX"
language="C++"
comp="CXX"
lang_flags=CXX
debug_flags="-g"
;;
- ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang)
+ ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang|crayftn)
command="$SPACK_FC"
language="Fortran 90"
comp="FC"
lang_flags=F
debug_flags="-g"
;;
- f77|xlf|xlf_r|pgf77|amdflang)
+ f77|xlf|xlf_r|pgf77)
command="$SPACK_F77"
language="Fortran 77"
comp="F77"
diff --git a/lib/spack/env/cce/case-insensitive/crayCC b/lib/spack/env/cce/case-insensitive/crayCC
new file mode 120000
index 0000000000..e2deb67f3b
--- /dev/null
+++ b/lib/spack/env/cce/case-insensitive/crayCC
@@ -0,0 +1 @@
+../../cc \ No newline at end of file
diff --git a/lib/spack/env/cce/craycc b/lib/spack/env/cce/craycc
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/cce/craycc
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/cce/crayftn b/lib/spack/env/cce/crayftn
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/cce/crayftn
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/spack/compilers/cce.py b/lib/spack/spack/compilers/cce.py
index d572a31ff4..3ecbcdc3d6 100644
--- a/lib/spack/spack/compilers/cce.py
+++ b/lib/spack/spack/compilers/cce.py
@@ -2,7 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import os
from spack.compiler import Compiler, UnsupportedCompilerFlag
@@ -12,17 +11,25 @@ from spack.version import ver
class Cce(Compiler):
"""Cray compiler environment compiler."""
+ def __init__(self, *args, **kwargs):
+ super(Cce, self).__init__(*args, **kwargs)
+ # For old cray compilers on module based systems we replace
+ # ``version_argument`` with the old value. Cannot be a property
+ # as the new value is used in classmethods for path-based detection
+ if not self.is_clang_based:
+ self.version_argument = "-V"
+
# Subclasses use possible names of C compiler
- cc_names = ["cc"]
+ cc_names = ["craycc", "cc"]
# Subclasses use possible names of C++ compiler
- cxx_names = ["CC"]
+ cxx_names = ["crayCC", "CC"]
# Subclasses use possible names of Fortran 77 compiler
- f77_names = ["ftn"]
+ f77_names = ["crayftn", "ftn"]
# Subclasses use possible names of Fortran 90 compiler
- fc_names = ["ftn"]
+ fc_names = ["crayftn", "ftn"]
# MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes.
suffixes = [r"-mp-\d\.\d"]
@@ -30,24 +37,30 @@ class Cce(Compiler):
PrgEnv = "PrgEnv-cray"
PrgEnv_compiler = "cce"
- link_paths = {
- "cc": os.path.join("cce", "cc"),
- "cxx": os.path.join("cce", "case-insensitive", "CC"),
- "f77": os.path.join("cce", "ftn"),
- "fc": os.path.join("cce", "ftn"),
- }
+ @property
+ def link_paths(self):
+ if self.PrgEnv in self.modules:
+ # Old module-based interface to cray compilers
+ return {
+ "cc": os.path.join("cce", "cc"),
+ "cxx": os.path.join("case-insensitive", "CC"),
+ "f77": os.path.join("cce", "ftn"),
+ "fc": os.path.join("cce", "ftn"),
+ }
+
+ return {
+ "cc": os.path.join("cce", "craycc"),
+ "cxx": os.path.join("cce", "case-insensitive", "crayCC"),
+ "f77": os.path.join("cce", "crayftn"),
+ "fc": os.path.join("cce", "crayftn"),
+ }
@property
def is_clang_based(self):
version = self._real_version or self.version
return version >= ver("9.0") and "classic" not in str(version)
- @property
- def version_argument(self):
- if self.is_clang_based:
- return "--version"
- return "-V"
-
+ version_argument = "--version"
version_regex = r"[Vv]ersion.*?(\d+(\.\d+)+)"
@property
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 8f87740e4c..dadf114d90 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -12,6 +12,7 @@ import archspec.cpu
import llnl.util.tty as tty
import spack.target
+import spack.version
from spack.operating_systems.cray_backend import CrayBackend
from spack.operating_systems.cray_frontend import CrayFrontend
from spack.paths import build_env_path
@@ -31,6 +32,9 @@ _craype_name_to_target_name = {
"abudhabi": "piledriver",
}
+_ex_craype_dir = "/opt/cray/pe/cpe"
+_xc_craype_dir = "/opt/cray/pe/cdt"
+
def _target_name_from_craype_target_name(name):
return _craype_name_to_target_name.get(name, name)
@@ -110,18 +114,47 @@ class Cray(Platform):
env.prepend_path("LD_LIBRARY_PATH", os.environ["CRAY_LD_LIBRARY_PATH"])
@classmethod
+ def craype_type_and_version(cls):
+ if os.path.isdir(_ex_craype_dir):
+ craype_dir = _ex_craype_dir
+ craype_type = "EX"
+ elif os.path.isdir(_xc_craype_dir):
+ craype_dir = _xc_craype_dir
+ craype_type = "XC"
+ else:
+ return (None, None)
+
+ # Take the default version from known symlink path
+ default_path = os.path.join(craype_dir, "default")
+ if os.path.islink(default_path):
+ version = spack.version.Version(os.readlink(default_path))
+ return (craype_type, version)
+
+ # If no default version, sort available versions and return latest
+ versions_available = [spack.version.Version(v) for v in os.listdir(craype_dir)]
+ versions_available.sort(reverse=True)
+ return (craype_type, versions_available[0])
+
+ @classmethod
def detect(cls):
"""
- Detect whether this system is a Cray machine.
-
- We detect the Cray platform based on the availability through `module`
- of the Cray programming environment. If this environment is available,
- we can use it to find compilers, target modules, etc. If the Cray
- programming environment is not available via modules, then we will
- treat it as a standard linux system, as the Cray compiler wrappers
- and other components of the Cray programming environment are
- irrelevant without module support.
+ Detect whether this system requires CrayPE module support.
+
+ Systems with newer CrayPE (21.10 for EX systems, future work for CS and
+ XC systems) have compilers and MPI wrappers that can be used directly
+ by path. These systems are considered ``linux`` platforms.
+
+ For systems running an older CrayPE, we detect the Cray platform based
+ on the availability through `module` of the Cray programming
+ environment. If this environment is available, we can use it to find
+ compilers, target modules, etc. If the Cray programming environment is
+ not available via modules, then we will treat it as a standard linux
+ system, as the Cray compiler wrappers and other components of the Cray
+ programming environment are irrelevant without module support.
"""
+ craype_type, craype_version = cls.craype_type_and_version()
+ if craype_type == "EX" and craype_version >= spack.version.Version("21.10"):
+ return False
return "opt/cray" in os.environ.get("MODULEPATH", "")
def _default_target_from_env(self):
diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py
index 746be0c8be..92914be685 100644
--- a/lib/spack/spack/test/architecture.py
+++ b/lib/spack/spack/test/architecture.py
@@ -8,6 +8,8 @@ import sys
import pytest
+import llnl.util.filesystem as fs
+
import spack.concretize
import spack.operating_systems
import spack.platforms
@@ -214,3 +216,27 @@ def test_concretize_target_ranges(root_target_range, dep_target_range, result, m
spec.concretize()
assert str(spec).count("arch=test-debian6-%s" % result) == 2
+
+
+@pytest.mark.parametrize(
+ "versions,default,expected",
+ [
+ (["21.11", "21.9"], "21.11", False),
+ (["21.11", "21.9"], "21.9", True),
+ (["21.11", "21.9"], None, False),
+ ],
+)
+def test_cray_platform_detection(versions, default, expected, tmpdir, monkeypatch, working_env):
+ ex_path = str(tmpdir.join("fake_craype_dir"))
+ fs.mkdirp(ex_path)
+
+ with fs.working_dir(ex_path):
+ for version in versions:
+ fs.touch(version)
+ if default:
+ os.symlink(default, "default")
+
+ monkeypatch.setattr(spack.platforms.cray, "_ex_craype_dir", ex_path)
+ os.environ["MODULEPATH"] = "/opt/cray/pe"
+
+ assert spack.platforms.cray.Cray.detect() == expected