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.
This commit is contained in:
Rémi Lacroix 2021-04-01 14:06:22 +02:00 committed by GitHub
parent 4a059aad17
commit 67f182bb6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,12 +60,14 @@ class Mumps(Package):
patch('mumps.src-makefile.5.2.patch', when='@5.2.0 +shared') patch('mumps.src-makefile.5.2.patch', when='@5.2.0 +shared')
patch('mumps.src-makefile.5.3.patch', when='@5.3.0: +shared') patch('mumps.src-makefile.5.3.patch', when='@5.3.0: +shared')
def write_makefile_inc(self): conflicts('+parmetis', when='~mpi',
if ('+parmetis' in self.spec or '+ptscotch' in self.spec) and ( msg="You cannot use the parmetis variant without mpi")
'+mpi' not in self.spec): conflicts('+parmetis', when='~metis',
raise RuntimeError( msg="You cannot use the parmetis variant without metis")
'You cannot use the variants parmetis or ptscotch without mpi') 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 # The makefile variables LIBBLAS, LSCOTCH, LMETIS, and SCALAP are only
# used to link the examples, so if building '+shared' there is no need # used to link the examples, so if building '+shared' there is no need
# to explicitly link with the respective libraries because we make sure # to explicitly link with the respective libraries because we make sure
@ -96,7 +98,7 @@ def write_makefile_inc(self):
if '+ptscotch' in self.spec: if '+ptscotch' in self.spec:
orderings.append('-Dptscotch') orderings.append('-Dptscotch')
if '+parmetis' in self.spec and '+metis' in self.spec: if '+parmetis' in self.spec:
makefile_conf.extend([ makefile_conf.extend([
"IMETIS = -I%s" % self.spec['parmetis'].prefix.include, "IMETIS = -I%s" % self.spec['parmetis'].prefix.include,
("LMETIS = -L%s -l%s -L%s -l%s" % ( ("LMETIS = -L%s -l%s -L%s -l%s" % (
@ -136,8 +138,8 @@ def write_makefile_inc(self):
# when building shared libs need -fPIC, otherwise # when building shared libs need -fPIC, otherwise
# /usr/bin/ld: graph.o: relocation R_X86_64_32 against `.rodata.str1.1' # /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 # can not be used when making a shared object; recompile with -fPIC
cpic = self.compiler.cc_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' in self.spec else '' fpic = self.compiler.fc_pic_flag if shared else ''
# TODO: test this part, it needs a full blas, scalapack and # TODO: test this part, it needs a full blas, scalapack and
# partitionning environment with 64bit integers # partitionning environment with 64bit integers
@ -147,34 +149,35 @@ def write_makefile_inc(self):
opt_level = '3' if using_xl else '' 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 '+int64' in self.spec:
if using_xlf: if not using_xlf:
makefile_conf.append('OPTF = -O%s' % opt_level)
else:
# the fortran compilation flags most probably are # the fortran compilation flags most probably are
# working only for intel and gnu compilers this is # working only for intel and gnu compilers this is
# perhaps something the compiler should provide # perhaps something the compiler should provide
makefile_conf.extend([ optf.append('-fdefault-integer-8' if using_gcc else '-i8')
'OPTF = %s -O -DALLOW_NON_INIT %s' % (
fpic,
'-fdefault-integer-8' if using_gcc else '-i8'), # noqa
])
makefile_conf.extend([ optc.append('-DINTSIZE64')
'OPTL = %s -O%s' % (cpic, opt_level),
'OPTC = %s -O%s -DINTSIZE64' % (cpic, opt_level)
])
else: else:
if using_xlf: if using_xlf:
makefile_conf.append('OPTF = -O%s -qfixed' % opt_level) optf.append('-qfixed')
else:
makefile_conf.append('OPTF = %s -O%s -DALLOW_NON_INIT' % (
fpic, opt_level))
makefile_conf.extend([ makefile_conf.extend([
'OPTL = %s -O%s' % (cpic, opt_level), 'OPTC = {0}'.format(' '.join(optc)),
'OPTC = %s -O%s' % (cpic, opt_level) 'OPTF = {0}'.format(' '.join(optf)),
]) 'OPTL = {0}'.format(' '.join(optl))
])
if '+mpi' in self.spec: if '+mpi' in self.spec:
scalapack = self.spec['scalapack'].libs if not shared \ scalapack = self.spec['scalapack'].libs if not shared \