MPICH sets MPI compilers to use real compilers and not spack wrappers.
This commit is contained in:
parent
5cc508393a
commit
3bd52678be
@ -38,7 +38,7 @@
|
|||||||
from spack.util.compression import ALLOWED_ARCHIVE_TYPES
|
from spack.util.compression import ALLOWED_ARCHIVE_TYPES
|
||||||
|
|
||||||
|
|
||||||
def filter_file(regex, repl, *filenames):
|
def filter_file(regex, repl, *filenames, **kwargs):
|
||||||
"""Like sed, but uses python regular expressions.
|
"""Like sed, but uses python regular expressions.
|
||||||
|
|
||||||
Filters every line of file through regex and replaces the file
|
Filters every line of file through regex and replaces the file
|
||||||
@ -49,16 +49,31 @@ def filter_file(regex, repl, *filenames):
|
|||||||
return a suitable replacement string. If it is a string, it
|
return a suitable replacement string. If it is a string, it
|
||||||
can contain ``\1``, ``\2``, etc. to represent back-substitution
|
can contain ``\1``, ``\2``, etc. to represent back-substitution
|
||||||
as sed would allow.
|
as sed would allow.
|
||||||
|
|
||||||
|
Keyword Options:
|
||||||
|
string[=False] If True, treat regex as a plain string.
|
||||||
|
backup[=True] Make a backup files suffixed with ~
|
||||||
|
ignore_absent[=False] Ignore any files that don't exist.
|
||||||
"""
|
"""
|
||||||
# Keep callables intact
|
string = kwargs.get('string', False)
|
||||||
if not hasattr(repl, '__call__'):
|
backup = kwargs.get('backup', True)
|
||||||
# Allow strings to use \1, \2, etc. for replacement, like sed
|
ignore_absent = kwargs.get('ignore_absent', False)
|
||||||
|
|
||||||
|
# Allow strings to use \1, \2, etc. for replacement, like sed
|
||||||
|
if not callable(repl):
|
||||||
unescaped = repl.replace(r'\\', '\\')
|
unescaped = repl.replace(r'\\', '\\')
|
||||||
repl = lambda m: re.sub(
|
repl = lambda m: re.sub(
|
||||||
r'\\([0-9])', lambda x: m.group(int(x.group(1))), unescaped)
|
r'\\([0-9])', lambda x: m.group(int(x.group(1))), unescaped)
|
||||||
|
|
||||||
|
if string:
|
||||||
|
regex = re.escape(regex)
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
backup = filename + "~"
|
backup = filename + "~"
|
||||||
|
|
||||||
|
if ignore_absent and not os.path.exists(filename):
|
||||||
|
continue
|
||||||
|
|
||||||
shutil.copy(filename, backup)
|
shutil.copy(filename, backup)
|
||||||
try:
|
try:
|
||||||
with closing(open(backup)) as infile:
|
with closing(open(backup)) as infile:
|
||||||
@ -71,6 +86,10 @@ def filter_file(regex, repl, *filenames):
|
|||||||
shutil.move(backup, filename)
|
shutil.move(backup, filename)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if not backup:
|
||||||
|
shutil.rmtree(backup, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
def change_sed_delimiter(old_delim, new_delim, *filenames):
|
def change_sed_delimiter(old_delim, new_delim, *filenames):
|
||||||
"""Find all sed search/replace commands and change the delimiter.
|
"""Find all sed search/replace commands and change the delimiter.
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from spack import *
|
from spack import *
|
||||||
|
import os
|
||||||
|
|
||||||
class Mpich(Package):
|
class Mpich(Package):
|
||||||
"""MPICH is a high performance and widely portable implementation of
|
"""MPICH is a high performance and widely portable implementation of
|
||||||
@ -53,3 +54,26 @@ def install(self, spec, prefix):
|
|||||||
configure(*config_args)
|
configure(*config_args)
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
|
||||||
|
self.filter_compilers()
|
||||||
|
|
||||||
|
|
||||||
|
def filter_compilers(self):
|
||||||
|
"""Run after install to make the MPI compilers use the
|
||||||
|
compilers that Spack built the package with.
|
||||||
|
|
||||||
|
If this isn't done, they'll have CC, CXX, F77, and FC set
|
||||||
|
to Spack's generic cc, c++, f77, and f90. We want them to
|
||||||
|
be bound to whatever compiler they were built with.
|
||||||
|
"""
|
||||||
|
bin = self.prefix.bin
|
||||||
|
mpicc = os.path.join(bin, 'mpicc')
|
||||||
|
mpicxx = os.path.join(bin, 'mpicxx')
|
||||||
|
mpif77 = os.path.join(bin, 'mpif77')
|
||||||
|
mpif90 = os.path.join(bin, 'mpif90')
|
||||||
|
|
||||||
|
kwargs = { 'ignore_absent' : True, 'backup' : False, 'string' : True }
|
||||||
|
filter_file('CC="cc"', 'CC="%s"' % self.compiler.cc, mpicc, **kwargs)
|
||||||
|
filter_file('CXX="c++"', 'CXX="%s"' % self.compiler.cxx, mpicxx, **kwargs)
|
||||||
|
filter_file('F77="f77"', 'F77="%s"' % self.compiler.f77, mpif77, **kwargs)
|
||||||
|
filter_file('FC="f90"', 'FC="%s"' % self.compiler.fc, mpif90, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user