summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/ratel/package.py
blob: 7cba52de93dd84f0f121697b5b0eca19662d7df1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Ratel(MakefilePackage, CudaPackage, ROCmPackage):
    """Extensible, performance-portable solid mechanics with libCEED and PETSc"""

    homepage = "https://ratel.micromorph.org"
    git = "https://gitlab.com/micromorph/ratel.git"

    maintainers("jedbrown", "jeremylt")

    license("BSD-2-Clause")

    version("develop", branch="main")
    version("0.3.0", tag="v0.3.0", commit="ca2f3357e10b89fb274626fba104aad30c72774b")
    version("0.2.1", tag="v0.2.1", commit="043b61696a2407205fdfd898681467d1a7ff59e0")
    version("0.1.2", tag="v0.1.2", commit="94ad630bf897d231af7a94bf08257f6067258aae")

    # development version
    depends_on("libceed@develop", when="@develop")
    depends_on("petsc@main", when="@develop")
    # released versions
    depends_on("libceed@0.12.0:0.12", when="@0.3.0")
    depends_on("petsc@3.20.0:3.20", when="@0.3.0")
    depends_on("libceed@0.11.0:0.11", when="@0.2.1")
    depends_on("petsc@3.18.3:3.18", when="@0.2.1")
    depends_on("libceed@0.10.1:0.10", when="@0.1.2")
    depends_on("petsc@3.17:3.17", when="@0.1.2")

    # Note: '+cuda' and 'cuda_arch' variants are added by the CudaPackage
    #       '+rocm' and 'amdgpu_target' variants are added by the ROCmPackage
    # But we need to sync cuda/rocm with libCEED and PETSc
    for sm_ in CudaPackage.cuda_arch_values:
        depends_on(
            "libceed+cuda cuda_arch={0}".format(sm_), when="+cuda cuda_arch={0}".format(sm_)
        )
        depends_on("petsc+cuda cuda_arch={0}".format(sm_), when="+cuda cuda_arch={0}".format(sm_))
    for gfx in ROCmPackage.amdgpu_targets:
        depends_on(
            "libceed+rocm amdgpu_target={0}".format(gfx),
            when="+rocm amdgpu_target={0}".format(gfx),
        )
        depends_on(
            "petsc+rocm amdgpu_target={0}".format(gfx), when="+rocm amdgpu_target={0}".format(gfx)
        )
    # Kokkos required for AMD GPUs
    depends_on("petsc+kokkos", when="+rocm")

    @property
    def common_make_opts(self):
        spec = self.spec

        # verbose build and test
        make_options = ["V=1", "PROVE_OPTS=-v"]

        # libCEED and PETSc dirs
        make_options += [
            "CEED_DIR=%s" % spec["libceed"].prefix,
            "PETSC_DIR=%s" % spec["petsc"].prefix,
        ]
        return make_options

    def edit(self, spec, prefix):
        make("info", *self.common_make_opts)

    @property
    def build_targets(self):
        return self.common_make_opts

    @property
    def install_targets(self):
        return ["install", "prefix={0}".format(self.prefix)] + self.common_make_opts

    def check(self):
        make("prove", *self.common_make_opts, parallel=False)