Skip to content

Commit 9f1bbef

Browse files
committed
Add _logger.debug statements to cmodule default blas ldflags
1 parent af7ed24 commit 9f1bbef

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

pytensor/link/c/cmodule.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,7 @@ def check_required_file(paths, required_regexs):
27182718
found = True
27192719
break
27202720
if not found:
2721+
_logger.debug(f"Required file {req} not found")
27212722
raise RuntimeError(f"Required file {req} not found")
27222723
return libs
27232724

@@ -2779,9 +2780,14 @@ def check_libs(
27792780
res = try_blas_flag(flags)
27802781
if res:
27812782
if any("mkl" in flag for flag in flags):
2782-
check_mkl_openmp()
2783+
try:
2784+
check_mkl_openmp()
2785+
except Exception as e:
2786+
_logger.debug(e)
2787+
_logger.debug(f"The following blas flags will be used {res}")
27832788
return res
27842789
else:
2790+
_logger.debug(f"Supplied flags {res} failed to compile")
27852791
raise RuntimeError(f"Supplied flags {flags} failed to compile")
27862792

27872793
# If no compiler is available we default to empty ldflags
@@ -2802,6 +2808,8 @@ def check_libs(
28022808
# directory. We will include both in our searched library dirs
28032809
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "bin"))
28042810
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "lib"))
2811+
_logger.debug("Will search for BLAS libraries in the following directories:")
2812+
_logger.debug("{}".format("\n".join(searched_library_dirs)))
28052813
all_libs = [
28062814
l
28072815
for path in [
@@ -2817,6 +2825,7 @@ def check_libs(
28172825
maybe_add_to_os_environ_pathlist("PATH", rpath)
28182826
try:
28192827
# 1. Try to use MKL with INTEL OpenMP threading
2828+
_logger.debug("Checking MKL flags with intel threading")
28202829
return check_libs(
28212830
all_libs,
28222831
required_libs=[
@@ -2829,40 +2838,44 @@ def check_libs(
28292838
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28302839
cxx_library_dirs=cxx_library_dirs,
28312840
)
2832-
except Exception:
2833-
pass
2841+
except Exception as e:
2842+
_logger.debug(e)
28342843
try:
28352844
# 2. Try to use MKL with GNU OpenMP threading
2845+
_logger.debug("Checking MKL flags with GNU OpenMP threading")
28362846
return check_libs(
28372847
all_libs,
28382848
required_libs=["mkl_core", "mkl_rt", "mkl_gnu_thread", "gomp", "pthread"],
28392849
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28402850
cxx_library_dirs=cxx_library_dirs,
28412851
)
2842-
except Exception:
2843-
pass
2852+
except Exception as e:
2853+
_logger.debug(e)
28442854
try:
2855+
_logger.debug("Checking Lapack + blas")
28452856
# 3. Try to use LAPACK + BLAS
28462857
return check_libs(
28472858
all_libs,
28482859
required_libs=["lapack", "blas", "cblas", "m"],
28492860
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28502861
cxx_library_dirs=cxx_library_dirs,
28512862
)
2852-
except Exception:
2853-
pass
2863+
except Exception as e:
2864+
_logger.debug(e)
28542865
try:
28552866
# 4. Try to use BLAS alone
2867+
_logger.debug("Checking blas alone")
28562868
return check_libs(
28572869
all_libs,
28582870
required_libs=["blas", "cblas"],
28592871
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28602872
cxx_library_dirs=cxx_library_dirs,
28612873
)
2862-
except Exception:
2863-
pass
2874+
except Exception as e:
2875+
_logger.debug(e)
28642876
try:
28652877
# 5. Try to use openblas
2878+
_logger.debug("Checking openblas")
28662879
return check_libs(
28672880
all_libs,
28682881
required_libs=["openblas", "gfortran", "gomp", "m"],
@@ -2871,8 +2884,9 @@ def check_libs(
28712884
else ["-fopenmp"],
28722885
cxx_library_dirs=cxx_library_dirs,
28732886
)
2874-
except Exception:
2875-
pass
2887+
except Exception as e:
2888+
_logger.debug(e)
2889+
_logger.debug("Failed to identify blas ldflags. Will leave them empty.")
28762890
return ""
28772891

28782892

0 commit comments

Comments
 (0)