summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Lacroix <remi.lacroix@idris.fr>2021-04-01 14:06:22 +0200
committerGitHub <noreply@github.com>2021-04-01 14:06:22 +0200
commit67f182bb6de79f26b417bc6f56fb4fea95018175 (patch)
treec9dc4d89190fd7125ffe6c412890fc5657757eef
parent4a059aad172cb29bd3618552566dc35cd35de4ac (diff)
downloadspack-67f182bb6de79f26b417bc6f56fb4fea95018175.tar.gz
spack-67f182bb6de79f26b417bc6f56fb4fea95018175.tar.bz2
spack-67f182bb6de79f26b417bc6f56fb4fea95018175.tar.xz
spack-67f182bb6de79f26b417bc6f56fb4fea95018175.zip
MUMPS: Various improvements to the package (#22575)
Use `conflicts` directive whenever possible. This allows failing early when conflicting variants are used. Do not silently ignore `+parmetis` variant when `~metis`. Instead throw an error during concretization. Simplify the "Makefile.inc" generation. This will make easier to add new variants in the future.
-rw-r--r--var/spack/repos/builtin/packages/mumps/package.py59
1 files changed, 31 insertions, 28 deletions
diff --git a/var/spack/repos/builtin/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py
index 12b7a7e35e..d7acaf4c90 100644
--- a/var/spack/repos/builtin/packages/mumps/package.py
+++ b/var/spack/repos/builtin/packages/mumps/package.py
@@ -60,12 +60,14 @@ class Mumps(Package):
patch('mumps.src-makefile.5.2.patch', when='@5.2.0 +shared')
patch('mumps.src-makefile.5.3.patch', when='@5.3.0: +shared')
- 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')
+ conflicts('+parmetis', when='~mpi',
+ msg="You cannot use the parmetis variant without mpi")
+ conflicts('+parmetis', when='~metis',
+ msg="You cannot use the parmetis variant without metis")
+ conflicts('+ptscotch', when='~mpi',
+ msg="You cannot use the ptscotch variant without mpi")
+ def write_makefile_inc(self):
# The makefile variables LIBBLAS, LSCOTCH, LMETIS, and SCALAP are only
# used to link the examples, so if building '+shared' there is no need
# to explicitly link with the respective libraries because we make sure
@@ -96,7 +98,7 @@ class Mumps(Package):
if '+ptscotch' in self.spec:
orderings.append('-Dptscotch')
- if '+parmetis' in self.spec and '+metis' in self.spec:
+ if '+parmetis' in self.spec:
makefile_conf.extend([
"IMETIS = -I%s" % self.spec['parmetis'].prefix.include,
("LMETIS = -L%s -l%s -L%s -l%s" % (
@@ -136,8 +138,8 @@ class Mumps(Package):
# when building shared libs need -fPIC, otherwise
# /usr/bin/ld: graph.o: relocation R_X86_64_32 against `.rodata.str1.1'
# can not be used when making a shared object; recompile with -fPIC
- cpic = self.compiler.cc_pic_flag if '+shared' in self.spec else ''
- fpic = self.compiler.fc_pic_flag if '+shared' in self.spec else ''
+ cpic = self.compiler.cc_pic_flag if shared else ''
+ fpic = self.compiler.fc_pic_flag if shared else ''
# TODO: test this part, it needs a full blas, scalapack and
# partitionning environment with 64bit integers
@@ -147,34 +149,35 @@ class Mumps(Package):
opt_level = '3' if using_xl else ''
+ optc = ['-O{0}'.format(opt_level)]
+ optf = ['-O{0}'.format(opt_level)]
+ optl = ['-O{0}'.format(opt_level)]
+
+ if shared:
+ optc.append(cpic)
+ optf.append(fpic)
+ optl.append(cpic)
+
+ if not using_xlf:
+ optf.append('-DALLOW_NON_INIT')
+
if '+int64' in self.spec:
- if using_xlf:
- makefile_conf.append('OPTF = -O%s' % opt_level)
- else:
+ if not using_xlf:
# the fortran compilation flags most probably are
# working only for intel and gnu compilers this is
# perhaps something the compiler should provide
- makefile_conf.extend([
- 'OPTF = %s -O -DALLOW_NON_INIT %s' % (
- fpic,
- '-fdefault-integer-8' if using_gcc else '-i8'), # noqa
- ])
+ optf.append('-fdefault-integer-8' if using_gcc else '-i8')
- makefile_conf.extend([
- 'OPTL = %s -O%s' % (cpic, opt_level),
- 'OPTC = %s -O%s -DINTSIZE64' % (cpic, opt_level)
- ])
+ optc.append('-DINTSIZE64')
else:
if using_xlf:
- makefile_conf.append('OPTF = -O%s -qfixed' % opt_level)
- else:
- makefile_conf.append('OPTF = %s -O%s -DALLOW_NON_INIT' % (
- fpic, opt_level))
+ optf.append('-qfixed')
- makefile_conf.extend([
- 'OPTL = %s -O%s' % (cpic, opt_level),
- 'OPTC = %s -O%s' % (cpic, opt_level)
- ])
+ makefile_conf.extend([
+ 'OPTC = {0}'.format(' '.join(optc)),
+ 'OPTF = {0}'.format(' '.join(optf)),
+ 'OPTL = {0}'.format(' '.join(optl))
+ ])
if '+mpi' in self.spec:
scalapack = self.spec['scalapack'].libs if not shared \