[intel-oneapi-mkl] workaround linking issue for threads=openmp (#42327)

This commit is contained in:
Robert Cohn 2024-01-27 00:22:51 -05:00 committed by GitHub
parent 179a1e423e
commit 1865e228c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 10 deletions

View file

@ -171,8 +171,14 @@ def configure_args(self):
options += self.enable_or_disable("openmp") options += self.enable_or_disable("openmp")
# if using mkl with openmp support, link with openmp
mkl_openmp_flag = (
self.compiler.openmp_flag
if self.spec.satisfies("^intel-oneapi-mkl threads=openmp")
else ""
)
options += [ options += [
"LDFLAGS={0}".format(spec["lapack"].libs.search_flags), "LDFLAGS={0} {1}".format(mkl_openmp_flag, spec["lapack"].libs.search_flags),
"LIBS={0} {1}".format(spec["lapack"].libs.link_flags, spec["blas"].libs.link_flags), "LIBS={0} {1}".format(spec["lapack"].libs.link_flags, spec["blas"].libs.link_flags),
] ]

View file

@ -179,7 +179,6 @@ def setup_dependent_build_environment(self, env, dependent_spec):
def _find_mkl_libs(self, shared): def _find_mkl_libs(self, shared):
libs = [] libs = []
threading_libs = []
if self.spec.satisfies("+cluster"): 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"])
@ -192,12 +191,6 @@ def _find_mkl_libs(self, shared):
libs.append("libmkl_intel_thread") libs.append("libmkl_intel_thread")
else: else:
libs.append("libmkl_gnu_thread") 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: else:
libs.append("libmkl_sequential") libs.append("libmkl_sequential")
@ -248,8 +241,6 @@ def _find_mkl_libs(self, shared):
except spack.error.NoLibrariesError: except spack.error.NoLibrariesError:
pass pass
resolved_libs += threading_libs
return resolved_libs return resolved_libs
def _xlp64_lib(self, lib): def _xlp64_lib(self, lib):