summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/spectre/package.py
blob: 4f40fa4cf89d6f15ae5839af8d4935255daff67e (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# Copyright 2013-2024 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 Spectre(CMakePackage):
    """The SpECTRE numerical relativity code.

    SpECTRE is an open-source code for multi-scale, multi-physics problems in
    astrophysics and gravitational physics. In the future, we hope that it can
    be applied to problems across discipline boundaries in fluid dynamics,
    geoscience, plasma physics, nuclear physics, and engineering. It runs at
    petascale and is designed for future exascale computers.

    SpECTRE is being developed in support of our collaborative Simulating
    eXtreme Spacetimes (SXS) research program into the multi-messenger
    astrophysics of neutron star mergers, core-collapse supernovae, and
    gamma-ray bursts."""

    homepage = "https://spectre-code.com"
    url = "https://github.com/sxs-collaboration/spectre/archive/v2021.12.15.tar.gz"
    git = "https://github.com/sxs-collaboration/spectre.git"

    maintainers("nilsvu")

    generator("ninja")

    license("MIT")

    version("develop", branch="develop")
    version(
        "2023.10.11", sha256="f25d17bc80cc49ebdd81726326701fe9ecd2b6705d86e6e3d48d9e4a458c8aff"
    )
    version(
        "2023.09.07", sha256="2375117df09d99a2716d445ff51d151422467bd42cd38b5f1177d2d40cb90916"
    )
    version(
        "2023.08.18", sha256="bdeb7da707d51d0e3b2a29b1d28646c5a64cba15844612e7b3726e8a28b37692"
    )
    version(
        "2023.07.29", sha256="134668b81b8e89e3fd02b8b1415a1198889d7fb90f04ca6556458d3ce4489e43"
    )
    version(
        "2023.06.19", sha256="f1140dfca1a9cf58f04acfe853c5597fa19c463d52b3643428e379496bff1236"
    )
    version(
        "2023.05.16", sha256="9cfe585e85b63e69d1b9b3922c68d3bd83d95853b6955e706133f2aaa933bd2b"
    )
    version(
        "2023.04.07", sha256="f18238788155413c4c1f73c5591f4bf60a3d331f0c926b3737a61b33c99dfb9c"
    )
    version(
        "2023.03.09", sha256="d8cd3512a8477b0b9ac83141d18fc7c55280bd886c6d97b60e8ae26c16c648ab"
    )
    version(
        "2023.02.09", sha256="cdd85aed10ea7d372a7989da16a379e684276978c1e53438cb562910601fd471"
    )
    version(
        "2023.01.13", sha256="fa1392015e4a8900483e0428e6b7b51a6c129f3d64f7ff862d810cfea0e04b40"
    )
    version(
        "2022.12.16", sha256="2b692ff1be889c86bc2d95ef523dc1a4880e66b9bdf75883e299643f4ccbcb50"
    )
    version(
        "2022.12.02", sha256="a930a41fe16834bf8dd9191180fd9db8fd8a871fbd10cc2c48a5360c0990a5b7"
    )
    version(
        "2022.11.15", sha256="3860fdb49b5ca5bc067a291f744f67f59081db21c82beb92b4c033edf39fc62e"
    )
    version(
        "2022.10.04", sha256="f9666ad7e546b2b6b5bc7743db1ab20eaada77ce5016f4467a96c9aab838ae1b"
    )
    version(
        "2022.09.02", sha256="8a218237c76f85debf8a1c65de67a6c7fe41c5df51efd7b5c160868ba5d40927"
    )
    version(
        "2022.08.01", sha256="453ad831f3d8c2d4dbed0b2e4f08f7a3b64e6634a2025b5ac1a0b242c1d87d93"
    )
    version(
        "2022.07.18", sha256="8812aeba70d60d6800fe8866542c3d2e0fae34aaac0c8d1c4324cf6c804f3fe1"
    )
    version(
        "2022.06.14", sha256="872ab6729d8675c90b0d194f4ca34e4c02ce23e60c558a43b874fee9da9dfe78"
    )
    version(
        "2022.05.05", sha256="4577d3a0e85c3ce2a39f1ec40d6c5455d876d55069b39c5e062efbf261c18455"
    )
    version(
        "2022.04.04", sha256="264d9b585fa1838b118e50893ce149d76bbf568ee4c27a3732fe0db904de986a"
    )
    version(
        "2022.03.07", sha256="41b2dea4d4a91313987fbad5252cad4a7e1cb3dcef5fbad0a09ea942423f5013"
    )
    version(
        "2022.02.17", sha256="4bc2949453a35699090efc2bb71b8bd2b951909e0f02d0f8c8af255d1668e63f"
    )
    version(
        "2022.02.08", sha256="996275536c990a6d49cd61f207c04ad771a1449506f38507afc35f95b29d4cf1"
    )
    version(
        "2022.01.03", sha256="872a0d152c19864ad543ddcc585ce30baaad4185c2617c13463d780175cbde5f"
    )
    version(
        "2021.12.15", sha256="4bfe9e27412e263ffdc6fcfcb84011f16d34a9fdd633ad7fc84a34c898f67e5c"
    )

    # Configuration variants
    variant(
        "executables",
        values=any_combination_of(
            # CCE
            "CharacteristicExtract",
            "ReduceCceWorldtube",
            # Elliptic / initial data
            "SolvePoisson1D",
            "SolvePoisson2D",
            "SolvePoisson3D",
            "SolveElasticity2D",
            "SolveElasticity3D",
            "SolveXcts",
            # Tools
            "ExportCoordinates1D",
            "ExportCoordinates2D",
            "ExportCoordinates3D",
        ),
        description="Executables to install",
    )
    variant("python", default=False, description="Build Python bindings")
    variant("doc", default=False, description="Build documentation")
    # Build type and debug symbols:
    # - Both Debug and Release builds have debug symbols enabled by default in
    #   the SpECTRE build system, so we can view backtraces, etc., when
    #   production code fails.
    variant(
        "build_type",
        values=("Debug", "Release"),
        default="Release",
        description="CMake build type",
    )
    # - Allow disabling debug symbols to reduce memory usage and executable size
    variant("debug_symbols", default=True, description="Build with debug symbols")
    variant("shared", default=False, description="Build shared libraries instead of static")
    variant(
        "memory_allocator",
        values=("system", "jemalloc"),
        multi=False,
        default="system",
        description="Which memory allocator to use",
    )
    variant(
        "formaline",
        default=True,
        description=(
            "Write the source tree into simulation output files "
            "to increase reproducibility of results"
        ),
    )
    variant(
        "profiling", default=False, description="Enable options to make profiling SpECTRE easier"
    )

    # Compiler support
    conflicts("%gcc@:6")
    conflicts("%clang@:7")
    conflicts("%apple-clang@:10")

    # Build dependencies
    depends_on("cmake@3.12:", type="build")
    depends_on("python@2.7:", type="build")

    # Link dependencies
    depends_on("charmpp@6.10.2:")
    depends_on("blaze@3.8")
    depends_on("boost@1.60:+math+program_options")
    depends_on("brigand@master")
    depends_on("gsl")
    depends_on("hdf5")
    depends_on("jemalloc", when="memory_allocator=jemalloc")
    depends_on("libsharp~mpi~openmp")
    depends_on("libxsmm@1.16.1:")
    depends_on("blas")
    depends_on("lapack")
    depends_on("yaml-cpp@0.6:")

    # Test dependencies
    depends_on("catch2@2.8:", type="test")
    depends_on("py-numpy@1.10:", type="test")
    depends_on("py-scipy", type="test")
    depends_on("py-h5py", type="test")

    # Python bindings
    with when("+python"):
        extends("python")
        depends_on("python@3.7:", type=("build", "run"))
        depends_on("py-pybind11@2.6:", type="build")
        depends_on("py-numpy@1.10:", type=("build", "run"))
        depends_on("py-scipy", type=("build", "run"))
        depends_on("py-matplotlib", type=("build", "run"))
        depends_on("py-h5py", type=("build", "run"))

    # Docs
    with when("+doc"):
        depends_on("doxygen", type="build")
        depends_on("perl", type="build", when="@2022.03.07:")
        depends_on("py-beautifulsoup4", type="build")
        depends_on("py-pybtex", type="build")
        depends_on("py-nbconvert", type="build", when="@2022.03.07:")

    # Incompatibilities
    # - Shared libs builds on macOS don't work before
    #   https://github.com/sxs-collaboration/spectre/pull/2680
    conflicts("+shared", when="@:2022.01.03 platform=darwin")
    # - Blaze with `BLAZE_BLAS_MODE` enabled doesn't work before
    #   https://github.com/sxs-collaboration/spectre/pull/3806 because it
    #   doesn't find the BLAS header. Also, we haven't tested Blaze with BLAS
    #   kernels before then.
    conflicts("^blaze+blas", when="@:2022.02.17")

    # Patch Charm++ v7.0.0 for Python bindings (see
    # https://github.com/sxs-collaboration/spectre/pull/3942 and
    # https://github.com/UIUC-PPL/charm/issues/3600)
    depends_on(
        "charmpp@6.10.2:",
        patches=patch(
            "https://raw.githubusercontent.com/sxs-collaboration/spectre/develop/support/Charm/v7.0.0.patch",
            sha256="576c745de202f030275aaeb3c6206f7ebdda696385353e0d1417ed7c47b856ca",
            when="@7.0.0",
        ),
        when="@2022.06.14: +python platform=linux",
    )

    # These patches backport updates to the SpECTRE build system to earlier
    # releases, to support installing them with Spack. In particular, we try to
    # support releases associated with published papers, so their results are
    # reproducible.
    # - Backport installation of targets, based on upstream patch:
    #   https://github.com/sxs-collaboration/spectre/commit/fe3514117c8205dbf18c4d42ec17712e67d33251
    patch("install-pre-2022.01.03.patch", when="@:2022.01.03")
    # - Backport experimental support for Charm++ v7+
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/a2203824ef38ec79a247703ae8cd215befffe391.patch?full_index=1",
        sha256="e1b22e5ebeb814c07f4aff690b7b4f3a7ba1f06ea4bc91468c68637521a458a7",
        when="@:2022.01.03 ^charmpp@7.0.0:",
    )
    # - Backport IWYU toggle to avoid CMake configuration issues
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/cffeba1bc24bf7c00ec8bac710f02d3db36fa111.patch?full_index=1",
        sha256="a3752024b743aeba6f7a53d26bf583e1e46adbd08a2e6f74470a777dde7b2dff",
        when="@:2022.01.03",
    )
    # - Backport patch for Boost 1.77
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/001fc190a6ec73ad6c19ada9444d04a2320f2b96.patch?full_index=1",
        sha256="96b3a3cb49ee30206eb70d1160feda84b7e7b4e1c7dd81ba7138b5c4fa718622",
        when="@:2022.01.03 ^boost@1.77:",
    )
    # - Backport patch for Python 3.10 in tests
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/82ff2c39cdae0ecc1e42bdf4564506a4ca869818.patch?full_index=1",
        sha256="36cdb5e48f6b49306709057e5e6ca37a44258ad6ecf918c1e87a71d7121e36ba",
        when="@:2022.01.03 ^python@3.10:",
    )
    # - Backport patch for hdf5+mpi
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/eb887635f5e2b394ae2c7e96170e9d907eb315cf.patch?full_index=1",
        sha256="ccc4631541d6aca996ced358a3ee43d3f8b8eb62fd7bec4534685445688d4d84",
        when="@:2022.01.03 ^hdf5+mpi",
    )
    # - Backport `BUILD_TESTING` toggle, based on upstream patch:
    #   https://github.com/sxs-collaboration/spectre/commit/79bed6cad6e95efadf48a5846f389e90801202d4
    patch("build-testing-pre-2022.01.03.patch", when="@:2022.01.03")
    # - Backport `PYTHONPATH` in CTest environment
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/ada1d15d5963bd22581dd8966599e1529a99645d.patch?full_index=1",
        sha256="6ae3d5b08bd3f0e743e1043c9363e32db2a4f9c549eb958ff989f1e7f3078f6c",
        when="@:2022.01.03",
    )
    # - Backport executable name CTest labels
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/1b61e62a27b02b658cc6a74c4d46af1f5b5d0a4d.patch?full_index=1",
        sha256="aeb41c30dd7a8bf61b79efbb79cfa81372cfc2e870a2b494fc583a8bd554c703",
        when="@:2022.01.03",
    )
    # - Backport fix for PCH builds with Spack
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/4bb3f25f905f83d8295a28a8036f6971dc4e75a2.patch?full_index=1",
        sha256="6e8ec4584b6b03866594d0744c041012c68f6b2382abaa9abeec39cd2f2a6480",
        when="@:2022.01.03",
    )
    # - Backport installation of shared libs
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/b7c54a2a20c6d62aae6b1c97e3468d4cd39ed6ad.patch?full_index=1",
        sha256="5ce050c73bab007c0bea9c1f4ae4fb5cd5abab820eeb89cf6cb81f8856d07c30",
        when="@:2022.01.03 +shared",
    )
    # - Fix an issue with Boost pre v1.67
    patch(
        "https://github.com/sxs-collaboration/spectre/commit/b229e939f15362aca892d4480a9182daf88305d4.patch?full_index=1",
        sha256="87811b73d72d60cf82cd85e464b42843add50c3be858c7c8272936aeb8574933",
        when="@2022.02.08 ^boost@:1.66",
    )

    def cmake_args(self):
        args = [
            self.define("CHARM_ROOT", self.spec["charmpp"].prefix),
            self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
            self.define("Python_EXECUTABLE", self.spec["python"].command.path),
            self.define_from_variant("BUILD_PYTHON_BINDINGS", "python"),
            self.define("BUILD_TESTING", self.run_tests),
            self.define_from_variant("BUILD_DOCS", "doc"),
            self.define("USE_GIT_HOOKS", False),
            self.define("USE_IWYU", False),
            self.define_from_variant("USE_FORMALINE", "formaline"),
            self.define_from_variant("MEMORY_ALLOCATOR").upper(),
            self.define_from_variant("ENABLE_PROFILING", "profiling"),
            self.define("USE_PCH", True),
            self.define_from_variant("DEBUG_SYMBOLS"),
        ]
        # Allow for more time on slower machines
        if self.run_tests:
            if self.spec.satisfies("@:2022.01.03"):
                args.extend(
                    [
                        self.define("SPECTRE_INPUT_FILE_TEST_TIMEOUT_FACTOR", "10"),
                        self.define("SPECTRE_UNIT_TEST_TIMEOUT_FACTOR", "10"),
                        self.define("SPECTRE_PYTHON_TEST_TIMEOUT_FACTOR", "10"),
                    ]
                )
            else:
                args.append(self.define("SPECTRE_TEST_TIMEOUT_FACTOR", "10"))
        return args

    @property
    def build_targets(self):
        spec = self.spec
        targets = list(self.spec.variants["executables"].value)
        if "none" in targets:
            targets.remove("none")
        if "+python" in spec:
            targets.append("all-pybindings")
        if "+doc" in spec:
            targets.append("doc")
        if self.run_tests:
            targets.append("unit-tests")
        if len(targets) == 0:
            raise InstallError(
                "Specify at least one target to build. See "
                "'spack info spectre' for available targets."
            )
        return targets

    @run_after("install")
    def install_docs(self):
        if "+doc" in self.spec:
            with working_dir(self.build_directory):
                install_tree(join_path("docs", "html"), self.prefix.docs)

    @property
    def archive_files(self):
        # Archive the `BuildInfo.txt` file for debugging builds
        return super().archive_files + [join_path(self.build_directory, "BuildInfo.txt")]

    def check(self):
        with working_dir(self.build_directory):
            # The test suite contains a lot of tests. We select only those
            # related to the targets that were specified.
            # - Unit tests
            ctest("--output-on-failure", "-L", "unit")
            # - Input file tests for the specified executables
            for executable in self.spec.variants["executables"].value:
                if executable == "none":
                    continue
                ctest("--output-on-failure", "-L", executable)