Corrected the shared libraries and tests in mumps package

This commit is contained in:
Nicolas Richart 2016-06-08 14:17:46 +02:00
parent 30e8e77fb6
commit e124c86a4f

View File

@ -23,7 +23,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
from spack import * from spack import *
import os, sys, glob import os
import sys
import glob
import subprocess
class Mumps(Package): class Mumps(Package):
"""MUMPS: a MUltifrontal Massively Parallel sparse direct Solver""" """MUMPS: a MUltifrontal Massively Parallel sparse direct Solver"""
@ -54,6 +58,8 @@ class Mumps(Package):
depends_on('scalapack', when='+mpi') depends_on('scalapack', when='+mpi')
depends_on('mpi', when='+mpi') depends_on('mpi', when='+mpi')
patch('mumps-shared.patch', when='+shared')
# this function is not a patch function because in case scalapack # this function is not a patch function because in case scalapack
# is needed it uses self.spec['scalapack'].fc_link set by the # is needed it uses self.spec['scalapack'].fc_link set by the
# setup_dependent_environment in scalapck. This happen after patch # setup_dependent_environment in scalapck. This happen after patch
@ -116,43 +122,39 @@ def write_makefile_inc(self):
if '+mpi' in self.spec: if '+mpi' in self.spec:
makefile_conf.extend( makefile_conf.extend(
["CC = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpicc'), ["CC = %s" % self.spec['mpi'].mpicc,
"FC = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpif90'), "FC = %s" % self.spec['mpi'].mpif90,
"FL = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpif90'),
"SCALAP = %s" % self.spec['scalapack'].fc_link, "SCALAP = %s" % self.spec['scalapack'].fc_link,
"MUMPS_TYPE = par"]) "MUMPS_TYPE = par"])
else: else:
makefile_conf.extend( makefile_conf.extend(
["CC = cc", ["CC = cc",
"FC = fc", "FC = fc",
"FL = fc",
"MUMPS_TYPE = seq"]) "MUMPS_TYPE = seq"])
# TODO: change the value to the correct one according to the # TODO: change the value to the correct one according to the
# compiler possible values are -DAdd_, -DAdd__ and/or -DUPPER # compiler possible values are -DAdd_, -DAdd__ and/or -DUPPER
makefile_conf.append("CDEFS = -DAdd_") makefile_conf.extend([
'CDEFS = -DAdd_',
'FL = $(FC)',
])
if '+shared' in self.spec: if '+shared' in self.spec:
makefile_conf.append('SHLIBEXT = .%s' % dso_suffix)
if sys.platform == 'darwin': if sys.platform == 'darwin':
# Building dylibs with mpif90 causes segfaults on 10.8 and 10.10. Use gfortran. (Homebrew) makefile_conf.append(
makefile_conf.extend([ 'LDFLAGS = -dynamiclib -Wl,-install_name -Wl,{0}/$(notdir $@) {1}{0} -undefined dynamic_lookup'.format(prefix.lib, self.compiler.fc_rpath_arg)
'LIBEXT=.dylib', )
'AR=%s -dynamiclib -Wl,-install_name -Wl,%s/$(notdir $@) -undefined dynamic_lookup -o ' % (os.environ['FC'],prefix.lib),
'RANLIB=echo'
])
else: else:
makefile_conf.extend([ makefile_conf.append(
'LIBEXT=.so', 'LDFLAGS = -shared {1}{0}'.format(prefix.lib, self.compiler.fc_rpath_arg)
'AR=$(FL) -shared -Wl,-soname -Wl,%s/$(notdir $@) -o' % prefix.lib, )
'RANLIB=echo'
])
else:
makefile_conf.extend([
'LIBEXT = .a',
'AR = ar vr',
'RANLIB = ranlib'
])
makefile_conf.extend([
'LIBEXT = .a',
'AR = ar vr ',
'RANLIB = ranlib'
])
makefile_inc_template = join_path(os.path.dirname(self.module.__file__), makefile_inc_template = join_path(os.path.dirname(self.module.__file__),
'Makefile.inc') 'Makefile.inc')
@ -172,38 +174,44 @@ def install(self, spec, prefix):
# the choice to compile ?examples is to have kind of a sanity # the choice to compile ?examples is to have kind of a sanity
# check on the libraries generated. # check on the libraries generated.
if '+float' in spec: if '+float' in spec:
make_libs.append('sexamples') make_libs.append('s')
if '+complex' in spec: if '+complex' in spec:
make_libs.append('cexamples') make_libs.append('c')
if '+double' in spec: if '+double' in spec:
make_libs.append('dexamples') make_libs.append('d')
if '+complex' in spec: if '+complex' in spec:
make_libs.append('zexamples') make_libs.append('z')
self.write_makefile_inc() self.write_makefile_inc()
# Build fails in parallel make('mumps_lib', parallel=False)
make(*make_libs, parallel=False) make(*make_libs)
install_tree('lib', prefix.lib) install_tree('lib', prefix.lib)
install_tree('include', prefix.include) install_tree('include', prefix.include)
if '~mpi' in spec: if '~mpi' in spec:
lib_dsuffix = '.dylib' if sys.platform == 'darwin' else '.so' install('libseq/libmpiseq.a', prefix.lib)
lib_suffix = lib_dsuffix if '+shared' in spec else '.a' if '+shared' in spec:
install('libseq/libmpiseq%s' % lib_suffix, prefix.lib) install('libseq/libmpiseq.{0}'.format(dso_suffix), prefix.lib)
for f in glob.glob(join_path('libseq','*.h')): install('libseq/mpi.h', prefix.include)
install(f, prefix.include) install('libseq/mpif.h', prefix.include)
# FIXME: extend the tests to mpirun -np 2 (or alike) when build with MPI # FIXME: extend the tests to mpirun -np 2 (or alike) when build with MPI
# FIXME: use something like numdiff to compare blessed output with the current # FIXME: use something like numdiff to compare blessed output with the current
# TODO: test the installed mumps and not the one in stage
for t in make_libs:
make('{0}examples'.format(t))
with working_dir('examples'): with working_dir('examples'):
if '+float' in spec: for t in make_libs:
os.system('./ssimpletest < input_simpletest_real') input_file = 'input_simpletest_{0}'.format(
if '+complex' in spec: 'real' if t in ['s', 'd'] else 'cmplx')
os.system('./csimpletest < input_simpletest_real') with open(input_file) as input:
if '+double' in spec: test = './{0}simpletest'.format(t)
os.system('./dsimpletest < input_simpletest_real') ret = subprocess.call(test,
if '+complex' in spec: stdin=input)
os.system('./zsimpletest < input_simpletest_cmplx') if ret is not 0:
raise RuntimeError(
'The test {0} did not pass'.format(test))