intel-oneapi-mkl: add missing compiler libraries for thread=openmp (#42087)

This commit is contained in:
Alberto Invernizzi 2024-01-18 14:14:16 +01:00 committed by GitHub
parent f7db6bf3f9
commit 51c02be909
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,6 +165,7 @@ def setup_dependent_build_environment(self, env, dependent_spec):
def _find_mkl_libs(self, shared):
libs = []
threading_libs = []
if self.spec.satisfies("+cluster"):
libs.extend([self._xlp64_lib("libmkl_scalapack"), "libmkl_cdft_core"])
@ -177,6 +178,12 @@ def _find_mkl_libs(self, shared):
libs.append("libmkl_intel_thread")
else:
libs.append("libmkl_gnu_thread")
# this is slightly different than what link-line advisor suggests.
# here it uses what the compiler suggests to use to enable openmp,
# instead of being explicit about in which path openmp libraries
# are located (e.g. intel libiomp5, gcc libgomp, clang libomp).
threading_libs += [self.compiler.openmp_flag]
else:
libs.append("libmkl_sequential")
@ -212,7 +219,10 @@ def _find_mkl_libs(self, shared):
)
lib_path = lib_path if isdir(lib_path) else dirname(lib_path)
# resolved_libs is populated as follows
# MKL-related + MPI-related + threading-related
resolved_libs = find_libraries(libs, lib_path, shared=shared)
# Add MPI libraries for cluster support. If MPI is not in the
# spec, then MKL is externally installed and application must
# link with MPI libaries. If MPI is in spec, but there are no
@ -223,6 +233,9 @@ def _find_mkl_libs(self, shared):
resolved_libs = resolved_libs + self.spec["mpi"].libs
except spack.error.NoLibrariesError:
pass
resolved_libs += threading_libs
return resolved_libs
def _xlp64_lib(self, lib):