summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorRobert Blake <blake14@llnl.gov>2020-08-28 11:53:27 -0700
committerGitHub <noreply@github.com>2020-08-28 11:53:27 -0700
commit6ceb3d4be0d75c71dc837b0990a5c3b77246fe91 (patch)
tree10ab79ebbbc2d9bfbfbe21c37407e9ef797e711a /var
parent9befc43708534ddaa80820468a57012bd1a62ca5 (diff)
downloadspack-6ceb3d4be0d75c71dc837b0990a5c3b77246fe91.tar.gz
spack-6ceb3d4be0d75c71dc837b0990a5c3b77246fe91.tar.bz2
spack-6ceb3d4be0d75c71dc837b0990a5c3b77246fe91.tar.xz
spack-6ceb3d4be0d75c71dc837b0990a5c3b77246fe91.zip
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
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/spectrum-mpi/package.py79
1 files changed, 78 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/spectrum-mpi/package.py b/var/spack/repos/builtin/packages/spectrum-mpi/package.py
index 8ec206adae..c9f3369155 100644
--- a/var/spack/repos/builtin/packages/spectrum-mpi/package.py
+++ b/var/spack/repos/builtin/packages/spectrum-mpi/package.py
@@ -2,7 +2,8 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os.path
+import os
+import re
class SpectrumMpi(Package):
@@ -12,6 +13,82 @@ class SpectrumMpi(Package):
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):
raise InstallError('IBM MPI is not installable; it is vendor supplied')