Bugfix spectrum-mpi module generation (#41466)

* Ensure that additional environment variables are set when a module
file is generated.

* Fixed the detection of the opal_prefix / MPI_ROOT field to use ompi_info.
---------

Co-authored-by: Greg Becker <becker33@llnl.gov>
This commit is contained in:
Brian Van Essen 2023-12-07 13:06:07 -06:00 committed by GitHub
parent 5beef28444
commit 9f1223e7a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,14 @@ def get_spack_compiler_spec(compilers_found):
break break
return actual_compiler.spec if actual_compiler else None return actual_compiler.spec if actual_compiler else None
def get_opal_prefix(exe):
output = Executable(exe)(output=str, error=str)
match = re.search(r"Prefix: (\S+)", output)
if not match:
return None
opal_prefix = match.group(1)
return opal_prefix
results = [] results = []
for exe in exes: for exe in exes:
dirname = os.path.dirname(exe) dirname = os.path.dirname(exe)
@ -83,9 +91,14 @@ def get_spack_compiler_spec(compilers_found):
# results.append((variant, {'compilers': compilers_found})) # results.append((variant, {'compilers': compilers_found}))
# #
# Otherwise, use this simpler attribute # Otherwise, use this simpler attribute
results.append(variant)
else: else:
results.append("") variant = ""
opal_prefix = get_opal_prefix(exe)
if opal_prefix:
extra_attributes = {"opal_prefix": opal_prefix}
results.append((variant, extra_attributes))
else:
results.append(variant)
return results return results
def setup_dependent_package(self, module, dependent_spec): def setup_dependent_package(self, module, dependent_spec):
@ -148,3 +161,6 @@ def setup_run_environment(self, env):
env.set("MPICXX", os.path.join(self.prefix.bin, "mpic++")) env.set("MPICXX", os.path.join(self.prefix.bin, "mpic++"))
env.set("MPIF77", os.path.join(self.prefix.bin, "mpif77")) env.set("MPIF77", os.path.join(self.prefix.bin, "mpif77"))
env.set("MPIF90", os.path.join(self.prefix.bin, "mpif90")) env.set("MPIF90", os.path.join(self.prefix.bin, "mpif90"))
env.set("OPAL_PREFIX", self.spec.extra_attributes.get("opal_prefix", self.prefix))
env.set("MPI_ROOT", self.spec.extra_attributes.get("opal_prefix", self.prefix))