Commit 4fec20c4 authored by Alexis Tsogias's avatar Alexis Tsogias Committed by Davis E. King

Added option to link against mkl_sequential (#1302)

parent 996a4bbb
...@@ -140,6 +140,8 @@ if (NOT TARGET dlib) ...@@ -140,6 +140,8 @@ if (NOT TARGET dlib)
"Disable this if you don't want to use a LAPACK library" ) "Disable this if you don't want to use a LAPACK library" )
set (DLIB_USE_CUDA_STR set (DLIB_USE_CUDA_STR
"Disable this if you don't want to use NVIDIA CUDA" ) "Disable this if you don't want to use NVIDIA CUDA" )
set (DLIB_USE_MKL_SEQUENTIAL_STR
"Enable this if you have MKL installed and want to use the sequential version" )
set (DLIB_PNG_SUPPORT_STR set (DLIB_PNG_SUPPORT_STR
"Disable this if you don't want to link against libpng" ) "Disable this if you don't want to link against libpng" )
set (DLIB_GIF_SUPPORT_STR set (DLIB_GIF_SUPPORT_STR
...@@ -162,6 +164,7 @@ if (NOT TARGET dlib) ...@@ -162,6 +164,7 @@ if (NOT TARGET dlib)
toggle_preprocessor_switch(DLIB_NO_GUI_SUPPORT) toggle_preprocessor_switch(DLIB_NO_GUI_SUPPORT)
option(DLIB_ENABLE_STACK_TRACE ${DLIB_ENABLE_STACK_TRACE_STR} OFF) option(DLIB_ENABLE_STACK_TRACE ${DLIB_ENABLE_STACK_TRACE_STR} OFF)
toggle_preprocessor_switch(DLIB_ENABLE_STACK_TRACE) toggle_preprocessor_switch(DLIB_ENABLE_STACK_TRACE)
option(DLIB_USE_MKL_SEQUENTIAL ${DLIB_USE_MKL_SEQUENTIAL_STR} OFF)
if(DLIB_ENABLE_ASSERTS) if(DLIB_ENABLE_ASSERTS)
# Set these variables so they are set in the config.h.in file when dlib # Set these variables so they are set in the config.h.in file when dlib
......
...@@ -110,13 +110,14 @@ if (UNIX OR MINGW) ...@@ -110,13 +110,14 @@ if (UNIX OR MINGW)
find_path(mkl_include_dir mkl_version.h ${mkl_include_search_path}) find_path(mkl_include_dir mkl_version.h ${mkl_include_search_path})
mark_as_advanced(mkl_include_dir) mark_as_advanced(mkl_include_dir)
if(NOT DLIB_USE_MKL_SEQUENTIAL)
# Search for the needed libraries from the MKL. We will try to link against the mkl_rt # Search for the needed libraries from the MKL. We will try to link against the mkl_rt
# file first since this way avoids linking bugs in some cases. # file first since this way avoids linking bugs in some cases.
find_library(mkl_rt mkl_rt ${mkl_search_path}) find_library(mkl_rt mkl_rt ${mkl_search_path})
find_library(openmp_libraries iomp5 ${mkl_search_path}) find_library(openmp_libraries iomp5 ${mkl_search_path})
mark_as_advanced( mkl_rt openmp_libraries ) mark_as_advanced(mkl_rt openmp_libraries)
# if we found the MKL # if we found the MKL
if ( mkl_rt) if (mkl_rt)
set(mkl_libraries ${mkl_rt} ) set(mkl_libraries ${mkl_rt} )
set(blas_libraries ${mkl_rt} ) set(blas_libraries ${mkl_rt} )
set(lapack_libraries ${mkl_rt} ) set(lapack_libraries ${mkl_rt} )
...@@ -125,21 +126,32 @@ if (UNIX OR MINGW) ...@@ -125,21 +126,32 @@ if (UNIX OR MINGW)
set(found_intel_mkl 1) set(found_intel_mkl 1)
message(STATUS "Found Intel MKL BLAS/LAPACK library") message(STATUS "Found Intel MKL BLAS/LAPACK library")
endif() endif()
endif()
if (NOT found_intel_mkl) if (NOT found_intel_mkl)
# Search for the needed libraries from the MKL. This time try looking for a different # Search for the needed libraries from the MKL. This time try looking for a different
# set of MKL files and try to link against those. # set of MKL files and try to link against those.
find_library(mkl_core mkl_core ${mkl_search_path}) find_library(mkl_core mkl_core ${mkl_search_path})
set(mkl_libs ${mkl_intel} ${mkl_core})
mark_as_advanced(mkl_libs mkl_intel mkl_core)
if (DLIB_USE_MKL_SEQUENTIAL)
find_library(mkl_sequential mkl_sequential ${mkl_search_path})
mark_as_advanced(mkl_sequential)
list(APPEND mkl_libs ${mkl_sequential})
else()
find_library(mkl_thread mkl_intel_thread ${mkl_search_path}) find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
find_library(mkl_iomp iomp5 ${mkl_search_path}) find_library(mkl_iomp iomp5 ${mkl_search_path})
find_library(mkl_pthread pthread ${mkl_search_path}) find_library(mkl_pthread pthread ${mkl_search_path})
mark_as_advanced(mkl_thread mkl_iomp mkl_pthread)
list(APPEND mkl_libs ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
endif()
mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp mkl_pthread)
# If we found the MKL # If we found the MKL
if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread) if (mkl_intel AND mkl_core AND ((mkl_thread AND mkl_iomp AND mkl_pthread) OR mkl_sequential))
set(mkl_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) set(mkl_libraries ${mkl_libs})
set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) set(blas_libraries ${mkl_libs})
set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) set(lapack_libraries ${mkl_libs})
set(blas_found 1) set(blas_found 1)
set(lapack_found 1) set(lapack_found 1)
set(found_intel_mkl 1) set(found_intel_mkl 1)
...@@ -302,14 +314,23 @@ elseif(WIN32 AND NOT MINGW) ...@@ -302,14 +314,23 @@ elseif(WIN32 AND NOT MINGW)
# Search for the needed libraries from the MKL. # Search for the needed libraries from the MKL.
find_library(mkl_core mkl_core ${mkl_search_path}) find_library(mkl_core mkl_core ${mkl_search_path})
set(mkl_libs ${mkl_intel} ${mkl_core})
mark_as_advanced(mkl_libs mkl_intel mkl_core)
if (DLIB_USE_MKL_SEQUENTIAL)
find_library(mkl_sequential mkl_sequential ${mkl_search_path})
mark_as_advanced(mkl_sequential)
list(APPEND mkl_libs ${mkl_sequential})
else()
find_library(mkl_thread mkl_intel_thread ${mkl_search_path}) find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
find_library(mkl_iomp libiomp5md ${mkl_search_path}) find_library(mkl_iomp libiomp5md ${mkl_search_path})
mark_as_advanced(mkl_thread mkl_iomp)
list(APPEND mkl_libs ${mkl_thread} ${mkl_iomp})
endif()
mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp)
# If we found the MKL # If we found the MKL
if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp ) if (mkl_intel AND mkl_core AND ((mkl_thread AND mkl_iomp) OR mkl_sequential))
set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ) set(blas_libraries ${mkl_libs})
set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ) set(lapack_libraries ${mkl_libs})
set(blas_found 1) set(blas_found 1)
set(lapack_found 1) set(lapack_found 1)
message(STATUS "Found Intel MKL BLAS/LAPACK library") message(STATUS "Found Intel MKL BLAS/LAPACK library")
...@@ -324,10 +345,7 @@ elseif(WIN32 AND NOT MINGW) ...@@ -324,10 +345,7 @@ elseif(WIN32 AND NOT MINGW)
set(blas_found 0) set(blas_found 0)
set(lapack_found 0) set(lapack_found 0)
endif() endif()
endif() endif()
endif() endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment