[intel-oneapi-mkl] add openmpi support for +cluster (#38554)

This commit is contained in:
Robert Cohn 2023-06-30 18:38:40 -04:00 committed by GitHub
parent 43143b134a
commit 0c2b98ca70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,7 +125,7 @@ def headers(self):
@property @property
def libs(self): def libs(self):
shared = "+shared" in self.spec shared = self.spec.satisfies("+shared")
libs = self._find_mkl_libs(shared) libs = self._find_mkl_libs(shared)
@ -145,28 +145,27 @@ def setup_run_environment(self, env):
# flags too. We prefer the __INTEL_POST_CFLAGS/__INTEL_POST_FFLAGS flags over # flags too. We prefer the __INTEL_POST_CFLAGS/__INTEL_POST_FFLAGS flags over
# the PRE ones so that any other RPATHs provided by the users on the command # the PRE ones so that any other RPATHs provided by the users on the command
# line come before and take precedence over the ones we inject here. # line come before and take precedence over the ones we inject here.
for d in self._find_mkl_libs("+shared" in self.spec).directories: for d in self._find_mkl_libs(self.spec.satisfies("+shared")).directories:
flag = "-Wl,-rpath,{0}".format(d) flag = "-Wl,-rpath,{0}".format(d)
env.append_path("__INTEL_POST_CFLAGS", flag, separator=" ") env.append_path("__INTEL_POST_CFLAGS", flag, separator=" ")
env.append_path("__INTEL_POST_FFLAGS", flag, separator=" ") env.append_path("__INTEL_POST_FFLAGS", flag, separator=" ")
def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_build_environment(self, env, dependent_spec):
# Only if environment modifications are desired (default is +envmods) # Only if environment modifications are desired (default is +envmods)
if "+envmods" in self.spec: if self.spec.satisfies("+envmods"):
env.set("MKLROOT", self.component_prefix) env.set("MKLROOT", self.component_prefix)
env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig) env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig)
def _find_mkl_libs(self, shared): def _find_mkl_libs(self, shared):
libs = [] libs = []
if "+cluster" in self.spec: if self.spec.satisfies("+cluster"):
libs.extend([self._xlp64_lib("libmkl_scalapack"), "libmkl_cdft_core"]) libs.extend([self._xlp64_lib("libmkl_scalapack"), "libmkl_cdft_core"])
libs.append(self._xlp64_lib("libmkl_intel")) libs.append(self._xlp64_lib("libmkl_intel"))
if self.spec.satisfies("threads=tbb"):
if "threads=tbb" in self.spec:
libs.append("libmkl_tbb_thread") libs.append("libmkl_tbb_thread")
elif "threads=openmp" in self.spec: elif self.spec.satisfies("threads=openmp"):
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"): if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
libs.append("libmkl_intel_thread") libs.append("libmkl_intel_thread")
else: else:
@ -176,8 +175,18 @@ def _find_mkl_libs(self, shared):
libs.append("libmkl_core") libs.append("libmkl_core")
if "+cluster" in self.spec: if self.spec.satisfies("+cluster"):
libs.append(self._xlp64_lib("libmkl_blacs_intelmpi")) if any(self.spec.satisfies(m) for m in ["^intel-oneapi-mpi", "^intel-mpi", "^mpich"]):
libs.append(self._xlp64_lib("libmkl_blacs_intelmpi"))
elif self.spec.satisfies("^openmpi"):
libs.append(self._xlp64_lib("libmkl_blacs_openmpi"))
else:
raise RuntimeError(
(
"intel-oneapi-mpi +cluster requires one of "
"^intel-oneapi-mpi, ^intel-mpi, ^mpich, or ^openmpi"
)
)
lib_path = self.component_prefix.lib.intel64 lib_path = self.component_prefix.lib.intel64
lib_path = lib_path if isdir(lib_path) else dirname(lib_path) lib_path = lib_path if isdir(lib_path) else dirname(lib_path)
@ -186,12 +195,12 @@ def _find_mkl_libs(self, shared):
# Add MPI libraries for cluster support. If MPI is not in the # Add MPI libraries for cluster support. If MPI is not in the
# spec, then MKL is externally installed and application must # spec, then MKL is externally installed and application must
# link with MPI libaries # link with MPI libaries
if "+cluster" in self.spec and "mpi" in self.spec: if self.spec.satisfies("+cluster ^mpi"):
resolved_libs = resolved_libs + self.spec["mpi"].libs resolved_libs = resolved_libs + self.spec["mpi"].libs
return resolved_libs return resolved_libs
def _xlp64_lib(self, lib): def _xlp64_lib(self, lib):
return lib + ("_ilp64" if "+ilp64" in self.spec else "_lp64") return lib + ("_ilp64" if self.spec.satisfies("+ilp64") else "_lp64")
@run_after("install") @run_after("install")
def fixup_prefix(self): def fixup_prefix(self):