Skip to content

Commit

Permalink
use lapacke symbols in openblas if available
Browse files Browse the repository at this point in the history
OpenBLAS normally provides lapacke symbols, and when true installing a separate liblapacke is not necessary and may degrade performance since OpenBLAS has its own optimizations.

The ubuntu-packaged OpenBLAS does NOT, however, provide lapacke.

This handles both cases.
  • Loading branch information
jaredmales authored Nov 29, 2023
1 parent 3f0a07c commit 0bf52b6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions plugins/milk-extra-src/linalgebra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,20 @@ target_link_libraries(${LIBNAME} PUBLIC ${MKL_LIBRARIES})
target_compile_options(${LIBNAME} PUBLIC -DHAVE_MKL ${MKL_CFLAGS_OTHER})
endif()

if(NOT MKL_FOUND) # Need to link against actual LAPACKE
message("-- MKL NOT FOUND")
message(" LINKING LAPACKE")
target_link_libraries(${LIBNAME} PRIVATE lapacke)
#If not using MKL, check if OpenBLAS has lapacke symbols. Include lapacke if not.
if(NOT MKL_FOUND)

check_library_exists(openblas LAPACKE_sgemlq "" DONT_NEED_LAPACKE)

if(DONT_NEED_LAPACKE)
message("-- MKL NOT FOUND")
message(" LINKING OpenBLAS")
else()
message("-- MKL NOT FOUND")
message(" LINKING LAPACKE")
list(APPEND LINKLIBS lapacke)
endif()

endif()

target_link_libraries(${LIBNAME} PRIVATE CLIcore)
Expand Down

0 comments on commit 0bf52b6

Please sign in to comment.