summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/hpcg/package.py
blob: ff03bbf722a1fdc002cd0352e08eece530dbf773 (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
# Copyright 2013-2021 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 import *
import os
import platform


class Hpcg(AutotoolsPackage):
    """HPCG is a software package that performs a fixed number of multigrid
    preconditioned (using a symmetric Gauss-Seidel smoother) conjugate gradient
    (PCG) iterations using double precision (64 bit) floating point values."""

    homepage = "https://www.hpcg-benchmark.org"
    url = "http://www.hpcg-benchmark.org/downloads/hpcg-3.1.tar.gz"
    git = "https://github.com/hpcg-benchmark/hpcg.git"

    version('develop', branch='master')
    version('3.1', sha256='33a434e716b79e59e745f77ff72639c32623e7f928eeb7977655ffcaade0f4a4')

    variant('openmp', default=True, description='Enable OpenMP support')

    patch('https://github.com/hpcg-benchmark/hpcg/commit/e9e0b7e6cae23e1f30dd983c2ce2d3bd34d56f75.patch', sha256='23b9de83042eb7a8207fdddcfa79ae2cc1a17e8e623e2224c7751d7c328ee482', when='%gcc@9:')
    patch('https://github.com/hpcg-benchmark/hpcg/commit/e9e0b7e6cae23e1f30dd983c2ce2d3bd34d56f75.patch', sha256='23b9de83042eb7a8207fdddcfa79ae2cc1a17e8e623e2224c7751d7c328ee482', when='%aocc')

    depends_on('mpi@1.1:')

    arch = '{0}-{1}'.format(platform.system(), platform.processor())
    build_targets = ['arch={0}'.format(arch)]

    def configure(self, spec, prefix):
        CXXFLAGS = '-O3 -ffast-math -ftree-vectorize '
        if '%aocc' not in self.spec:
            CXXFLAGS += ' -ftree-vectorizer-verbose=0 '
        if '+openmp' in self.spec:
            CXXFLAGS += self.compiler.openmp_flag
        config = [
            # Shell
            'SHELL         = /bin/sh',
            'CD            = cd',
            'CP            = cp',
            'LN_S          = ln -fs',
            'MKDIR         = mkdir -p',
            'RM            = /bin/rm -f',
            'TOUCH         = touch',
            # Platform identifier
            'ARCH          = {0}'.format(self.arch),
            # HPCG Directory Structure / HPCG library
            'TOPdir        = {0}'.format(os.getcwd()),
            'SRCdir        = $(TOPdir)/src',
            'INCdir        = $(TOPdir)/src',
            'BINdir        = $(TOPdir)/bin',
            # Message Passing library (MPI)
            'MPinc         = -I{0}'.format(spec['mpi'].prefix.include),
            'MPlib         = -L{0}'.format(spec['mpi'].prefix.lib),
            # HPCG includes / libraries / specifics
            'HPCG_INCLUDES = -I$(INCdir) -I$(INCdir)/$(arch) $(MPinc)',
            'HPCG_LIBS     =',
            'HPCG_OPTS     =',
            'HPCG_DEFS     = $(HPCG_OPTS) $(HPCG_INCLUDES)',
            # Compilers / linkers - Optimization flags
            'CXX           = {0}'.format(spec['mpi'].mpicxx),
            'CXXFLAGS      = $(HPCG_DEFS) {0}'.format(CXXFLAGS),
            'LINKER        = $(CXX)',
            'LINKFLAGS     = $(CXXFLAGS)',
            'ARCHIVER      = ar',
            'ARFLAGS       = r',
            'RANLIB        = echo',
        ]

        # Write configuration options to include file
        with open('setup/Make.{0}'.format(self.arch), 'w') as makefile:
            for var in config:
                makefile.write('{0}\n'.format(var))

    def install(self, spec, prefix):
        # Manual installation
        install_tree('bin', prefix.bin)