Compare commits
6 Commits
develop
...
hs/feature
Author | SHA1 | Date | |
---|---|---|---|
![]() |
01423a9bea | ||
![]() |
0ac63a3799 | ||
![]() |
2519ad20da | ||
![]() |
adfb6ee6aa | ||
![]() |
d17c118a78 | ||
![]() |
1a57df46f6 |
@ -33,6 +33,7 @@ packages:
|
|||||||
glu: [mesa-glu, openglu]
|
glu: [mesa-glu, openglu]
|
||||||
golang: [go, gcc]
|
golang: [go, gcc]
|
||||||
go-or-gccgo-bootstrap: [go-bootstrap, gcc]
|
go-or-gccgo-bootstrap: [go-bootstrap, gcc]
|
||||||
|
hip-lang: [llvm-amdgpu]
|
||||||
iconv: [libiconv]
|
iconv: [libiconv]
|
||||||
ipp: [intel-oneapi-ipp]
|
ipp: [intel-oneapi-ipp]
|
||||||
java: [openjdk, jdk]
|
java: [openjdk, jdk]
|
||||||
|
@ -199,10 +199,21 @@ def cxx(self) -> Optional[str]:
|
|||||||
return self.spec.extra_attributes["compilers"].get("cxx", None)
|
return self.spec.extra_attributes["compilers"].get("cxx", None)
|
||||||
return self._cxx_path()
|
return self._cxx_path()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hip(self) -> Optional[str]:
|
||||||
|
assert self.spec.concrete, "cannot retrieve HIP compiler, spec is not concrete"
|
||||||
|
if self.spec.external:
|
||||||
|
return self.spec.extra_attributes["compilers"].get("hip", None)
|
||||||
|
return self._hip_path()
|
||||||
|
|
||||||
def _cxx_path(self) -> Optional[str]:
|
def _cxx_path(self) -> Optional[str]:
|
||||||
"""Returns the path to the C++ compiler, if the package was installed by Spack"""
|
"""Returns the path to the C++ compiler, if the package was installed by Spack"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _hip_path(self) -> Optional[str]:
|
||||||
|
"""Returns the path to the HIP compiler, if the package was installed by Spack"""
|
||||||
|
return self._cxx_path()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fortran(self):
|
def fortran(self):
|
||||||
assert self.spec.concrete, "cannot retrieve Fortran compiler, spec is not concrete"
|
assert self.spec.concrete, "cannot retrieve Fortran compiler, spec is not concrete"
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import spack.variant
|
import spack.variant
|
||||||
from spack.directives import conflicts, depends_on, variant
|
from spack.directives import conflicts, depends_on, requires, variant
|
||||||
from spack.package_base import PackageBase
|
from spack.package_base import PackageBase
|
||||||
from spack.util.environment import EnvironmentModifications
|
from spack.util.environment import EnvironmentModifications
|
||||||
|
|
||||||
@ -140,9 +140,7 @@ class ROCmPackage(PackageBase):
|
|||||||
when="+rocm",
|
when="+rocm",
|
||||||
)
|
)
|
||||||
|
|
||||||
depends_on("llvm-amdgpu", type="build", when="+rocm")
|
depends_on("hip-lang", type="build", when="+rocm")
|
||||||
depends_on("hsa-rocr-dev", when="+rocm")
|
|
||||||
depends_on("hip +rocm", when="+rocm")
|
|
||||||
|
|
||||||
# need amd gpu type for rocm builds
|
# need amd gpu type for rocm builds
|
||||||
conflicts("amdgpu_target=none", when="+rocm")
|
conflicts("amdgpu_target=none", when="+rocm")
|
||||||
@ -183,14 +181,14 @@ def asan_on(self, env: EnvironmentModifications):
|
|||||||
|
|
||||||
# Add compiler minimum versions based on the first release where the
|
# Add compiler minimum versions based on the first release where the
|
||||||
# processor is included in llvm/lib/Support/TargetParser.cpp
|
# processor is included in llvm/lib/Support/TargetParser.cpp
|
||||||
depends_on("llvm-amdgpu@5.2.0:", when="amdgpu_target=gfx940")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.2.0:", when="amdgpu_target=gfx940")
|
||||||
depends_on("llvm-amdgpu@5.7.0:", when="amdgpu_target=gfx941")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.7.0:", when="amdgpu_target=gfx941")
|
||||||
depends_on("llvm-amdgpu@5.7.0:", when="amdgpu_target=gfx942")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.7.0:", when="amdgpu_target=gfx942")
|
||||||
depends_on("llvm-amdgpu@5.2.0:", when="amdgpu_target=gfx1036")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.2.0:", when="amdgpu_target=gfx1036")
|
||||||
depends_on("llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1100")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1100")
|
||||||
depends_on("llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1101")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1101")
|
||||||
depends_on("llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1102")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1102")
|
||||||
depends_on("llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1103")
|
requires("%[virtuals=hip-lang] llvm-amdgpu@5.3.0:", when="amdgpu_target=gfx1103")
|
||||||
|
|
||||||
# Compiler conflicts
|
# Compiler conflicts
|
||||||
|
|
||||||
|
@ -1421,6 +1421,7 @@ compiler(Compiler) :- compiler_supports_target(Compiler, _, _).
|
|||||||
language("c").
|
language("c").
|
||||||
language("cxx").
|
language("cxx").
|
||||||
language("fortran").
|
language("fortran").
|
||||||
|
language("hip-lang").
|
||||||
language_runtime("fortran-rt").
|
language_runtime("fortran-rt").
|
||||||
|
|
||||||
error(10, "Only external, or concrete, compilers are allowed for the {0} language", Language)
|
error(10, "Only external, or concrete, compilers are allowed for the {0} language", Language)
|
||||||
|
@ -216,16 +216,13 @@ def check_args_contents(cc, args, must_contain, must_not_contain):
|
|||||||
assert a not in cc_modified_args
|
assert a not in cc_modified_args
|
||||||
|
|
||||||
|
|
||||||
def check_env_var(executable, var, expected):
|
def check_wrapper_var(exe, *args, var, expected):
|
||||||
"""Check environment variables updated by the passed compiler wrapper
|
"""Check variables set by the compiler wrapper. This works by setting SPACK_TEST_COMMAND to
|
||||||
|
dump-var-<variable-to-debug>, which will print the variable and exit."""
|
||||||
This assumes that cc will print debug output when it's environment
|
executable = Executable(str(exe))
|
||||||
contains SPACK_TEST_COMMAND=dump-env-<variable-to-debug>
|
with set_env(SPACK_TEST_COMMAND=f"dump-var-{var}"):
|
||||||
"""
|
output = executable(*args, output=str).strip()
|
||||||
executable = Executable(str(executable))
|
assert f"{executable.path}: {var}: {expected}" == output
|
||||||
with set_env(SPACK_TEST_COMMAND="dump-env-" + var):
|
|
||||||
output = executable(*test_args, output=str).strip()
|
|
||||||
assert executable.path + ": " + var + ": " + expected == output
|
|
||||||
|
|
||||||
|
|
||||||
def dump_mode(cc, args):
|
def dump_mode(cc, args):
|
||||||
@ -749,11 +746,22 @@ def test_system_path_cleanup(wrapper_environment, wrapper_dir):
|
|||||||
"""
|
"""
|
||||||
cc = wrapper_dir / "cc"
|
cc = wrapper_dir / "cc"
|
||||||
system_path = "/bin:/usr/bin:/usr/local/bin"
|
system_path = "/bin:/usr/bin:/usr/local/bin"
|
||||||
with set_env(SPACK_COMPILER_WRAPPER_PATH=str(wrapper_dir), SPACK_CC="true"):
|
with set_env(SPACK_COMPILER_WRAPPER_PATH=str(wrapper_dir)):
|
||||||
with set_env(PATH=str(wrapper_dir) + ":" + system_path):
|
with set_env(PATH=str(wrapper_dir) + ":" + system_path):
|
||||||
check_env_var(cc, "PATH", system_path)
|
check_wrapper_var(cc, *test_args, var="PATH", expected=system_path)
|
||||||
with set_env(PATH=str(wrapper_dir) + "/:" + system_path):
|
with set_env(PATH=str(wrapper_dir) + "/:" + system_path):
|
||||||
check_env_var(cc, "PATH", system_path)
|
check_wrapper_var(cc, *test_args, var="PATH", expected=system_path)
|
||||||
|
|
||||||
|
|
||||||
|
def test_language_from_flags(wrapper_environment, wrapper_dir):
|
||||||
|
"""Tes that the compiler language mode is determined by -x/--language flags if present"""
|
||||||
|
cc = wrapper_dir / "cc"
|
||||||
|
|
||||||
|
for flag_value, lang in [("c", "CC"), ("c++", "CXX"), ("f77", "F77"), ("f95", "FC")]:
|
||||||
|
check_wrapper_var(cc, "-c", "file", "-x", flag_value, var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", f"-x{flag_value}", var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", f"--language={flag_value}", var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", "--language", flag_value, var="comp", expected=lang)
|
||||||
|
|
||||||
|
|
||||||
def test_ld_deps_partial(wrapper_environment, wrapper_dir):
|
def test_ld_deps_partial(wrapper_environment, wrapper_dir):
|
||||||
|
@ -68,6 +68,7 @@ def url_for_version(self, version):
|
|||||||
depends_on("zlib-api", type="link")
|
depends_on("zlib-api", type="link")
|
||||||
depends_on("z3", type="link")
|
depends_on("z3", type="link")
|
||||||
depends_on("ncurses", type="link")
|
depends_on("ncurses", type="link")
|
||||||
|
requires("%[virtuals=c,cxx] llvm-amdgpu")
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
"5.3.0",
|
"5.3.0",
|
||||||
@ -94,12 +95,9 @@ def url_for_version(self, version):
|
|||||||
"6.3.3",
|
"6.3.3",
|
||||||
"master",
|
"master",
|
||||||
]:
|
]:
|
||||||
# llvm libs are linked statically, so this *could* be a build dep
|
# in reality this should be a link type dep, but libLLVM is linked statically,
|
||||||
depends_on(f"llvm-amdgpu@{ver}", when=f"@{ver}")
|
# and just requiring llvm-amdgpu as a compiler suffices for now.
|
||||||
|
requires(f"%llvm-amdgpu@{ver}", when=f"@{ver}")
|
||||||
# aomp may not build rocm-device-libs as part of llvm-amdgpu, so make
|
|
||||||
# that a conditional dependency
|
|
||||||
depends_on(f"rocm-device-libs@{ver}", when=f"@{ver} ^llvm-amdgpu ~rocm-device-libs")
|
|
||||||
depends_on(f"rocm-cmake@{ver}", when=f"@{ver}", type="build")
|
depends_on(f"rocm-cmake@{ver}", when=f"@{ver}", type="build")
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
|
@ -178,9 +178,10 @@ execute() {
|
|||||||
unset IFS
|
unset IFS
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
dump-env-*)
|
dump-var-*)
|
||||||
var=${SPACK_TEST_COMMAND#dump-env-}
|
var=${SPACK_TEST_COMMAND#dump-var-}
|
||||||
eval "printf '%s\n' \"\$0: \$var: \$$var\""
|
eval "printf '%s\n' \"\$0: \$var: \$$var\""
|
||||||
|
exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
die "Unknown test command: '$SPACK_TEST_COMMAND'"
|
die "Unknown test command: '$SPACK_TEST_COMMAND'"
|
||||||
@ -296,9 +297,36 @@ fi
|
|||||||
# Note. SPACK_ALWAYS_XFLAGS are applied for all compiler invocations,
|
# Note. SPACK_ALWAYS_XFLAGS are applied for all compiler invocations,
|
||||||
# including version checks (SPACK_XFLAGS variants are not applied
|
# including version checks (SPACK_XFLAGS variants are not applied
|
||||||
# for version checks).
|
# for version checks).
|
||||||
command="${0##*/}"
|
command_from_argv0="${0##*/}"
|
||||||
|
command="$command_from_argv0"
|
||||||
comp="CC"
|
comp="CC"
|
||||||
vcheck_flags=""
|
vcheck_flags=""
|
||||||
|
|
||||||
|
_command_from_flags() {
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
arg="$1"
|
||||||
|
shift
|
||||||
|
case "$arg" in
|
||||||
|
-x|--language)
|
||||||
|
_lang="$1"
|
||||||
|
shift ;;
|
||||||
|
-x*)
|
||||||
|
_lang="${arg#-x}" ;;
|
||||||
|
--language=*)
|
||||||
|
_lang="${arg#--language=}" ;;
|
||||||
|
*) continue ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$_lang" in
|
||||||
|
c) command=cc ;;
|
||||||
|
c++|f77|f95|hip) command="$_lang" ;;
|
||||||
|
*) command="$command_from_argv0" ;; # drop unknown languages
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_command_from_flags "$@"
|
||||||
|
|
||||||
case "$command" in
|
case "$command" in
|
||||||
cpp)
|
cpp)
|
||||||
mode=cpp
|
mode=cpp
|
||||||
@ -337,6 +365,14 @@ case "$command" in
|
|||||||
debug_flags="-g"
|
debug_flags="-g"
|
||||||
vcheck_flags="${SPACK_ALWAYS_FFLAGS}"
|
vcheck_flags="${SPACK_ALWAYS_FFLAGS}"
|
||||||
;;
|
;;
|
||||||
|
hip)
|
||||||
|
command="$SPACK_HIPCXX"
|
||||||
|
language="HIP"
|
||||||
|
comp="HIPCXX"
|
||||||
|
lang_flags=HIP
|
||||||
|
debug_flags="-g"
|
||||||
|
vcheck_flags="${SPACK_ALWAYS_HIPCXXFLAGS}"
|
||||||
|
;;
|
||||||
ld|ld.gold|ld.lld)
|
ld|ld.gold|ld.lld)
|
||||||
mode=ld
|
mode=ld
|
||||||
if [ -z "$SPACK_CC_RPATH_ARG" ]; then
|
if [ -z "$SPACK_CC_RPATH_ARG" ]; then
|
||||||
|
@ -43,7 +43,7 @@ class CompilerWrapper(Package):
|
|||||||
if sys.platform != "win32":
|
if sys.platform != "win32":
|
||||||
version(
|
version(
|
||||||
"1.0",
|
"1.0",
|
||||||
sha256="c65a9d2b2d4eef67ab5cb0684d706bb9f005bb2be94f53d82683d7055bdb837c",
|
sha256="01db837305c8e181f142da3341c8438e0a7b4e03f0361df19d5784ab68b3c1f2",
|
||||||
expand=False,
|
expand=False,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -156,6 +156,9 @@ def setup_dependent_build_environment(self, env, dependent_spec):
|
|||||||
_var_list.append(("fortran", "fortran", "F77", "SPACK_F77"))
|
_var_list.append(("fortran", "fortran", "F77", "SPACK_F77"))
|
||||||
_var_list.append(("fortran", "fortran", "FC", "SPACK_FC"))
|
_var_list.append(("fortran", "fortran", "FC", "SPACK_FC"))
|
||||||
|
|
||||||
|
if dependent_spec.has_virtual_dependency("hip-lang"):
|
||||||
|
_var_list.append(("hip-lang", "hip", "HIPCXX", "SPACK_HIPCXX"))
|
||||||
|
|
||||||
# The package is not used as a compiler, so skip this setup
|
# The package is not used as a compiler, so skip this setup
|
||||||
if not _var_list:
|
if not _var_list:
|
||||||
return
|
return
|
||||||
|
@ -69,6 +69,8 @@ class Hip(CMakePackage):
|
|||||||
depends_on("libedit", type="build")
|
depends_on("libedit", type="build")
|
||||||
depends_on("perl@5.10:", type=("build", "run"))
|
depends_on("perl@5.10:", type=("build", "run"))
|
||||||
|
|
||||||
|
requires("%[virtuals=c,cxx] llvm-amdgpu")
|
||||||
|
|
||||||
test_requires_compiler = True
|
test_requires_compiler = True
|
||||||
|
|
||||||
with when("+rocm"):
|
with when("+rocm"):
|
||||||
@ -123,8 +125,8 @@ class Hip(CMakePackage):
|
|||||||
"6.3.3",
|
"6.3.3",
|
||||||
]:
|
]:
|
||||||
depends_on(f"hsa-rocr-dev@{ver}", when=f"@{ver}")
|
depends_on(f"hsa-rocr-dev@{ver}", when=f"@{ver}")
|
||||||
|
requires(f"%llvm-amdgpu@{ver}", when=f"@{ver}")
|
||||||
depends_on(f"comgr@{ver}", when=f"@{ver}")
|
depends_on(f"comgr@{ver}", when=f"@{ver}")
|
||||||
depends_on(f"llvm-amdgpu@{ver} +rocm-device-libs", when=f"@{ver}")
|
|
||||||
depends_on(f"rocminfo@{ver}", when=f"@{ver}")
|
depends_on(f"rocminfo@{ver}", when=f"@{ver}")
|
||||||
depends_on(f"roctracer-dev-api@{ver}", when=f"@{ver}")
|
depends_on(f"roctracer-dev-api@{ver}", when=f"@{ver}")
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@ class HipifyClang(CMakePackage):
|
|||||||
depends_on("cxx", type="build")
|
depends_on("cxx", type="build")
|
||||||
|
|
||||||
depends_on("cmake@3.5:", type="build")
|
depends_on("cmake@3.5:", type="build")
|
||||||
|
requires("%[virtuals=c,cxx] llvm-amdgpu")
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
"5.3.0",
|
"5.3.0",
|
||||||
"5.3.3",
|
"5.3.3",
|
||||||
@ -82,7 +84,7 @@ class HipifyClang(CMakePackage):
|
|||||||
"6.3.3",
|
"6.3.3",
|
||||||
"master",
|
"master",
|
||||||
]:
|
]:
|
||||||
depends_on(f"llvm-amdgpu@{ver}", when=f"@{ver}")
|
requires(f"%llvm-amdgpu@{ver}", when=f"@{ver}")
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
"5.5.0",
|
"5.5.0",
|
||||||
|
@ -64,6 +64,7 @@ class HsaRocrDev(CMakePackage):
|
|||||||
depends_on("numactl")
|
depends_on("numactl")
|
||||||
depends_on("pkgconfig")
|
depends_on("pkgconfig")
|
||||||
depends_on("libdrm", when="@6.3:")
|
depends_on("libdrm", when="@6.3:")
|
||||||
|
requires("%[virtuals=c,cxx] llvm-amdgpu")
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
"5.3.0",
|
"5.3.0",
|
||||||
@ -112,9 +113,7 @@ class HsaRocrDev(CMakePackage):
|
|||||||
"6.3.3",
|
"6.3.3",
|
||||||
"master",
|
"master",
|
||||||
]:
|
]:
|
||||||
depends_on(f"llvm-amdgpu@{ver}", when=f"@{ver}")
|
requires(f"%llvm-amdgpu@{ver}", when=f"@{ver}")
|
||||||
# allow standalone rocm-device-libs (useful for aomp)
|
|
||||||
depends_on(f"rocm-device-libs@{ver}", when=f"@{ver} ^llvm-amdgpu ~rocm-device-libs")
|
|
||||||
|
|
||||||
for ver in [
|
for ver in [
|
||||||
"5.5.0",
|
"5.5.0",
|
||||||
|
@ -23,6 +23,7 @@ class LlvmAmdgpu(CMakePackage, LlvmDetection, CompilerPackage):
|
|||||||
"c": "rocmcc/amdclang",
|
"c": "rocmcc/amdclang",
|
||||||
"cxx": "rocmcc/amdclang++",
|
"cxx": "rocmcc/amdclang++",
|
||||||
"fortran": "rocmcc/amdflang",
|
"fortran": "rocmcc/amdflang",
|
||||||
|
"hip-lang": "rocmcc/amdclang++",
|
||||||
}
|
}
|
||||||
|
|
||||||
stdcxx_libs = ("-lstdc++",)
|
stdcxx_libs = ("-lstdc++",)
|
||||||
@ -59,6 +60,7 @@ class LlvmAmdgpu(CMakePackage, LlvmDetection, CompilerPackage):
|
|||||||
version("5.3.0", sha256="4e3fcddb5b8ea8dcaa4417e0e31a9c2bbdc9e7d4ac3401635a636df32905c93e")
|
version("5.3.0", sha256="4e3fcddb5b8ea8dcaa4417e0e31a9c2bbdc9e7d4ac3401635a636df32905c93e")
|
||||||
|
|
||||||
provides("c", "cxx")
|
provides("c", "cxx")
|
||||||
|
provides("hip-lang")
|
||||||
provides("fortran")
|
provides("fortran")
|
||||||
|
|
||||||
variant(
|
variant(
|
||||||
@ -372,3 +374,20 @@ def _cxx_path(self):
|
|||||||
|
|
||||||
def _fortran_path(self):
|
def _fortran_path(self):
|
||||||
return os.path.join(self.spec.prefix.bin, "amdflang")
|
return os.path.join(self.spec.prefix.bin, "amdflang")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def runtime_constraints(cls, *, spec, pkg):
|
||||||
|
"""Callback function to inject runtime-related rules into the solver.
|
||||||
|
|
||||||
|
Rule-injection is obtained through method calls of the ``pkg`` argument.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
spec: spec that will inject runtime dependencies
|
||||||
|
pkg: object used to forward information to the solver
|
||||||
|
"""
|
||||||
|
pkg("*").depends_on(
|
||||||
|
"hip +rocm",
|
||||||
|
when="%[virtuals=hip-lang] llvm-amdgpu",
|
||||||
|
type="link",
|
||||||
|
description="If any package uses %llvm-amdgpu for hip-lang, it depends on hip",
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user