spectrum-mpi: external support, compiler detection (#18055)
* spectrum-mpi: adding external support. * Package is tested, works on LLNL lassen * Spectrum external now detects the correct compiler * Changing code to not output all compilers Done per becker33's request on #18055
This commit is contained in:
parent
9befc43708
commit
6ceb3d4be0
@ -2,7 +2,8 @@
|
|||||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os.path
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class SpectrumMpi(Package):
|
class SpectrumMpi(Package):
|
||||||
@ -12,6 +13,82 @@ class SpectrumMpi(Package):
|
|||||||
|
|
||||||
provides('mpi')
|
provides('mpi')
|
||||||
|
|
||||||
|
executables = ['^ompi_info$']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def determine_version(cls, exe):
|
||||||
|
output = Executable(exe)(output=str, error=str)
|
||||||
|
match = re.search(r'Spectrum MPI: (\S+)', output)
|
||||||
|
if not match:
|
||||||
|
return None
|
||||||
|
version = match.group(1)
|
||||||
|
return version
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def determine_variants(cls, exes, version):
|
||||||
|
compiler_suites = {
|
||||||
|
'xl': {'cc': 'mpixlc',
|
||||||
|
'cxx': 'mpixlC',
|
||||||
|
'f77': 'mpixlf',
|
||||||
|
'fc': 'mpixlf'},
|
||||||
|
'pgi': {'cc': 'mpipgicc',
|
||||||
|
'cxx': 'mpipgic++',
|
||||||
|
'f77': 'mpipgifort',
|
||||||
|
'fc': 'mpipgifort'},
|
||||||
|
'default': {'cc': 'mpicc',
|
||||||
|
'cxx': 'mpicxx',
|
||||||
|
'f77': 'mpif77',
|
||||||
|
'fc': 'mpif90'}}
|
||||||
|
|
||||||
|
def get_host_compiler(exe):
|
||||||
|
output = Executable(exe)("--showme", output=str, error=str)
|
||||||
|
match = re.search(r'^(\S+)', output)
|
||||||
|
return match.group(1) if match else None
|
||||||
|
|
||||||
|
def get_spack_compiler_spec(compilers_found):
|
||||||
|
# check using cc for now, as everyone should have that defined.
|
||||||
|
path = os.path.dirname(compilers_found['cc'])
|
||||||
|
spack_compilers = spack.compilers.find_compilers([path])
|
||||||
|
actual_compiler = None
|
||||||
|
# check if the compiler actually matches the one we want
|
||||||
|
for spack_compiler in spack_compilers:
|
||||||
|
if os.path.dirname(spack_compiler.cc) == path:
|
||||||
|
actual_compiler = spack_compiler
|
||||||
|
break
|
||||||
|
return actual_compiler.spec if actual_compiler else None
|
||||||
|
|
||||||
|
results = []
|
||||||
|
for exe in exes:
|
||||||
|
dirname = os.path.dirname(exe)
|
||||||
|
siblings = os.listdir(dirname)
|
||||||
|
compilers_found = {}
|
||||||
|
for compiler_suite in compiler_suites.values():
|
||||||
|
for (compiler_class, compiler_name) in compiler_suite.items():
|
||||||
|
if compiler_name in siblings:
|
||||||
|
# Get the real name of the compiler
|
||||||
|
full_exe = os.path.join(dirname, compiler_name)
|
||||||
|
host_exe = get_host_compiler(full_exe)
|
||||||
|
if host_exe:
|
||||||
|
compilers_found[compiler_class] = host_exe
|
||||||
|
if compilers_found:
|
||||||
|
break
|
||||||
|
if compilers_found:
|
||||||
|
compiler_spec = get_spack_compiler_spec(compilers_found)
|
||||||
|
if compiler_spec:
|
||||||
|
variant = "%" + str(compiler_spec)
|
||||||
|
else:
|
||||||
|
variant = ''
|
||||||
|
# Use this variant when you need to define the
|
||||||
|
# compilers explicitly
|
||||||
|
#
|
||||||
|
# results.append((variant, {'compilers': compilers_found}))
|
||||||
|
#
|
||||||
|
# Otherwise, use this simpler attribute
|
||||||
|
results.append(variant)
|
||||||
|
else:
|
||||||
|
results.append('')
|
||||||
|
return results
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
raise InstallError('IBM MPI is not installable; it is vendor supplied')
|
raise InstallError('IBM MPI is not installable; it is vendor supplied')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user