summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/hpgmg/package.py
blob: 3a5208493f5df94042f0297616911eb0eaf5dfd1 (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 (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore 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/spack/spack
# Please also see the LICENSE file 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 Hpgmg(Package):
    """HPGMG implements full multigrid (FMG) algorithms using
    finite-volume and finite-element methods.
    Different algorithmic variants adjust the arithmetic intensity
    and architectural properties that are tested. These FMG methods
    converge up to discretization error in one F-cycle,
    thus may be considered direct solvers. An F-cycle visits
    the finest level a total of two times,
    the first coarsening (8x smaller) 4 times,
    the second coarsening 6 times, etc."""

    homepage = "https://bitbucket.org/hpgmg/hpgmg"
    url      = "https://hpgmg.org/static/hpgmg-0.tar.gz"
    tags     = ['proxy-app']

    version('a0a5510df23b', 'b9c50f25e541428d4735fb07344d1d0ed9fc821bdde918d8e0defa78c0d9b4f9')
    version('develop', git='https://bitbucket.org/hpgmg/hpgmg.git', branch='master')

    variant(
        'fe', default=False, description='Build finite element solver')
    variant(
        'fv', default='mpi', values=('serial', 'mpi', 'none'),
        description='Build finite volume solver with or without MPI support')
    variant('cuda', default=False, description='Build with CUDA')
    variant('debug', default=False, description='Build in debug mode')

    depends_on('petsc', when='+fe')
    depends_on('mpi', when='+fe')
    depends_on('mpi', when='fv=mpi')
    depends_on('cuda', when='+cuda')
    depends_on('python', type='build')

    phases = ['configure', 'build', 'install']

    def configure_args(self):
        args = []
        if '+fe' in self.spec:
            args.append('--fe')

        if 'fv=serial' in self.spec:
            args.append('--no-fv-mpi')

        if 'mpi' in self.spec:
            args.append('--CC={0}'.format(self.spec['mpi'].mpicc))

        cflags = []
        if 'fv=none' in self.spec:
            args.append('--no-fv')
        else:
            cflags.append(self.compiler.openmp_flag)

        if '+debug' in self.spec:
            cflags.append('-g')
        elif any(map(self.spec.satisfies, ['%gcc', '%clang', '%intel'])):
            cflags += ['-O3', '-march=native']

        args.append('--CFLAGS=' + ' '.join(cflags))

        return args

    def configure(self, spec, prefix):
        configure(*self.configure_args())

    def build(self, spec, prefix):
        make()

    def install(self, spec, prefix):
        install_tree('build/bin', prefix.bin)
        install('README.md', prefix)
        install('LICENSE', prefix)