summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/cray-libsci/package.py
blob: ad24e669c2d3a2e3e15803a5f93128b6d30bf055 (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
# 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 *
from spack.util.module_cmd import get_path_args_from_module_line, module


class CrayLibsci(Package):
    """The Cray Scientific Libraries package, LibSci, is a collection of
    numerical routines optimized for best performance on Cray systems."""

    homepage = "https://docs.nersc.gov/development/libraries/libsci/"
    has_code = False  # Skip attempts to fetch source that is not available

    version("21.08.1.2")
    version("20.06.1")
    version("20.03.1")
    version("19.06.1")
    version("18.12.1")
    version("18.11.1.2")
    version("16.11.1")
    version("16.09.1")
    version("16.07.1")
    version("16.06.1")
    version("16.03.1")

    variant("shared", default=True, description="enable shared libs")
    variant("openmp", default=False, description="link with openmp")
    variant("mpi", default=False, description="link with mpi libs")

    provides("blas")
    provides("lapack")
    provides("scalapack", when="+mpi")

    canonical_names = {
        "gcc": "GNU",
        "cce": "CRAY",
        "intel": "INTEL",
        "clang": "ALLINEA",
        "aocc": "AOCC",
        "nvhpc": "NVIDIA",
        "rocmcc": "AMD",
    }

    @property
    def modname(self):
        return "cray-libsci/{0}".format(self.version)

    @property
    def external_prefix(self):
        libsci_module = module("show", self.modname).splitlines()

        for line in libsci_module:
            if "CRAY_LIBSCI_PREFIX_DIR" in line:
                return get_path_args_from_module_line(line)[0]

    @property
    def blas_libs(self):
        shared = True if "+shared" in self.spec else False
        compiler = self.spec.compiler.name

        lib = []
        if "+openmp" in self.spec and "+mpi" in self.spec:
            lib = ["libsci_{0}_mpi_mp", "libsci_{0}_mp"]
        elif "+openmp" in self.spec:
            lib = ["libsci_{0}_mp"]
        elif "+mpi" in self.spec:
            lib = ["libsci_{0}_mpi", "libsci_{0}"]
        else:
            lib = ["libsci_{0}"]

        libname = []
        for lib_fmt in lib:
            libname.append(lib_fmt.format(self.canonical_names[compiler].lower()))

        return find_libraries(libname, root=self.prefix.lib, shared=shared, recursive=False)

    @property
    def lapack_libs(self):
        return self.blas_libs

    @property
    def scalapack_libs(self):
        return self.blas_libs

    @property
    def libs(self):
        return self.blas_libs

    def install(self, spec, prefix):
        raise InstallError(
            self.spec.format(
                "{name} is not installable, you need to specify "
                "it as an external package in packages.yaml"
            )
        )