2016-05-12 12:22:25 +08:00
|
|
|
##############################################################################
|
2018-03-25 03:13:52 +08:00
|
|
|
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
|
2016-05-12 12:22:25 +08:00
|
|
|
# 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
|
|
|
|
#
|
2017-11-05 08:08:04 +08:00
|
|
|
# For details, see https://github.com/spack/spack
|
2017-06-25 13:22:55 +08:00
|
|
|
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
##############################################################################
|
2015-05-28 08:39:17 +08:00
|
|
|
from spack import *
|
2016-07-16 13:58:51 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2015-05-28 08:39:17 +08:00
|
|
|
|
|
|
|
class Hypre(Package):
|
2015-06-07 08:20:33 +08:00
|
|
|
"""Hypre is a library of high performance preconditioners that
|
|
|
|
features parallel multigrid methods for both structured and
|
|
|
|
unstructured grid problems."""
|
2015-05-28 08:39:17 +08:00
|
|
|
|
2015-11-24 05:00:10 +08:00
|
|
|
homepage = "http://computation.llnl.gov/project/linear_solvers/software.php"
|
2018-07-23 15:00:15 +08:00
|
|
|
url = "https://github.com/LLNL/hypre/archive/v2.14.0.tar.gz"
|
|
|
|
git = "https://github.com/LLNL/hypre.git"
|
2015-05-28 08:39:17 +08:00
|
|
|
|
2018-07-23 15:00:15 +08:00
|
|
|
version('develop', branch='master')
|
|
|
|
version('2.14.0', 'ecde5cc807ec45bfb647e9f28d2eaea1')
|
|
|
|
version('2.13.0', '4b688a5c15b6b5e3de5e045ae081b89b')
|
|
|
|
version('2.12.1', 'c6fcb6d7e57cec1c7ce4a44da885068c')
|
2017-03-26 15:32:49 +08:00
|
|
|
version('2.11.2', 'd507943a1a3ce5681c3308e2f3a6dd34')
|
2016-10-18 22:38:15 +08:00
|
|
|
version('2.11.1', '3f02ef8fd679239a6723f60b7f796519')
|
2016-03-09 13:18:20 +08:00
|
|
|
version('2.10.1', 'dc048c4cabb3cd549af72591474ad674')
|
2015-05-28 08:39:17 +08:00
|
|
|
version('2.10.0b', '768be38793a35bb5d055905b271f5b8e')
|
2018-07-23 15:00:15 +08:00
|
|
|
version('xsdk-0.2.0', tag='xsdk-0.2.0')
|
2015-05-28 08:39:17 +08:00
|
|
|
|
2016-03-23 02:17:39 +08:00
|
|
|
# hypre does not know how to build shared libraries on Darwin
|
2016-08-10 16:50:00 +08:00
|
|
|
variant('shared', default=(sys.platform != 'darwin'),
|
|
|
|
description="Build shared library (disables static library)")
|
2016-03-28 23:49:20 +08:00
|
|
|
# SuperluDist have conflicting headers with those in Hypre
|
2016-08-10 16:50:00 +08:00
|
|
|
variant('internal-superlu', default=True,
|
|
|
|
description="Use internal Superlu routines")
|
2017-01-16 18:23:07 +08:00
|
|
|
variant('int64', default=False,
|
|
|
|
description="Use 64bit integers")
|
2017-10-25 09:53:12 +08:00
|
|
|
variant('mpi', default=True, description='Enable MPI support')
|
2018-09-15 06:53:06 +08:00
|
|
|
variant('debug', default=False,
|
|
|
|
description='Build debug instead of optimized version')
|
2017-03-26 15:32:49 +08:00
|
|
|
|
2017-03-01 03:24:43 +08:00
|
|
|
# Patch to add ppc64le in config.guess
|
2017-03-26 15:32:49 +08:00
|
|
|
patch('ibm-ppc64le.patch', when='@:2.11.1')
|
2016-03-09 13:18:20 +08:00
|
|
|
|
2017-10-25 09:53:12 +08:00
|
|
|
depends_on("mpi", when='+mpi')
|
2015-05-28 08:39:17 +08:00
|
|
|
depends_on("blas")
|
|
|
|
depends_on("lapack")
|
|
|
|
|
2018-07-23 15:00:15 +08:00
|
|
|
def url_for_version(self, version):
|
|
|
|
if version >= Version('2.12.0'):
|
|
|
|
url = 'https://github.com/LLNL/hypre/archive/v{0}.tar.gz'
|
|
|
|
else:
|
|
|
|
url = 'http://computation.llnl.gov/project/linear_solvers/download/hypre-{0}.tar.gz'
|
|
|
|
|
|
|
|
return url.format(version)
|
|
|
|
|
2015-05-28 08:39:17 +08:00
|
|
|
def install(self, spec, prefix):
|
2016-07-16 13:28:31 +08:00
|
|
|
# Note: --with-(lapack|blas)_libs= needs space separated list of names
|
2017-03-03 02:01:29 +08:00
|
|
|
lapack = spec['lapack'].libs
|
|
|
|
blas = spec['blas'].libs
|
2016-09-22 03:27:59 +08:00
|
|
|
|
2016-03-09 13:18:20 +08:00
|
|
|
configure_args = [
|
2016-07-16 13:28:31 +08:00
|
|
|
'--prefix=%s' % prefix,
|
2016-09-24 01:06:18 +08:00
|
|
|
'--with-lapack-libs=%s' % ' '.join(lapack.names),
|
2016-10-11 21:48:16 +08:00
|
|
|
'--with-lapack-lib-dirs=%s' % ' '.join(lapack.directories),
|
2016-09-24 01:06:18 +08:00
|
|
|
'--with-blas-libs=%s' % ' '.join(blas.names),
|
2016-10-11 21:48:16 +08:00
|
|
|
'--with-blas-lib-dirs=%s' % ' '.join(blas.directories)
|
2016-07-16 13:28:31 +08:00
|
|
|
]
|
|
|
|
|
2017-10-25 09:53:12 +08:00
|
|
|
if '+mpi' in self.spec:
|
|
|
|
os.environ['CC'] = spec['mpi'].mpicc
|
|
|
|
os.environ['CXX'] = spec['mpi'].mpicxx
|
|
|
|
os.environ['F77'] = spec['mpi'].mpif77
|
|
|
|
configure_args.append('--with-MPI')
|
|
|
|
else:
|
|
|
|
configure_args.append('--without-MPI')
|
|
|
|
|
2017-01-16 18:23:07 +08:00
|
|
|
if '+int64' in self.spec:
|
|
|
|
configure_args.append('--enable-bigint')
|
|
|
|
|
2016-03-09 13:18:20 +08:00
|
|
|
if '+shared' in self.spec:
|
|
|
|
configure_args.append("--enable-shared")
|
2015-05-28 08:39:17 +08:00
|
|
|
|
2016-03-28 23:49:20 +08:00
|
|
|
if '~internal-superlu' in self.spec:
|
|
|
|
configure_args.append("--without-superlu")
|
2016-03-29 15:41:57 +08:00
|
|
|
# MLI and FEI do not build without superlu on Linux
|
|
|
|
configure_args.append("--without-mli")
|
|
|
|
configure_args.append("--without-fei")
|
2016-03-28 23:49:20 +08:00
|
|
|
|
2018-09-15 06:53:06 +08:00
|
|
|
if '+debug' in self.spec:
|
|
|
|
configure_args.append("--enable-debug")
|
|
|
|
else:
|
|
|
|
configure_args.append("--disable-debug")
|
|
|
|
|
2015-06-07 08:20:33 +08:00
|
|
|
# Hypre's source is staged under ./src so we'll have to manually
|
2015-05-28 08:39:17 +08:00
|
|
|
# cd into it.
|
2015-06-07 08:20:33 +08:00
|
|
|
with working_dir("src"):
|
2016-03-09 13:18:20 +08:00
|
|
|
configure(*configure_args)
|
|
|
|
|
2015-06-07 08:20:33 +08:00
|
|
|
make()
|
2016-07-16 13:28:31 +08:00
|
|
|
if self.run_tests:
|
|
|
|
make("check")
|
|
|
|
make("test")
|
|
|
|
Executable(join_path('test', 'ij'))()
|
|
|
|
sstruct = Executable(join_path('test', 'struct'))
|
|
|
|
sstruct()
|
|
|
|
sstruct('-in', 'test/sstruct.in.default', '-solver', '40',
|
|
|
|
'-rhsone')
|
2015-06-07 08:20:33 +08:00
|
|
|
make("install")
|
2018-02-14 16:21:13 +08:00
|
|
|
|
2018-03-23 08:43:23 +08:00
|
|
|
@property
|
|
|
|
def headers(self):
|
|
|
|
"""Export the main hypre header, HYPRE.h; all other headers can be found
|
|
|
|
in the same directory.
|
|
|
|
Sample usage: spec['hypre'].headers.cpp_flags
|
|
|
|
"""
|
|
|
|
hdrs = find_headers('HYPRE', self.prefix.include, recursive=False)
|
|
|
|
return hdrs or None
|
|
|
|
|
2018-02-14 16:21:13 +08:00
|
|
|
@property
|
|
|
|
def libs(self):
|
2018-03-23 08:43:23 +08:00
|
|
|
"""Export the hypre library.
|
|
|
|
Sample usage: spec['hypre'].libs.ld_flags
|
|
|
|
"""
|
|
|
|
search_paths = [[self.prefix.lib, False], [self.prefix.lib64, False],
|
|
|
|
[self.prefix, True]]
|
|
|
|
is_shared = '+shared' in self.spec
|
|
|
|
for path, recursive in search_paths:
|
|
|
|
libs = find_libraries('libHYPRE', root=path,
|
|
|
|
shared=is_shared, recursive=recursive)
|
|
|
|
if libs:
|
|
|
|
return libs
|
|
|
|
return None
|