提交 c38e7ba3 authored 作者: lucianopaz's avatar lucianopaz 提交者: Thomas Wiecki

Add _logger.debug statements to cmodule default blas ldflags

上级 af7ed248
...@@ -2718,6 +2718,7 @@ def default_blas_ldflags(): ...@@ -2718,6 +2718,7 @@ def default_blas_ldflags():
found = True found = True
break break
if not found: if not found:
_logger.debug("Required file '%s' not found", req)
raise RuntimeError(f"Required file {req} not found") raise RuntimeError(f"Required file {req} not found")
return libs return libs
...@@ -2779,9 +2780,15 @@ def default_blas_ldflags(): ...@@ -2779,9 +2780,15 @@ def default_blas_ldflags():
res = try_blas_flag(flags) res = try_blas_flag(flags)
if res: if res:
if any("mkl" in flag for flag in flags): if any("mkl" in flag for flag in flags):
check_mkl_openmp() try:
check_mkl_openmp()
except Exception as e:
_logger.debug(e)
_logger.debug("The following blas flags will be used: '%s'", res)
return res return res
else: else:
_logger.debug(f"Supplied flags {res} failed to compile")
_logger.debug("Supplied flags '%s' failed to compile", res)
raise RuntimeError(f"Supplied flags {flags} failed to compile") raise RuntimeError(f"Supplied flags {flags} failed to compile")
# If no compiler is available we default to empty ldflags # If no compiler is available we default to empty ldflags
...@@ -2802,6 +2809,11 @@ def default_blas_ldflags(): ...@@ -2802,6 +2809,11 @@ def default_blas_ldflags():
# directory. We will include both in our searched library dirs # directory. We will include both in our searched library dirs
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "bin")) searched_library_dirs.append(os.path.join(sys.prefix, "Library", "bin"))
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "lib")) searched_library_dirs.append(os.path.join(sys.prefix, "Library", "lib"))
search_dirs = "\n".join(searched_library_dirs)
_logger.debug(
"Will search for BLAS libraries in the following directories:\n%s",
search_dirs,
)
all_libs = [ all_libs = [
l l
for path in [ for path in [
...@@ -2817,6 +2829,7 @@ def default_blas_ldflags(): ...@@ -2817,6 +2829,7 @@ def default_blas_ldflags():
maybe_add_to_os_environ_pathlist("PATH", rpath) maybe_add_to_os_environ_pathlist("PATH", rpath)
try: try:
# 1. Try to use MKL with INTEL OpenMP threading # 1. Try to use MKL with INTEL OpenMP threading
_logger.debug("Checking MKL flags with intel threading")
return check_libs( return check_libs(
all_libs, all_libs,
required_libs=[ required_libs=[
...@@ -2829,19 +2842,21 @@ def default_blas_ldflags(): ...@@ -2829,19 +2842,21 @@ def default_blas_ldflags():
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [], extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
cxx_library_dirs=cxx_library_dirs, cxx_library_dirs=cxx_library_dirs,
) )
except Exception: except Exception as e:
pass _logger.debug(e)
try: try:
# 2. Try to use MKL with GNU OpenMP threading # 2. Try to use MKL with GNU OpenMP threading
_logger.debug("Checking MKL flags with GNU OpenMP threading")
return check_libs( return check_libs(
all_libs, all_libs,
required_libs=["mkl_core", "mkl_rt", "mkl_gnu_thread", "gomp", "pthread"], required_libs=["mkl_core", "mkl_rt", "mkl_gnu_thread", "gomp", "pthread"],
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [], extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
cxx_library_dirs=cxx_library_dirs, cxx_library_dirs=cxx_library_dirs,
) )
except Exception: except Exception as e:
pass _logger.debug(e)
try: try:
_logger.debug("Checking Lapack + blas")
# 3. Try to use LAPACK + BLAS # 3. Try to use LAPACK + BLAS
return check_libs( return check_libs(
all_libs, all_libs,
...@@ -2849,20 +2864,22 @@ def default_blas_ldflags(): ...@@ -2849,20 +2864,22 @@ def default_blas_ldflags():
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [], extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
cxx_library_dirs=cxx_library_dirs, cxx_library_dirs=cxx_library_dirs,
) )
except Exception: except Exception as e:
pass _logger.debug(e)
try: try:
# 4. Try to use BLAS alone # 4. Try to use BLAS alone
_logger.debug("Checking blas alone")
return check_libs( return check_libs(
all_libs, all_libs,
required_libs=["blas", "cblas"], required_libs=["blas", "cblas"],
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [], extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
cxx_library_dirs=cxx_library_dirs, cxx_library_dirs=cxx_library_dirs,
) )
except Exception: except Exception as e:
pass _logger.debug(e)
try: try:
# 5. Try to use openblas # 5. Try to use openblas
_logger.debug("Checking openblas")
return check_libs( return check_libs(
all_libs, all_libs,
required_libs=["openblas", "gfortran", "gomp", "m"], required_libs=["openblas", "gfortran", "gomp", "m"],
...@@ -2871,8 +2888,9 @@ def default_blas_ldflags(): ...@@ -2871,8 +2888,9 @@ def default_blas_ldflags():
else ["-fopenmp"], else ["-fopenmp"],
cxx_library_dirs=cxx_library_dirs, cxx_library_dirs=cxx_library_dirs,
) )
except Exception: except Exception as e:
pass _logger.debug(e)
_logger.debug("Failed to identify blas ldflags. Will leave them empty.")
return "" return ""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论