kokkos: use 'when' instead of 'conflicts' for CUDA variants (#39463)
This commit is contained in:
parent
4818b75814
commit
2846be315b
@ -4,7 +4,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from llnl.util import tty
|
from llnl.util import lang, tty
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
@ -175,22 +175,14 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
|
|||||||
description="Intel GPU architecture",
|
description="Intel GPU architecture",
|
||||||
)
|
)
|
||||||
|
|
||||||
devices_values = list(devices_variants.keys())
|
for dev, (dflt, desc) in devices_variants.items():
|
||||||
for dev in devices_variants:
|
|
||||||
dflt, desc = devices_variants[dev]
|
|
||||||
variant(dev, default=dflt, description=desc)
|
variant(dev, default=dflt, description=desc)
|
||||||
conflicts("+cuda", when="+rocm", msg="CUDA and ROCm are not compatible in Kokkos.")
|
conflicts("+cuda", when="+rocm", msg="CUDA and ROCm are not compatible in Kokkos.")
|
||||||
|
|
||||||
options_values = list(options_variants.keys())
|
for opt, (dflt, desc) in options_variants.items():
|
||||||
for opt in options_values:
|
variant(opt, default=dflt, description=desc, when=("+cuda" if "cuda" in opt else None))
|
||||||
if "cuda" in opt:
|
|
||||||
conflicts("+%s" % opt, when="~cuda", msg="Must enable CUDA to use %s" % opt)
|
|
||||||
dflt, desc = options_variants[opt]
|
|
||||||
variant(opt, default=dflt, description=desc)
|
|
||||||
|
|
||||||
tpls_values = list(tpls_variants.keys())
|
for tpl, (dflt, desc) in tpls_variants.items():
|
||||||
for tpl in tpls_values:
|
|
||||||
dflt, desc = tpls_variants[tpl]
|
|
||||||
variant(tpl, default=dflt, description=desc)
|
variant(tpl, default=dflt, description=desc)
|
||||||
depends_on(tpl, when="+%s" % tpl)
|
depends_on(tpl, when="+%s" % tpl)
|
||||||
|
|
||||||
@ -264,7 +256,7 @@ def append_args(self, cmake_prefix, cmake_options, spack_options):
|
|||||||
optname = "Kokkos_%s_%s" % (cmake_prefix, opt.upper())
|
optname = "Kokkos_%s_%s" % (cmake_prefix, opt.upper())
|
||||||
# Explicitly enable or disable
|
# Explicitly enable or disable
|
||||||
option = self.define_from_variant(optname, variant_name)
|
option = self.define_from_variant(optname, variant_name)
|
||||||
if option not in spack_options:
|
if option:
|
||||||
spack_options.append(option)
|
spack_options.append(option)
|
||||||
|
|
||||||
def setup_dependent_package(self, module, dependent_spec):
|
def setup_dependent_package(self, module, dependent_spec):
|
||||||
@ -316,11 +308,11 @@ def cmake_args(self):
|
|||||||
for arch in spack_microarches:
|
for arch in spack_microarches:
|
||||||
options.append(self.define("Kokkos_ARCH_" + arch.upper(), True))
|
options.append(self.define("Kokkos_ARCH_" + arch.upper(), True))
|
||||||
|
|
||||||
self.append_args("ENABLE", self.devices_values, options)
|
self.append_args("ENABLE", self.devices_variants.keys(), options)
|
||||||
self.append_args("ENABLE", self.options_values, options)
|
self.append_args("ENABLE", self.options_variants.keys(), options)
|
||||||
self.append_args("ENABLE", self.tpls_values, options)
|
self.append_args("ENABLE", self.tpls_variants.keys(), options)
|
||||||
|
|
||||||
for tpl in self.tpls_values:
|
for tpl in self.tpls_variants:
|
||||||
if spec.variants[tpl].value:
|
if spec.variants[tpl].value:
|
||||||
options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
|
options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
|
||||||
|
|
||||||
@ -334,7 +326,8 @@ def cmake_args(self):
|
|||||||
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
|
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
|
||||||
options.append(self.define("CMAKE_CXX_FLAGS", "-fp-model=precise"))
|
options.append(self.define("CMAKE_CXX_FLAGS", "-fp-model=precise"))
|
||||||
|
|
||||||
return options
|
# Remove duplicate options
|
||||||
|
return lang.dedupe(options)
|
||||||
|
|
||||||
test_script_relative_path = join_path("scripts", "spack_test")
|
test_script_relative_path = join_path("scripts", "spack_test")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user