Skip to content

Commit db41c43

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

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

pytensor/link/c/cmodule.py

+29-11
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("Required file '%s' not found", req)
27212722
raise RuntimeError(f"Required file {req} not found")
27222723
return libs
27232724

@@ -2779,9 +2780,15 @@ 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("The following blas flags will be used: '%s'", res)
27832788
return res
27842789
else:
2790+
_logger.debug(f"Supplied flags {res} failed to compile")
2791+
_logger.debug("Supplied flags '%s' failed to compile", res)
27852792
raise RuntimeError(f"Supplied flags {flags} failed to compile")
27862793

27872794
# If no compiler is available we default to empty ldflags
@@ -2802,6 +2809,11 @@ def check_libs(
28022809
# directory. We will include both in our searched library dirs
28032810
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "bin"))
28042811
searched_library_dirs.append(os.path.join(sys.prefix, "Library", "lib"))
2812+
search_dirs = "\n".join(searched_library_dirs)
2813+
_logger.debug(
2814+
"Will search for BLAS libraries in the following directories:\n%s",
2815+
search_dirs,
2816+
)
28052817
all_libs = [
28062818
l
28072819
for path in [
@@ -2817,6 +2829,7 @@ def check_libs(
28172829
maybe_add_to_os_environ_pathlist("PATH", rpath)
28182830
try:
28192831
# 1. Try to use MKL with INTEL OpenMP threading
2832+
_logger.debug("Checking MKL flags with intel threading")
28202833
return check_libs(
28212834
all_libs,
28222835
required_libs=[
@@ -2829,40 +2842,44 @@ def check_libs(
28292842
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28302843
cxx_library_dirs=cxx_library_dirs,
28312844
)
2832-
except Exception:
2833-
pass
2845+
except Exception as e:
2846+
_logger.debug(e)
28342847
try:
28352848
# 2. Try to use MKL with GNU OpenMP threading
2849+
_logger.debug("Checking MKL flags with GNU OpenMP threading")
28362850
return check_libs(
28372851
all_libs,
28382852
required_libs=["mkl_core", "mkl_rt", "mkl_gnu_thread", "gomp", "pthread"],
28392853
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28402854
cxx_library_dirs=cxx_library_dirs,
28412855
)
2842-
except Exception:
2843-
pass
2856+
except Exception as e:
2857+
_logger.debug(e)
28442858
try:
2859+
_logger.debug("Checking Lapack + blas")
28452860
# 3. Try to use LAPACK + BLAS
28462861
return check_libs(
28472862
all_libs,
28482863
required_libs=["lapack", "blas", "cblas", "m"],
28492864
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28502865
cxx_library_dirs=cxx_library_dirs,
28512866
)
2852-
except Exception:
2853-
pass
2867+
except Exception as e:
2868+
_logger.debug(e)
28542869
try:
28552870
# 4. Try to use BLAS alone
2871+
_logger.debug("Checking blas alone")
28562872
return check_libs(
28572873
all_libs,
28582874
required_libs=["blas", "cblas"],
28592875
extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [],
28602876
cxx_library_dirs=cxx_library_dirs,
28612877
)
2862-
except Exception:
2863-
pass
2878+
except Exception as e:
2879+
_logger.debug(e)
28642880
try:
28652881
# 5. Try to use openblas
2882+
_logger.debug("Checking openblas")
28662883
return check_libs(
28672884
all_libs,
28682885
required_libs=["openblas", "gfortran", "gomp", "m"],
@@ -2871,8 +2888,9 @@ def check_libs(
28712888
else ["-fopenmp"],
28722889
cxx_library_dirs=cxx_library_dirs,
28732890
)
2874-
except Exception:
2875-
pass
2891+
except Exception as e:
2892+
_logger.debug(e)
2893+
_logger.debug("Failed to identify blas ldflags. Will leave them empty.")
28762894
return ""
28772895

28782896

0 commit comments

Comments
 (0)