hip: add cuda variant (#33872)
This commit is contained in:
@@ -138,7 +138,7 @@ class ROCmPackage(PackageBase):
|
||||
|
||||
depends_on("llvm-amdgpu", when="+rocm")
|
||||
depends_on("hsa-rocr-dev", when="+rocm")
|
||||
depends_on("hip", when="+rocm")
|
||||
depends_on("hip +rocm", when="+rocm")
|
||||
|
||||
conflicts("^blt@:0.3.6", when="+rocm")
|
||||
|
||||
|
||||
@@ -111,12 +111,20 @@ class Hip(CMakePackage):
|
||||
description="CMake build type",
|
||||
)
|
||||
|
||||
variant("rocm", default=True, description="Enable ROCm support")
|
||||
variant("cuda", default=False, description="Build with CUDA")
|
||||
conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive")
|
||||
conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required")
|
||||
|
||||
depends_on("cuda", when="+cuda")
|
||||
|
||||
depends_on("cmake@3.16.8:", type="build", when="@4.5.0:")
|
||||
depends_on("cmake@3.4.3:", type="build")
|
||||
depends_on("perl@5.10:", type=("build", "run"))
|
||||
|
||||
with when("+rocm"):
|
||||
depends_on("gl@4.5:")
|
||||
depends_on("py-cppheaderparser", type="build", when="@5.3.3:")
|
||||
|
||||
for ver in [
|
||||
"3.5.0",
|
||||
"3.7.0",
|
||||
@@ -390,6 +398,7 @@ def determine_version(cls, lib):
|
||||
return ver
|
||||
|
||||
def set_variables(self, env):
|
||||
if self.spec.satisfies("+rocm"):
|
||||
# Note: do not use self.spec[name] here, since not all dependencies
|
||||
# have defined prefixes when hip is marked as external.
|
||||
paths = self.get_paths()
|
||||
@@ -449,6 +458,10 @@ def set_variables(self, env):
|
||||
"--rocm-path={0}".format(paths["rocm-path"]),
|
||||
separator=" ",
|
||||
)
|
||||
elif self.spec.satisfies("+cuda"):
|
||||
env.set("CUDA_PATH", self.spec["cuda"].prefix)
|
||||
env.set("HIP_PATH", self.spec.prefix)
|
||||
env.set("HIP_PLATFORM", "nvidia")
|
||||
|
||||
def setup_build_environment(self, env):
|
||||
self.set_variables(env)
|
||||
@@ -478,7 +491,7 @@ def patch(self):
|
||||
"hip-config.cmake.in",
|
||||
string=True,
|
||||
)
|
||||
if self.spec.satisfies("@5.2:"):
|
||||
if self.spec.satisfies("@5.2: +rocm"):
|
||||
filter_file(
|
||||
'"${ROCM_PATH}/llvm"',
|
||||
self.spec["llvm-amdgpu"].prefix,
|
||||
@@ -519,7 +532,7 @@ def patch(self):
|
||||
substitute = "#!{perl}".format(perl=perl)
|
||||
files = ["roc-obj-extract", "roc-obj-ls"]
|
||||
filter_file(match, substitute, *files, **kwargs)
|
||||
if "@3.7.0:" in self.spec:
|
||||
if "@3.7.0: +rocm" in self.spec:
|
||||
numactl = self.spec["numactl"].prefix.lib
|
||||
kwargs = {"ignore_absent": False, "backup": False, "string": False}
|
||||
|
||||
@@ -537,20 +550,24 @@ def flag_handler(self, name, flags):
|
||||
return (flags, None, None)
|
||||
|
||||
def cmake_args(self):
|
||||
args = [
|
||||
args = []
|
||||
if self.spec.satisfies("+rocm"):
|
||||
args.append(self.define("HSA_PATH", self.spec["hsa-rocr-dev"].prefix))
|
||||
args.append(self.define("HIP_COMPILER", "clang"))
|
||||
args.append(
|
||||
self.define(
|
||||
"PROF_API_HEADER_PATH",
|
||||
join_path(self.spec["roctracer-dev-api"].prefix, "roctracer", "include", "ext"),
|
||||
),
|
||||
self.define("HIP_COMPILER", "clang"),
|
||||
self.define("HSA_PATH", self.spec["hsa-rocr-dev"].prefix),
|
||||
]
|
||||
self.spec["roctracer-dev-api"].prefix.roctracer.include.ext,
|
||||
)
|
||||
)
|
||||
if self.spec.satisfies("@:4.0.0"):
|
||||
args.append(self.define("HIP_RUNTIME", "ROCclr"))
|
||||
args.append(self.define("HIP_PLATFORM", "rocclr"))
|
||||
else:
|
||||
args.append(self.define("HIP_RUNTIME", "rocclr"))
|
||||
args.append(self.define("HIP_PLATFORM", "amd"))
|
||||
if self.spec.satisfies("+cuda"):
|
||||
args.append(self.define("HIP_PLATFORM", "nvidia"))
|
||||
|
||||
# LIBROCclr_STATIC_DIR is unused from 3.6.0 and above
|
||||
if "@3.5.0:4.3.2" in self.spec:
|
||||
|
||||
Reference in New Issue
Block a user