summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/exasp2/package.py
blob: cae46bb055e27b2f7a5ba7faaf3f4acf2154cdb8 (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
##############################################################################
# Copyright (c) 2017, Los Alamos National Security, LLC
# Produced at the Los Alamos National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *


class Exasp2(MakefilePackage):
    """ExaSP2 is a reference implementation of typical linear algebra algorithms
    and workloads for a quantum molecular dynamics (QMD) electronic structure
    code. The algorithm is based on a recursive second-order Fermi-Operator
    expansion method (SP2) and is tailored for density functional based
    tight-binding calculations of material systems. The SP2 algorithm variants
    are part of the Los Alamos Transferable Tight-binding for Energetics
    (LATTE) code, based on a matrix expansion of the Fermi operator in a
    recursive series of generalized matrix-matrix multiplications. It is
    created and maintained by Co-Design Center for Particle Applications
    (CoPA). The code is intended to serve as a vehicle for co-design by
    allowing others to extend and/or reimplement as needed to test performance
    of new architectures, programming models, etc."""

    tags = ['proxy-app']

    homepage = "https://github.com/ECP-copa/ExaSP2"

    version('develop', git='https://github.com/ECP-copa/ExaSP2',
            branch='master')

    variant('mpi', default=True, description='Build With MPI Support')

    depends_on('bml')
    depends_on('blas')
    depends_on('lapack')
    depends_on('mpi', when='+mpi')
    depends_on('bml@1.2.3:+mpi', when='+mpi')

    build_directory = 'src'

    @property
    def build_targets(self):
        targets = []
        spec = self.spec
        if '+mpi' in spec:
            targets.append('PARALLEL=MPI')
            targets.append('MPICC={0}'.format(spec['mpi'].mpicc))
            targets.append('MPI_LIB=-L' + spec['mpi'].prefix.lib + ' -lmpi')
            targets.append('MPI_INCLUDE=-I' + spec['mpi'].prefix.include)
        else:
            targets.append('PARALLEL=NONE')
        # NOTE: no blas except for mkl has been properly tested. OpenBlas was
        #   briefly but not rigoruously tested. Using generic blas approach to
        #   meet Spack requirements
        targets.append('BLAS=GENERIC_SPACKBLAS')
        math_libs = str(spec['lapack'].libs)
        math_libs += ' ' + str(spec['lapack'].libs)
        targets.append('SPACKBLASLIBFLAGS=' + math_libs)
        math_includes = spec['lapack'].prefix.include
        math_includes += " -I" + spec['blas'].prefix.include
        targets.append('SPACKBLASINCLUDES=' + math_includes)
        # And BML
        bmlLibDirs = spec['bml'].libs.directories[0]
        targets.append('BML_PATH=' + bmlLibDirs)
        targets.append('--file=Makefile.vanilla')
        return targets

    def install(self, spec, prefix):
        mkdir(prefix.bin)
        mkdir(prefix.doc)
        if '+mpi' in self.spec:
            install('bin/ExaSP2-parallel', prefix.bin)
        else:
            install('bin/ExaSP2-serial', prefix.bin)
        install('LICENSE.md', prefix.doc)
        install('README.md', prefix.doc)