From 65f65ec4e47289e15e5d6a25913beb8e6bb4831b Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 20 Jan 2016 10:03:24 +0100 Subject: [PATCH 1/3] Adding MUMPS and ScaLAPACK --- var/spack/packages/mumps/Makefile.inc | 41 ++++++ var/spack/packages/mumps/package.py | 121 ++++++++++++++++++ .../packages/netlib-scalapack/package.py | 43 +++++++ 3 files changed, 205 insertions(+) create mode 100644 var/spack/packages/mumps/Makefile.inc create mode 100644 var/spack/packages/mumps/package.py create mode 100644 var/spack/packages/netlib-scalapack/package.py diff --git a/var/spack/packages/mumps/Makefile.inc b/var/spack/packages/mumps/Makefile.inc new file mode 100644 index 0000000000..4b6696db5c --- /dev/null +++ b/var/spack/packages/mumps/Makefile.inc @@ -0,0 +1,41 @@ +LPORDDIR = $(topdir)/PORD/lib/ +IPORD = -I$(topdir)/PORD/include/ +LPORD = -L$(LPORDDIR) -lpord + +ORDERINGSC = $(ORDERINGSF) +LORDERINGS = $(LMETIS) $(LPORD) $(LSCOTCH) +IORDERINGSF = $(ISCOTCH) +IORDERINGSC = $(IMETIS) $(IPORD) $(ISCOTCH) + +PLAT = +LIBEXT = .a +OUTC = -o +OUTF = -o +RM = /bin/rm -f +AR = ar vr +RANLIB = ranlib + +INCSEQ = -I$(topdir)/libseq +LIBSEQ = -L$(topdir)/libseq -lmpiseq + +INCPAR = +LIBPAR = $(SCALAP) + +LIBOTHERS = -lpthread + +#Preprocessor defs for calling Fortran from C (-DAdd_ or -DAdd__ or -DUPPER) +CDEFS = -DAdd_ + +#Sequential: +ifeq ($(MUMPS_TYPE),seq) +INCS = $(INCSEQ) +LIBS = $(LIBSEQ) +LIBSEQNEEDED = libseqneeded +endif + +#Parallel: +ifeq ($(MUMPS_TYPE),par) +INCS = $(INCPAR) +LIBS = $(LIBPAR) +LIBSEQNEEDED = +endif diff --git a/var/spack/packages/mumps/package.py b/var/spack/packages/mumps/package.py new file mode 100644 index 0000000000..b4e38c02de --- /dev/null +++ b/var/spack/packages/mumps/package.py @@ -0,0 +1,121 @@ +from spack import * +import os + + +class Mumps(Package): + """MUMPS: a MUltifrontal Massively Parallel sparse direct Solver""" + + homepage = "http://mumps.enseeiht.fr" + url = "http://mumps.enseeiht.fr/MUMPS_5.0.1.tar.gz" + + version('5.0.1', 'b477573fdcc87babe861f62316833db0') + + variant('mpi', default=True, description='Activate the compilation of MUMPS with the MPI support') + variant('scotch', default=False, description='Activate Scotch as a possible ordering library') + variant('ptscotch', default=False, description='Activate PT-Scotch as a possible ordering library') + variant('metis', default=False, description='Activate Metis as a possible ordering library') + variant('parmetis', default=False, description='Activate Parmetis as a possible ordering library') + variant('double', default=True, description='Activate dmumps') + variant('float', default=True, description='Activate smumps') + variant('complex', default=True, description='Activate cmumps and/or zmumps') + variant('idx64', default=False, description='Use int64_t/integer*8 as default index type') + variant('double', default=False, description='Use double precision floating point types') + + + depends_on('scotch + esmumps', when='~ptscotch+scotch') + depends_on('scotch + esmumps + mpi', when='+ptscotch') + depends_on('metis', when='~parmetis+metis') + depends_on('parmetis', when="+parmetis") + depends_on('blas') + depends_on('scalapack', when='+mpi') + depends_on('mpi', when='+mpi') + + def patch(self): + if ('+parmetis' in self.spec or '+ptscotch' in self.spec) and '+mpi' not in self.spec: + raise RuntimeError('You cannot use the variants parmetis or ptscotch without mpi') + + makefile_conf = ["LIBBLAS = -L%s -lblas" % self.spec['blas'].prefix.lib] + + orderings = ['-Dpord'] + + if '+ptscotch' in self.spec or '+scotch' in self.spec: + join_lib = ' -l%s' % ('pt' if '+ptscotch' in self.spec else '') + makefile_conf.extend( + ["ISCOTCH = -I%s" % self.spec['scotch'].prefix.include, + "LSCOTCH = -L%s %s%s" % (self.spec['scotch'].prefix.lib, + join_lib, + join_lib.join(['esmumps', 'scotch', 'scotcherr']))]) + orderings.append('-Dscotch') + if '+ptscotch' in self.spec: + orderings.append('-Dptscotch') + + if '+parmetis' in self.spec or '+metis' in self.spec: + libname = 'parmetis' if '+parmetis' in self.spec else 'metis' + makefile_conf.extend( + ["IMETIS = -I%s" % self.spec[libname].prefix.include, + "LMETIS = -L%s -l%s" % (self.spec[libname].prefix.lib, libname)]) + + orderings.append('-Dmetis') + if '+parmetis' in self.spec: + orderings.append('-Dparmetis') + + makefile_conf.append("ORDERINGSF = %s" % (' '.join(orderings))) + + if '+idx64' in self.spec: + makefile_conf.extend( + ['OPTF = -O -DALLOW_NON_INIT %s' % '-fdefault-integer-8' if self.compiler.name == "gcc" else '-i8', + 'OPTL = -O ', + 'OPTC = -O -DINTSIZE64']) + else: + makefile_conf.extend( + ['OPTF = -O -DALLOW_NON_INIT', + 'OPTL = -O ', + 'OPTC = -O ']) + + + if '+mpi' in self.spec: + makefile_conf.extend( + ["CC = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpicc'), + "FC = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpif90'), + "FL = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpif90'), + "SCALAP = %s" % self.spec['scalapack'].fc_link]) + else: + makefile_conf.extend( + ["CC = cc", + "FC = fc", + "FL = fc", + "MUMPS_TYPE = seq"]) + + makefile_inc_template = join_path(os.path.dirname(self.module.__file__), + 'Makefile.inc') + with open(makefile_inc_template, "r") as fh: + makefile_conf.extend(fh.read().split('\n')) + + with working_dir('.'): + with open("Makefile.inc", "w") as fh: + makefile_inc = '\n'.join(makefile_conf) + fh.write(makefile_inc) + + + + def install(self, spec, prefix): + make_libs = [] + + # the coice to compile ?examples is to have kind of a sanity + # check on the libraries generated. + if '+float' in spec: + make_libs.append('sexamples') + if '+complex' in spec: + make_libs.append('cexamples') + + if '+double' in spec: + make_libs.append('dexamples') + if '+complex' in spec: + make_libs.append('zexamples') + + make(*make_libs) + + install_tree('lib', prefix.lib) + install_tree('include', prefix.include) + if '~mpi' in spec: + install('libseq/libmpiseq.a', prefix.lib) diff --git a/var/spack/packages/netlib-scalapack/package.py b/var/spack/packages/netlib-scalapack/package.py new file mode 100644 index 0000000000..69df4d9da7 --- /dev/null +++ b/var/spack/packages/netlib-scalapack/package.py @@ -0,0 +1,43 @@ +from spack import * + +class NetlibScalapack(Package): + """ScaLAPACK is a library of high-performance linear algebra routines for parallel distributed memory machines""" + + homepage = "http://www.netlib.org/scalapack/" + url = "http://www.netlib.org/scalapack/scalapack-2.0.2.tgz" + + version('2.0.2', '2f75e600a2ba155ed9ce974a1c4b536f') + version('2.0.1', '17b8cde589ea0423afe1ec43e7499161') + version('2.0.0', '9e76ae7b291be27faaad47cfc256cbfe') + + variant('shared', default=True, description='Build the shared library version') + + provides('scalapack') + + depends_on('mpi') + depends_on('blas') + depends_on('lapack') + + def install(self, spec, prefix): + options = [ + "-DBUILD_SHARED_LIBS:BOOL=%s" % 'ON' if '+shared' in spec else 'OFF', + "-DBUILD_STATIC_LIBS:BOOL=%s" % 'OFF' if '+shared' in spec else 'ON', + "-DCMAKE_C_FLAGS=-fPIC", + "-DCMAKE_Fortran_FLAGS=-fPIC", + ] + + options.extend(std_cmake_args) + + with working_dir('spack-build', create=True): + cmake('..', *options) + make() + make("install") + + def setup_dependent_environment(self, module, spec, dependent_spec): + # TODO treat OS that are not Linux... + lib_suffix = '.so' if '+shared' in spec['scalapack'] else '.a' + + spec['scalapack'].fc_link = '-L%s -lscalapack' % spec['scalapack'].prefix.lib + spec['scalapack'].cc_link = spec['scalapack'].fc_link + spec['scalapack'].libraries = [join_path(spec['scalapack'].prefix.lib, + 'libscalapack%s' % lib_suffix)] From 974fc65e0f15ac87d2422858d71e0c7624fb7726 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 20 Jan 2016 14:38:55 +0100 Subject: [PATCH 2/3] renaming packages to follow changes on develop --- var/spack/{ => repos/builtin}/packages/mumps/Makefile.inc | 0 var/spack/{ => repos/builtin}/packages/mumps/package.py | 0 .../{ => repos/builtin}/packages/netlib-scalapack/package.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename var/spack/{ => repos/builtin}/packages/mumps/Makefile.inc (100%) rename var/spack/{ => repos/builtin}/packages/mumps/package.py (100%) rename var/spack/{ => repos/builtin}/packages/netlib-scalapack/package.py (100%) diff --git a/var/spack/packages/mumps/Makefile.inc b/var/spack/repos/builtin/packages/mumps/Makefile.inc similarity index 100% rename from var/spack/packages/mumps/Makefile.inc rename to var/spack/repos/builtin/packages/mumps/Makefile.inc diff --git a/var/spack/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py similarity index 100% rename from var/spack/packages/mumps/package.py rename to var/spack/repos/builtin/packages/mumps/package.py diff --git a/var/spack/packages/netlib-scalapack/package.py b/var/spack/repos/builtin/packages/netlib-scalapack/package.py similarity index 100% rename from var/spack/packages/netlib-scalapack/package.py rename to var/spack/repos/builtin/packages/netlib-scalapack/package.py From b71b478a3626ae9e1a0d3b5c7ab9945b5c478200 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 20 Jan 2016 18:31:02 +0100 Subject: [PATCH 3/3] Minor correction to install mumps+mpi --- .../repos/builtin/packages/mumps/Makefile.inc | 3 -- .../repos/builtin/packages/mumps/package.py | 32 +++++++++++++++---- .../packages/netlib-scalapack/package.py | 17 +++++++--- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/var/spack/repos/builtin/packages/mumps/Makefile.inc b/var/spack/repos/builtin/packages/mumps/Makefile.inc index 4b6696db5c..2e6a041878 100644 --- a/var/spack/repos/builtin/packages/mumps/Makefile.inc +++ b/var/spack/repos/builtin/packages/mumps/Makefile.inc @@ -23,9 +23,6 @@ LIBPAR = $(SCALAP) LIBOTHERS = -lpthread -#Preprocessor defs for calling Fortran from C (-DAdd_ or -DAdd__ or -DUPPER) -CDEFS = -DAdd_ - #Sequential: ifeq ($(MUMPS_TYPE),seq) INCS = $(INCSEQ) diff --git a/var/spack/repos/builtin/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py index b4e38c02de..44a37903cc 100644 --- a/var/spack/repos/builtin/packages/mumps/package.py +++ b/var/spack/repos/builtin/packages/mumps/package.py @@ -15,11 +15,10 @@ class Mumps(Package): variant('ptscotch', default=False, description='Activate PT-Scotch as a possible ordering library') variant('metis', default=False, description='Activate Metis as a possible ordering library') variant('parmetis', default=False, description='Activate Parmetis as a possible ordering library') - variant('double', default=True, description='Activate dmumps') - variant('float', default=True, description='Activate smumps') - variant('complex', default=True, description='Activate cmumps and/or zmumps') + variant('double', default=True, description='Activate the compilation of dmumps') + variant('float', default=True, description='Activate the compilation of smumps') + variant('complex', default=True, description='Activate the compilation of cmumps and/or zmumps') variant('idx64', default=False, description='Use int64_t/integer*8 as default index type') - variant('double', default=False, description='Use double precision floating point types') depends_on('scotch + esmumps', when='~ptscotch+scotch') @@ -27,10 +26,16 @@ class Mumps(Package): depends_on('metis', when='~parmetis+metis') depends_on('parmetis', when="+parmetis") depends_on('blas') + depends_on('lapack') depends_on('scalapack', when='+mpi') depends_on('mpi', when='+mpi') - - def patch(self): + + # this function is not a patch function because in case scalapack + # is needed it uses self.spec['scalapack'].fc_link set by the + # setup_dependent_environment in scalapck. This happen after patch + # end before install + # def patch(self): + def write_makefile_inc(self): if ('+parmetis' in self.spec or '+ptscotch' in self.spec) and '+mpi' not in self.spec: raise RuntimeError('You cannot use the variants parmetis or ptscotch without mpi') @@ -61,8 +66,13 @@ def patch(self): makefile_conf.append("ORDERINGSF = %s" % (' '.join(orderings))) + # TODO: test this part, it needs a full blas, scalapack and + # partitionning environment with 64bit integers if '+idx64' in self.spec: makefile_conf.extend( + # the fortran compilation flags most probably are + # working only for intel and gnu compilers this is + # perhaps something the compiler should provide ['OPTF = -O -DALLOW_NON_INIT %s' % '-fdefault-integer-8' if self.compiler.name == "gcc" else '-i8', 'OPTL = -O ', 'OPTC = -O -DINTSIZE64']) @@ -78,7 +88,8 @@ def patch(self): ["CC = %s" % join_path(self.spec['mpi'].prefix.bin, 'mpicc'), "FC = %s" % join_path(self.spec['mpi'].prefix.bin, '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"]) else: makefile_conf.extend( ["CC = cc", @@ -86,6 +97,11 @@ def patch(self): "FL = fc", "MUMPS_TYPE = seq"]) + # TODO: change the value to the correct one according to the + # compiler possible values are -DAdd_, -DAdd__ and/or -DUPPER + makefile_conf.append("CDEFS = -DAdd_") + + makefile_inc_template = join_path(os.path.dirname(self.module.__file__), 'Makefile.inc') with open(makefile_inc_template, "r") as fh: @@ -113,6 +129,8 @@ def install(self, spec, prefix): if '+complex' in spec: make_libs.append('zexamples') + self.write_makefile_inc() + make(*make_libs) install_tree('lib', prefix.lib) diff --git a/var/spack/repos/builtin/packages/netlib-scalapack/package.py b/var/spack/repos/builtin/packages/netlib-scalapack/package.py index 69df4d9da7..5be91c4a40 100644 --- a/var/spack/repos/builtin/packages/netlib-scalapack/package.py +++ b/var/spack/repos/builtin/packages/netlib-scalapack/package.py @@ -9,23 +9,30 @@ class NetlibScalapack(Package): version('2.0.2', '2f75e600a2ba155ed9ce974a1c4b536f') version('2.0.1', '17b8cde589ea0423afe1ec43e7499161') version('2.0.0', '9e76ae7b291be27faaad47cfc256cbfe') - + # versions before 2.0.0 are not using cmake and requires blacs as + # a separated package + variant('shared', default=True, description='Build the shared library version') - + variant('fpic', default=False, description="Build with -fpic compiler option") + provides('scalapack') depends_on('mpi') - depends_on('blas') depends_on('lapack') def install(self, spec, prefix): options = [ "-DBUILD_SHARED_LIBS:BOOL=%s" % 'ON' if '+shared' in spec else 'OFF', "-DBUILD_STATIC_LIBS:BOOL=%s" % 'OFF' if '+shared' in spec else 'ON', - "-DCMAKE_C_FLAGS=-fPIC", - "-DCMAKE_Fortran_FLAGS=-fPIC", + "-DUSE_OPTIMIZED_LAPACK_BLAS:BOOL=ON", # forces scalapack to use find_package(LAPACK) ] + if '+fpic' in spec: + options.extend([ + "-DCMAKE_C_FLAGS=-fPIC", + "-DCMAKE_Fortran_FLAGS=-fPIC" + ]) + options.extend(std_cmake_args) with working_dir('spack-build', create=True):