paraview: update cuda_arch management (#44243)

* refactor logic to switch to cmake for cuda management
This commit is contained in:
Alberto Invernizzi 2024-05-31 06:33:38 +02:00 committed by GitHub
parent 82050ed371
commit 77fd5d8414
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,6 +144,40 @@ class Paraview(CMakePackage, CudaPackage, ROCmPackage):
msg="Use paraview@5.9.0 with %xl_r. Earlier versions are not able to build with xl.",
)
# CUDA ARCH
# This is (more or less) the mapping hard-coded in VTK-m logic
# see https://gitlab.kitware.com/vtk/vtk-m/-/blob/v2.1.0/CMake/VTKmDeviceAdapters.cmake?ref_type=tags#L221-247
supported_cuda_archs = {
"20": "fermi",
"21": "fermi",
"30": "kepler",
"32": "kepler",
"35": "kepler",
"37": "kepler",
"50": "maxwel",
"52": "maxwel",
"53": "maxwel",
"60": "pascal",
"61": "pascal",
"62": "pascal",
"70": "volta",
"72": "volta",
"75": "turing",
"80": "ampere",
"86": "ampere",
}
# VTK-m and transitively ParaView does not support Tesla Arch
for _arch in range(10, 14):
conflicts(f"cuda_arch={_arch}", when="+cuda", msg="ParaView requires cuda_arch >= 20")
# Starting from cmake@3.18, CUDA architecture managament can be delegated to CMake.
# Hence, it is possible to rely on it instead of relying on custom logic updates from VTK-m for
# newer architectures (wrt mapping).
for _arch in [arch for arch in CudaPackage.cuda_arch_values if int(arch) > 86]:
conflicts("cmake@:3.17", when=f"cuda_arch={_arch}")
# We only support one single Architecture
for _arch, _other_arch in itertools.permutations(CudaPackage.cuda_arch_values, 2):
conflicts(
@ -152,9 +186,6 @@ class Paraview(CMakePackage, CudaPackage, ROCmPackage):
msg="Paraview only accepts one architecture value",
)
for _arch in range(10, 14):
conflicts("cuda_arch=%d" % _arch, when="+cuda", msg="ParaView requires cuda_arch >= 20")
depends_on("cmake@3.3:", type="build")
depends_on("cmake@3.21:", type="build", when="+rocm")
@ -577,38 +608,25 @@ def use_x11():
# VTK-m expects cuda_arch to be the arch name vs. the arch version.
if spec.satisfies("+cuda"):
supported_cuda_archs = {
# VTK-m and transitively ParaView does not support Tesla Arch
"20": "fermi",
"21": "fermi",
"30": "kepler",
"32": "kepler",
"35": "kepler",
"37": "kepler",
"50": "maxwel",
"52": "maxwel",
"53": "maxwel",
"60": "pascal",
"61": "pascal",
"62": "pascal",
"70": "volta",
"72": "volta",
"75": "turing",
"80": "ampere",
"86": "ampere",
}
if spec["cmake"].satisfies("@3.18:"):
cmake_args.append(
self.define(
"CMAKE_CUDA_ARCHITECTURES", ";".join(spec.variants["cuda_arch"].value)
)
)
else:
# ParaView/VTK-m only accepts one arch, default to first element
requested_arch = spec.variants["cuda_arch"].value[0]
cuda_arch_value = "native"
requested_arch = spec.variants["cuda_arch"].value
if requested_arch == "none":
cuda_arch_value = "native"
else:
try:
cuda_arch_value = supported_cuda_archs[requested_arch]
except KeyError:
raise InstallError("Incompatible cuda_arch=" + requested_arch)
# ParaView/VTK-m only accepts one arch, default to first element
if requested_arch[0] != "none":
try:
cuda_arch_value = supported_cuda_archs[requested_arch[0]]
except KeyError:
raise InstallError("Incompatible cuda_arch=" + requested_arch[0])
cmake_args.append(self.define("VTKm_CUDA_Architecture", cuda_arch_value))
cmake_args.append(self.define("VTKm_CUDA_Architecture", cuda_arch_value))
if "darwin" in spec.architecture:
cmake_args.extend(