Cray support: use linux platform for newer craype versions (#29392)

Newer versions of the CrayPE for EX systems have standalone compiler executables for CCE and compiler wrappers for Cray MPICH. With those, we can treat the cray systems as part of the linux platform rather than having a separate cray platform.

This PR:
- [x] Changes cray platform detection to ignore EX systems with Craype version 21.10 or later
- [x] Changes the cce compiler to be detectable via paths
- [x] Changes the spack compiler wrapper to understand the executable names for the standalone cce compiler (`craycc`, `crayCC`, `crayftn`).
This commit is contained in:
Greg Becker
2022-11-04 14:52:11 -07:00
committed by GitHub
parent a88c74dc17
commit 53fbaa5dcd
14 changed files with 121 additions and 46 deletions

8
lib/spack/env/cc vendored
View File

@@ -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"

View File

@@ -0,0 +1 @@
../../cc

1
lib/spack/env/cce/craycc vendored Symbolic link
View File

@@ -0,0 +1 @@
../cc

1
lib/spack/env/cce/crayftn vendored Symbolic link
View File

@@ -0,0 +1 @@
../cc

View File

@@ -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 @@
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

View File

@@ -12,6 +12,7 @@
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 @@
"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)
@@ -109,19 +113,48 @@ def setup_platform_environment(self, pkg, env):
if os.environ.get("CRAY_LD_LIBRARY_PATH"):
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.
Detect whether this system requires CrayPE module support.
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.
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):

View File

@@ -8,6 +8,8 @@
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