2024-01-02 16:21:30 +08:00
|
|
|
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
|
2020-08-08 06:42:07 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
import socket
|
|
|
|
|
2022-05-29 00:55:44 +08:00
|
|
|
from spack.package import *
|
2020-08-08 06:42:07 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
from .blt import llnl_link_helpers
|
|
|
|
|
2020-08-08 06:42:07 +08:00
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
class Chai(CachedCMakePackage, CudaPackage, ROCmPackage):
|
2020-08-08 06:42:07 +08:00
|
|
|
"""
|
|
|
|
Copy-hiding array interface for data migration between memory spaces
|
|
|
|
"""
|
|
|
|
|
|
|
|
homepage = "https://github.com/LLNL/CHAI"
|
|
|
|
git = "https://github.com/LLNL/CHAI.git"
|
2021-10-15 05:50:09 +08:00
|
|
|
tags = ["ecp", "e4s", "radiuss"]
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2023-02-02 13:07:25 +08:00
|
|
|
maintainers("davidbeckingsale")
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2023-12-23 03:29:11 +08:00
|
|
|
license("BSD-3-Clause")
|
|
|
|
|
2022-05-19 13:48:22 +08:00
|
|
|
version("develop", branch="develop", submodules=False)
|
2024-04-03 06:03:07 +08:00
|
|
|
version(
|
|
|
|
"2024.02.0",
|
|
|
|
tag="v2024.02.0",
|
|
|
|
commit="31773a2f0d30f3f64c82939f60fc4da32cf33261",
|
|
|
|
submodules=False,
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2023.06.0",
|
|
|
|
tag="v2023.06.0",
|
|
|
|
commit="6fe3470ad020303530af2f3dbbfe18826bd3319b",
|
|
|
|
submodules=False,
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2022.10.0",
|
|
|
|
tag="v2022.10.0",
|
|
|
|
commit="9510efd33b06e4443b15447eebb7dad761822654",
|
|
|
|
submodules=False,
|
|
|
|
)
|
2023-08-29 22:33:03 +08:00
|
|
|
version(
|
|
|
|
"2022.03.0",
|
|
|
|
tag="v2022.03.0",
|
|
|
|
commit="f0b809de1ac194376866b3ac0f5933d4146ec09e",
|
|
|
|
submodules=False,
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.4.0", tag="v2.4.0", commit="77d22da28187245a2c5454cf471c0c352bd98ad7", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.3.0", tag="v2.3.0", commit="42f3fbcc0b966227b40b4467dc919a4c24f07196", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.2.2", tag="v2.2.2", commit="56e75fc0f805b2746f3992af0c00c474513e3b24", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.2.1", tag="v2.2.1", commit="c912f583828ea5963850816e3e232cc45608ccf7", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.2.0", tag="v2.2.0", commit="18536c61a4817db6b3b3025f35e2dd3ae532330c", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.1.1", tag="v2.1.1", commit="496911e00d15c350560860f7964cd5fb5ab7f515", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.1.0", tag="v2.1.0", commit="fff02768068a64970b34760a1041585319edee87", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"2.0.0", tag="v2.0.0", commit="63139cf45443b1266950826b165e042c7679b557", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"1.2.0", tag="v1.2.0", commit="7bb5bc12e4508db45910d8e2b98444687da7ebf6", submodules=True
|
|
|
|
)
|
|
|
|
version(
|
|
|
|
"1.1.0", tag="v1.1.0", commit="907d5f40d653a73955387067799913397807adf3", submodules=True
|
|
|
|
)
|
|
|
|
version("1.0", tag="v1.0", commit="501a098ad879dc8deb4a74fcfe8c08c283a10627", submodules=True)
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
# Patching Umpire for dual BLT targets import changed MPI target name in Umpire link interface
|
|
|
|
# We propagate the patch here.
|
|
|
|
patch("change_mpi_target_name_umpire_patch.patch", when="@2022.10.0:2023.06.0")
|
|
|
|
|
2020-12-03 09:07:56 +08:00
|
|
|
variant("enable_pick", default=False, description="Enable pick method")
|
2024-01-19 07:53:28 +08:00
|
|
|
variant(
|
|
|
|
"separable_compilation",
|
|
|
|
default=True,
|
|
|
|
description="Build with CUDA_SEPARABLE_COMPILATION flag on ",
|
|
|
|
)
|
2020-08-08 06:42:07 +08:00
|
|
|
variant("shared", default=True, description="Build Shared Libs")
|
2024-04-03 06:03:07 +08:00
|
|
|
variant("mpi", default=False, description="Enable MPI support")
|
2020-08-08 06:42:07 +08:00
|
|
|
variant("raja", default=False, description="Build plugin for RAJA")
|
2020-10-30 02:52:10 +08:00
|
|
|
variant("examples", default=True, description="Build examples.")
|
2021-09-02 08:58:47 +08:00
|
|
|
variant("openmp", default=False, description="Build using OpenMP")
|
2020-12-03 09:07:56 +08:00
|
|
|
# TODO: figure out gtest dependency and then set this default True
|
|
|
|
# and remove the +tests conflict below.
|
2024-04-03 06:03:07 +08:00
|
|
|
variant(
|
|
|
|
"tests",
|
|
|
|
default="none",
|
|
|
|
values=("none", "basic", "benchmarks"),
|
|
|
|
multi=False,
|
|
|
|
description="Tests to run",
|
|
|
|
)
|
2020-08-08 06:42:07 +08:00
|
|
|
|
|
|
|
depends_on("cmake@3.8:", type="build")
|
2020-12-03 09:07:56 +08:00
|
|
|
depends_on("cmake@3.9:", type="build", when="+cuda")
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("cmake@3.14:", type="build", when="@2022.03.0:")
|
2021-05-01 06:57:44 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("blt")
|
|
|
|
depends_on("blt@0.6.1:", type="build", when="@2024.02.0:")
|
|
|
|
depends_on("blt@0.5.3", type="build", when="@2023.06.0")
|
|
|
|
depends_on("blt@0.5.2:0.5.3", type="build", when="@2022.10.0")
|
|
|
|
depends_on("blt@0.5.0:0.5.3", type="build", when="@2022.03.0")
|
|
|
|
depends_on("blt@0.4.1:0.5.3", type="build", when="@2.4.0")
|
|
|
|
depends_on("blt@0.4.0:0.5.3", type="build", when="@2.3.0")
|
|
|
|
depends_on("blt@0.3.6:0.5.3", type="build", when="@:2.2.2")
|
2023-08-09 13:53:17 +08:00
|
|
|
conflicts("^blt@:0.3.6", when="+rocm")
|
2021-05-01 06:57:44 +08:00
|
|
|
|
2020-08-08 06:42:07 +08:00
|
|
|
depends_on("umpire")
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("umpire@2024.02.0:", when="@2024.02.0:")
|
|
|
|
depends_on("umpire@2023.06.0", when="@2023.06.0")
|
|
|
|
depends_on("umpire@2022.10.0:2023.06.0", when="@2022.10.0")
|
|
|
|
depends_on("umpire@2022.03.0:2023.06.0", when="@2022.03.0")
|
2021-09-02 08:58:47 +08:00
|
|
|
depends_on("umpire@6.0.0", when="@2.4.0")
|
|
|
|
depends_on("umpire@4.1.2", when="@2.2.0:2.3.0")
|
2024-04-03 06:03:07 +08:00
|
|
|
|
|
|
|
depends_on("umpire+mpi", when="+mpi")
|
2021-09-02 08:58:47 +08:00
|
|
|
|
|
|
|
with when("+cuda"):
|
|
|
|
depends_on("umpire+cuda")
|
|
|
|
for sm_ in CudaPackage.cuda_arch_values:
|
|
|
|
depends_on("umpire+cuda cuda_arch={0}".format(sm_), when="cuda_arch={0}".format(sm_))
|
|
|
|
|
|
|
|
with when("+rocm"):
|
|
|
|
depends_on("umpire+rocm")
|
|
|
|
for arch in ROCmPackage.amdgpu_targets:
|
|
|
|
depends_on(
|
|
|
|
"umpire+rocm amdgpu_target={0}".format(arch), when="amdgpu_target={0}".format(arch)
|
|
|
|
)
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2021-09-02 08:58:47 +08:00
|
|
|
with when("+raja"):
|
|
|
|
depends_on("raja~openmp", when="~openmp")
|
|
|
|
depends_on("raja+openmp", when="+openmp")
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("raja@2024.02.0:", when="@2024.02.0:")
|
|
|
|
depends_on("raja@2023.06.0", when="@2023.06.0")
|
|
|
|
depends_on("raja@2022.10.0:2023.06.0", when="@2022.10.0")
|
|
|
|
depends_on("raja@2022.03.0:2023.06.0", when="@2022.03.0")
|
2021-09-02 08:58:47 +08:00
|
|
|
depends_on("raja@0.12.0", when="@2.2.0:2.2.2")
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("raja@0.13.0", when="@2.3.0")
|
|
|
|
depends_on("raja@0.14.0", when="@2.4.0")
|
2022-07-31 06:19:18 +08:00
|
|
|
|
2021-09-02 08:58:47 +08:00
|
|
|
with when("+cuda"):
|
|
|
|
depends_on("raja+cuda")
|
|
|
|
for sm_ in CudaPackage.cuda_arch_values:
|
|
|
|
depends_on("raja+cuda cuda_arch={0}".format(sm_), when="cuda_arch={0}".format(sm_))
|
|
|
|
with when("+rocm"):
|
|
|
|
depends_on("raja+rocm")
|
|
|
|
for arch in ROCmPackage.amdgpu_targets:
|
|
|
|
depends_on(
|
|
|
|
"raja+rocm amdgpu_target={0}".format(arch),
|
|
|
|
when="amdgpu_target={0}".format(arch),
|
|
|
|
)
|
2020-11-19 03:52:21 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
depends_on("mpi", when="+mpi")
|
2020-12-03 09:07:56 +08:00
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
def _get_sys_type(self, spec):
|
|
|
|
sys_type = spec.architecture
|
|
|
|
if "SYS_TYPE" in env:
|
|
|
|
sys_type = env["SYS_TYPE"]
|
|
|
|
return sys_type
|
|
|
|
|
|
|
|
@property
|
|
|
|
def cache_name(self):
|
|
|
|
hostname = socket.gethostname()
|
|
|
|
if "SYS_TYPE" in env:
|
|
|
|
hostname = hostname.rstrip("1234567890")
|
2024-04-03 06:03:07 +08:00
|
|
|
return "{0}-{1}-{2}@{3}-{4}.cmake".format(
|
2021-09-18 12:29:41 +08:00
|
|
|
hostname,
|
|
|
|
self._get_sys_type(self.spec),
|
|
|
|
self.spec.compiler.name,
|
|
|
|
self.spec.compiler.version,
|
2024-04-03 06:03:07 +08:00
|
|
|
self.spec.dag_hash(8),
|
2021-09-18 12:29:41 +08:00
|
|
|
)
|
|
|
|
|
2022-10-25 00:08:16 +08:00
|
|
|
def initconfig_compiler_entries(self):
|
|
|
|
spec = self.spec
|
2024-04-03 06:03:07 +08:00
|
|
|
compiler = self.compiler
|
|
|
|
# Default entries are already defined in CachedCMakePackage, inherit them:
|
2023-07-05 22:04:29 +08:00
|
|
|
entries = super().initconfig_compiler_entries()
|
2024-04-03 06:03:07 +08:00
|
|
|
|
|
|
|
llnl_link_helpers(entries, spec, compiler)
|
|
|
|
|
2022-10-25 00:08:16 +08:00
|
|
|
return entries
|
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
def initconfig_hardware_entries(self):
|
2020-08-08 06:42:07 +08:00
|
|
|
spec = self.spec
|
2023-07-05 22:04:29 +08:00
|
|
|
entries = super().initconfig_hardware_entries()
|
2020-08-08 06:42:07 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
entries.append("#------------------{0}".format("-" * 30))
|
|
|
|
entries.append("# Package custom hardware settings")
|
|
|
|
entries.append("#------------------{0}\n".format("-" * 30))
|
2021-09-02 08:58:47 +08:00
|
|
|
|
2020-08-08 06:42:07 +08:00
|
|
|
if "+cuda" in spec:
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_option("ENABLE_CUDA", True))
|
2024-01-19 07:53:28 +08:00
|
|
|
if "+separable_compilation" in spec:
|
|
|
|
entries.append(cmake_cache_option("CMAKE_CUDA_SEPARABLE_COMPILATION", True))
|
|
|
|
entries.append(cmake_cache_option("CUDA_SEPARABLE_COMPILATION", True))
|
2020-08-08 06:42:07 +08:00
|
|
|
|
|
|
|
else:
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_option("ENABLE_CUDA", False))
|
2020-08-08 06:42:07 +08:00
|
|
|
|
2020-12-02 22:58:58 +08:00
|
|
|
if "+rocm" in spec:
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_option("ENABLE_HIP", True))
|
2020-11-19 03:52:21 +08:00
|
|
|
else:
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_option("ENABLE_HIP", False))
|
2020-12-03 09:07:56 +08:00
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
return entries
|
2020-08-08 06:42:07 +08:00
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
def initconfig_mpi_entries(self):
|
|
|
|
spec = self.spec
|
|
|
|
|
|
|
|
entries = super(Chai, self).initconfig_mpi_entries()
|
|
|
|
entries.append(cmake_cache_option("ENABLE_MPI", "+mpi" in spec))
|
|
|
|
|
|
|
|
return entries
|
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
def initconfig_package_entries(self):
|
|
|
|
spec = self.spec
|
|
|
|
entries = []
|
2020-10-30 02:52:10 +08:00
|
|
|
|
2022-05-19 13:48:22 +08:00
|
|
|
option_prefix = "CHAI_" if spec.satisfies("@2022.03.0:") else ""
|
|
|
|
|
2024-04-03 06:03:07 +08:00
|
|
|
# TPL locations
|
|
|
|
entries.append("#------------------{0}".format("-" * 60))
|
|
|
|
entries.append("# TPLs")
|
|
|
|
entries.append("#------------------{0}\n".format("-" * 60))
|
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_path("BLT_SOURCE_DIR", spec["blt"].prefix))
|
|
|
|
if "+raja" in spec:
|
2022-05-19 13:48:22 +08:00
|
|
|
entries.append(cmake_cache_option("{}ENABLE_RAJA_PLUGIN".format(option_prefix), True))
|
2021-09-18 12:29:41 +08:00
|
|
|
entries.append(cmake_cache_path("RAJA_DIR", spec["raja"].prefix))
|
2024-04-03 06:03:07 +08:00
|
|
|
entries.append(cmake_cache_path("umpire_DIR", spec["umpire"].prefix))
|
|
|
|
|
|
|
|
# Build options
|
|
|
|
entries.append("#------------------{0}".format("-" * 60))
|
|
|
|
entries.append("# Build Options")
|
|
|
|
entries.append("#------------------{0}\n".format("-" * 60))
|
|
|
|
|
|
|
|
# Build options
|
|
|
|
entries.append(cmake_cache_string("CMAKE_BUILD_TYPE", spec.variants["build_type"].value))
|
|
|
|
entries.append(cmake_cache_option("BUILD_SHARED_LIBS", "+shared" in spec))
|
|
|
|
|
|
|
|
# Generic options that have a prefixed equivalent in CHAI CMake
|
|
|
|
entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec))
|
|
|
|
entries.append(cmake_cache_option("ENABLE_EXAMPLES", "+examples" in spec))
|
|
|
|
entries.append(cmake_cache_option("ENABLE_DOCS", False))
|
|
|
|
if "tests=benchmarks" in spec:
|
|
|
|
# BLT requires ENABLE_TESTS=True to enable benchmarks
|
|
|
|
entries.append(cmake_cache_option("ENABLE_BENCHMARKS", True))
|
|
|
|
entries.append(cmake_cache_option("ENABLE_TESTS", True))
|
|
|
|
else:
|
|
|
|
entries.append(cmake_cache_option("ENABLE_TESTS", "tests=none" not in spec))
|
|
|
|
|
|
|
|
# Prefixed options that used to be name without one
|
2022-05-19 13:48:22 +08:00
|
|
|
entries.append(
|
|
|
|
cmake_cache_option("{}ENABLE_PICK".format(option_prefix), "+enable_pick" in spec)
|
2022-07-31 06:19:18 +08:00
|
|
|
)
|
2021-09-18 12:29:41 +08:00
|
|
|
|
|
|
|
return entries
|
2021-05-27 08:23:37 +08:00
|
|
|
|
2021-09-18 12:29:41 +08:00
|
|
|
def cmake_args(self):
|
2024-04-03 06:03:07 +08:00
|
|
|
return []
|