kokkos: refactor defines to use helper functions (#27189)
This commit is contained in:
parent
6a7b07c60b
commit
503576c017
1 changed files with 19 additions and 33 deletions
|
@ -175,6 +175,7 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
|
||||||
conflicts("+wrapper", when="~cuda")
|
conflicts("+wrapper", when="~cuda")
|
||||||
|
|
||||||
stds = ["11", "14", "17", "20"]
|
stds = ["11", "14", "17", "20"]
|
||||||
|
# TODO: This should be named cxxstd for consistency with other packages
|
||||||
variant("std", default="14", values=stds, multi=False)
|
variant("std", default="14", values=stds, multi=False)
|
||||||
variant("pic", default=False, description="Build position independent code")
|
variant("pic", default=False, description="Build position independent code")
|
||||||
|
|
||||||
|
@ -208,18 +209,10 @@ def get_microarch(cls, target):
|
||||||
def append_args(self, cmake_prefix, cmake_options, spack_options):
|
def append_args(self, cmake_prefix, cmake_options, spack_options):
|
||||||
variant_to_cmake_option = {'rocm': 'hip'}
|
variant_to_cmake_option = {'rocm': 'hip'}
|
||||||
for variant_name in cmake_options:
|
for variant_name in cmake_options:
|
||||||
enablestr = "+%s" % variant_name
|
|
||||||
opt = variant_to_cmake_option.get(variant_name, variant_name)
|
opt = variant_to_cmake_option.get(variant_name, variant_name)
|
||||||
optuc = opt.upper()
|
optname = "Kokkos_%s_%s" % (cmake_prefix, opt.upper())
|
||||||
optname = "Kokkos_%s_%s" % (cmake_prefix, optuc)
|
# Explicitly enable or disable
|
||||||
option = None
|
option = self.define_from_variant(optname, variant_name)
|
||||||
if enablestr in self.spec:
|
|
||||||
option = "-D%s=ON" % optname
|
|
||||||
else:
|
|
||||||
# explicitly turn off if not enabled
|
|
||||||
# this avoids any confusing implicit defaults
|
|
||||||
# that come from the CMake
|
|
||||||
option = "-D%s=OFF" % optname
|
|
||||||
if option not in spack_options:
|
if option not in spack_options:
|
||||||
spack_options.append(option)
|
spack_options.append(option)
|
||||||
|
|
||||||
|
@ -231,6 +224,7 @@ def setup_dependent_package(self, module, dependent_spec):
|
||||||
|
|
||||||
def cmake_args(self):
|
def cmake_args(self):
|
||||||
spec = self.spec
|
spec = self.spec
|
||||||
|
from_variant = self.define_from_variant
|
||||||
|
|
||||||
if spec.satisfies("~wrapper+cuda") and not (
|
if spec.satisfies("~wrapper+cuda") and not (
|
||||||
spec.satisfies("%clang") or spec.satisfies("%cce")
|
spec.satisfies("%clang") or spec.satisfies("%cce")
|
||||||
|
@ -238,14 +232,11 @@ def cmake_args(self):
|
||||||
raise InstallError("Kokkos requires +wrapper when using +cuda"
|
raise InstallError("Kokkos requires +wrapper when using +cuda"
|
||||||
"without clang")
|
"without clang")
|
||||||
|
|
||||||
options = []
|
options = [
|
||||||
|
from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
|
||||||
isdiy = "+diy" in spec
|
from_variant("Kokkos_CXX_STANDARD", "std"),
|
||||||
if isdiy:
|
from_variant("BUILD_SHARED_LIBS", "shared"),
|
||||||
options.append("-DSpack_WORKAROUND=On")
|
]
|
||||||
|
|
||||||
if "+pic" in spec:
|
|
||||||
options.append("-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
|
|
||||||
|
|
||||||
spack_microarches = []
|
spack_microarches = []
|
||||||
if "+cuda" in spec:
|
if "+cuda" in spec:
|
||||||
|
@ -272,29 +263,24 @@ def cmake_args(self):
|
||||||
amdgpu_target))
|
amdgpu_target))
|
||||||
|
|
||||||
for arch in spack_microarches:
|
for arch in spack_microarches:
|
||||||
options.append("-DKokkos_ARCH_%s=ON" % arch.upper())
|
options.append(self.define("Kokkos_ARCH_" + arch.upper(), True))
|
||||||
|
|
||||||
self.append_args("ENABLE", self.devices_values, options)
|
self.append_args("ENABLE", self.devices_values, options)
|
||||||
self.append_args("ENABLE", self.options_values, options)
|
self.append_args("ENABLE", self.options_values, options)
|
||||||
self.append_args("ENABLE", self.tpls_values, options)
|
self.append_args("ENABLE", self.tpls_values, options)
|
||||||
|
|
||||||
for tpl in self.tpls_values:
|
for tpl in self.tpls_values:
|
||||||
var = "+%s" % tpl
|
if spec.variants[tpl].value:
|
||||||
if var in self.spec:
|
options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
|
||||||
options.append("-D%s_DIR=%s" % (tpl, spec[tpl].prefix))
|
|
||||||
|
|
||||||
if '+rocm' in self.spec:
|
if '+rocm' in self.spec:
|
||||||
options.append('-DCMAKE_CXX_COMPILER=%s' %
|
options.append(self.define(
|
||||||
self.spec['hip'].hipcc)
|
'CMAKE_CXX_COMPILER', self.spec['hip'].hipcc))
|
||||||
elif '+wrapper' in self.spec:
|
elif '+wrapper' in self.spec:
|
||||||
options.append("-DCMAKE_CXX_COMPILER=%s" %
|
options.append(self.define(
|
||||||
self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
|
"CMAKE_CXX_COMPILER",
|
||||||
|
self.spec["kokkos-nvcc-wrapper"].kokkos_cxx
|
||||||
# Set the C++ standard to use
|
))
|
||||||
options.append("-DKokkos_CXX_STANDARD=%s" %
|
|
||||||
self.spec.variants["std"].value)
|
|
||||||
|
|
||||||
options.append('-DBUILD_SHARED_LIBS=%s' % ('+shared' in self.spec))
|
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue