summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/superlu-dist/package.py
blob: 28aff2ffdf7206d1a5517ba4a50d59939a77b198 (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
# Copyright 2013-2022 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 SuperluDist(CMakePackage, CudaPackage, ROCmPackage):
    """A general purpose library for the direct solution of large, sparse,
    nonsymmetric systems of linear equations on high performance machines."""

    homepage = "https://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
    url      = "https://github.com/xiaoyeli/superlu_dist/archive/v6.0.0.tar.gz"
    git      = "https://github.com/xiaoyeli/superlu_dist.git"

    tags = ['e4s']

    maintainers = ['xiaoye', 'gchavez2', 'balay', 'pghysels', 'liuyangzhuan']

    version('develop', branch='master')
    version('amd', branch='amd')
    version('7.2.0', sha256='20b60bd8a3d88031c9ce6511ae9700b7a8dcf12e2fd704e74b1af762b3468b8c')
    version('7.1.1', sha256='558053b3d4a56eb661c4f04d4fcab6604018ce5db97115394c161b56c9c278ff')
    version('7.1.0', sha256='edbea877562be95fb22c7de1ff484f18685bec4baa8e4f703c414d3c035d4a66')
    version('6.4.0', sha256='cb9c0b2ba4c28e5ed5817718ba19ae1dd63ccd30bc44c8b8252b54f5f04a44cc')
    version('6.3.1', sha256='3787c2755acd6aadbb4d9029138c293a7570a2ed228806676edcc7e1d3f5a1d3')
    version('6.3.0', sha256='daf3264706caccae2b8fd5a572e40275f1e128fa235cb7c21ee2f8051c11af95')
    version('6.2.0', sha256='15ad1badd81b41e37941dd124d06d3b92e51c4f0ff532ad23fb09c4ebfe6eb9e')
    version('6.1.1', sha256='35d25cff592c724439870444ed45e1d1d15ca2c65f02ccd4b83a6d3c9d220bd1')
    version('6.1.0', sha256='92c6d1424dd830ee2d1e7396a418a5f6645160aea8472e558c4e4bfe006593c4')
    version('6.0.0', sha256='ff6cdfa0263d595708bbb6d11fb780915d8cfddab438db651e246ea292f37ee4')
    version('5.4.0', sha256='3ac238fe082106a2c4dbaf0c22af1ff1247308ffa8f053de9d78c3ec7dd0d801')
    version('5.3.0', sha256='49ed110bdef1e284a0181d6c7dd1fae3aa110cb45f67c6aa5cb791070304d670')
    version('5.2.2', sha256='65cfb9ace9a81f7affac4ad92b9571badf0f10155b3468531b0fffde3bd8e727')
    version('5.2.1', sha256='67cf3c46cbded4cee68e2a9d601c30ab13b08091c8cdad95b0a8e018b6d5d1f1')
    version('5.1.3', sha256='58e3dfdb4ae6f8e3f6f3d5ee5e851af59b967c4483cdb3b15ccd1dbdf38f44f9')
    version('5.1.2', sha256='e34865ad6696ee6a6d178b4a01c8e19103a7d241ba9de043603970d63b0ee1e2')
    version('5.1.0', sha256='73f292ab748b590b6dd7469e6986aeb95d279b8b8b3da511c695a396bdbc996c')
    version('5.0.0', sha256='78d1d6460ff16b3f71e4bcd7306397574d54d421249553ccc26567f00a10bfc6')

    variant('int64', default=False, description='Build with 64 bit integers')
    variant('openmp', default=False, description='Build with OpenMP support (needs a good multithreaded BLAS implementation for good performance)')
    variant('shared', default=True, description='Build shared libraries')

    depends_on('mpi')
    depends_on('blas')
    depends_on('lapack')
    depends_on('parmetis')
    depends_on('metis@5:')
    depends_on('cmake@3.18.1:', type='build', when='@7.1.0:')
    depends_on('hipblas', when='+rocm')
    depends_on('rocsolver', when='+rocm')

    conflicts('+rocm', when='+cuda')
    conflicts('+cuda', when='@:6.3')
    # See https://github.com/xiaoyeli/superlu_dist/issues/87
    conflicts('^cuda@11.5.0:', when='@7.1.0:7.1 +cuda')

    patch('xl-611.patch', when='@:6.1.1 %xl')
    patch('xl-611.patch', when='@:6.1.1 %xl_r')
    patch('superlu-cray-ftn-case.patch', when='@7.1.1 %cce')
    patch('CMAKE_INSTALL_LIBDIR.patch', when='@7.0.0:7.2.0')

    def cmake_args(self):
        spec = self.spec
        cmake_args = []

        def append_define(*args):
            cmake_args.append(CMakePackage.define(*args))

        def append_from_variant(*args):
            cmake_args.append(self.define_from_variant(*args))

        append_define('CMAKE_C_COMPILER', spec['mpi'].mpicc)
        append_define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx)
        append_define('CMAKE_INSTALL_LIBDIR:STRING', self.prefix.lib)
        append_define('CMAKE_INSTALL_BINDIR:STRING', self.prefix.bin)
        append_define('TPL_BLAS_LIBRARIES', spec['blas'].libs)
        append_define('TPL_LAPACK_LIBRARIES', spec['lapack'].libs)
        append_define('TPL_ENABLE_LAPACKLIB', True)
        append_define('USE_XSDK_DEFAULTS', True)
        append_define('TPL_PARMETIS_LIBRARIES', [
            spec['parmetis'].libs.ld_flags,
            spec['metis'].libs.ld_flags
        ])
        append_define('TPL_PARMETIS_INCLUDE_DIRS', [
            spec['parmetis'].prefix.include,
            spec['metis'].prefix.include
        ])

        if ((spec.satisfies('%xl') or spec.satisfies('%xl_r'))
                and spec.satisfies('@:6.1.1')):
            append_define('CMAKE_C_FLAGS', '-DNoChange')

        append_define('XSDK_INDEX_SIZE', '64' if '+int64' in spec else '32')

        append_from_variant('enable_openmp', 'openmp')
        if '~openmp' in spec:
            append_define('CMAKE_DISABLE_FIND_PACKAGE_OpenMP', True)

        if '+cuda' in spec:
            append_define('TPL_ENABLE_CUDALIB', True)
            append_define(
                'TPL_CUDA_LIBRARIES',
                '-L%s -lcublas -lcudart' % spec['cuda'].libs.directories[0]
            )
            cuda_arch = spec.variants['cuda_arch'].value
            if cuda_arch[0] != 'none':
                append_define('CMAKE_CUDA_FLAGS', '-arch=sm_' + cuda_arch[0])

        if '+rocm' in spec and spec.satisfies('@amd'):
            append_define('TPL_ENABLE_HIPLIB', True)
            append_define('HIP_ROOT_DIR', spec['hip'].prefix)
            rocm_archs = spec.variants['amdgpu_target'].value
            if 'none' not in rocm_archs:
                append_define('HIP_HIPCC_FLAGS',
                              '--amdgpu-target=' + ",".join(rocm_archs))

        append_from_variant('BUILD_SHARED_LIBS', 'shared')
        return cmake_args

    def flag_handler(self, name, flags):
        flags = list(flags)
        if name == 'cxxflags':
            flags.append(self.compiler.cxx11_flag)
        if name == 'cflags' and '%pgi' not in self.spec:
            flags.append('-std=c99')
        return (None, None, flags)

    examples_src_dir = 'EXAMPLE'

    @run_after('install')
    def cache_test_sources(self):
        """Copy the example matrices after the package is installed to an
        install test subdirectory for use during `spack test run`."""
        self.cache_extra_test_sources([self.examples_src_dir])

    def test(self):
        test_dir = join_path(self.install_test_root, self.examples_src_dir)
        superludriver = join_path(self.prefix.lib, 'EXAMPLE', 'pddrive')
        with working_dir(test_dir, create=False):
            # Smoke test input parameters: -r 2 -c 2 g20.rua
            test_args = ['-n', '4', superludriver, '-r', '2', '-c', '2', 'g20.rua']
            # Find the correct mpirun command
            mpiexe_f = which('srun', 'mpirun', 'mpiexec')
            if mpiexe_f:
                if self.spec.satisfies('@7.2.0:'):
                    self.run_test(mpiexe_f.command, test_args, work_dir='.',
                                  purpose='superlu-dist smoke test')
                else:
                    self.run_test('echo', options=['skip test'], work_dir='.',
                                  purpose='superlu-dist smoke test')