summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/grid/package.py
blob: abfad00d81df57ae88580e420bad2d5d8b149c08 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 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 Grid(AutotoolsPackage):
    """Data parallel C++ mathematical object library."""

    homepage = "https://github.com/paboyle/Grid"
    url = "https://github.com/paboyle/Grid/archive/refs/tags/0.8.2.tar.gz"
    git = "https://github.com/paboyle/Grid.git"

    maintainers("giordano")

    version("develop", branch="develop")

    variant(
        "comms",
        default="mpi",
        values=("none", "mpi", "mpi3", conditional("shmem", when="^cray-mpich")),
        description="Choose communication interface",
    )
    variant("fftw", default=True, description="Activate FFTW support")
    variant("lapack", default=False, description="Activate LAPACK support")
    variant("hdf5", default=False, description="Activate HDF5 support")
    variant("lime", default=False, description="Activate LIME support")
    variant("doxygen-doc", default=False, description="Build the documentation with doxygen")
    variant(
        "gen-simd-width",
        default="64",
        description="Size (in bytes) of the generic SIMD vector type",
    )
    variant(
        "rng",
        default="sitmo",
        values=("sitmo", "ranlux48", "mt19937"),
        multi=False,
        description="RNG setting",
    )
    variant("timers", default=True, description="System dependent high-resolution timers")
    variant("chroma", default=False, description="Chroma regression tests")

    depends_on("autoconf", type="build")
    depends_on("automake", type="build")
    depends_on("libtool", type="build")
    depends_on("m4", type="build")
    depends_on("gmp")
    depends_on("mpfr")
    depends_on("openssl")

    depends_on("mpi", when="comms=mpi")
    depends_on("cray-mpich", when="comms=shmem")
    depends_on("mpi@3:", when="comms=mpi3")

    depends_on("fftw-api@3", when="+fftw")

    depends_on("lapack", when="+lapack")

    depends_on("hdf5", when="+hdf5")

    depends_on("c-lime", when="+lime")

    depends_on("doxygen", type="build", when="+doxygen-doc")

    def autoreconf(self, spec, prefix):
        Executable("./bootstrap.sh")()

    def configure_args(self):
        spec = self.spec
        args = ["--with-gmp", "--with-mpfr"]

        if spec.satisfies("^intel-mkl"):
            if "+fftw" in spec or "+lapack" in spec:
                args.append("--enable-mkl")
        else:
            if "+fftw" in spec:
                args.append("--with-fftw={0}".format(self.spec["fftw-api"].prefix))
            if "+lapack" in spec:
                args.append("--enable-lapack={0}".format(self.spec["lapack"].prefix))
                # lapack is searched only as `-llapack`, so anything else
                # wouldn't be found, causing an error.
                args.append("LIBS={0}".format(self.spec["lapack"].libs.ld_flags))

        if "comms=none" not in spec:
            # The build system can easily get very confused about MPI support
            # and what linker to use.  In many case it'd end up building the
            # code with support for MPI but without using `mpicxx` or linking to
            # `-lmpi`, wreaking havoc.  Forcing `CXX` to be mpicxx should help.
            args.extend(
                [
                    "CC={0}".format(spec["mpi"].mpicc),
                    "CXX={0}".format(spec["mpi"].mpicxx),
                ]
            )

        args += self.enable_or_disable("timers")
        args += self.enable_or_disable("chroma")
        args += self.enable_or_disable("doxygen-doc")

        if "avx512" in spec.target:
            args.append("--enable-simd=AVX512")
        elif "avx2" in spec.target:
            args.append("--enable-simd=AVX2")
        elif "avx" in spec.target:
            if "fma4" in spec.target:
                args.append("--enable-simd=AVXFMA4")
            elif "fma" in spec.target:
                args.append("--enable-simd=AVXFMA")
            else:
                args.append("--enable-simd=AVX")
        elif "sse4_2" in spec.target:
            args.append("--enable-simd=SSE4")
        elif spec.target == "a64fx":
            args.append("--enable-simd=A64FX")
        elif "neon" in spec.target:
            args.append("--enable-simd=NEONv8")
        else:
            args.extend(
                [
                    "--enable-simd=GEN",
                    "--enable-gen-simd-width={0}".format(spec.variants["gen-simd-width"].value),
                ]
            )

        args.append("--enable-comms={0}".format(spec.variants["comms"].value))
        args.append("--enable-rng={0}".format(spec.variants["rng"].value))

        return args