forked from BVLC/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
131 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,110 @@ | ||
# - Find Intel MKL | ||
# Find the MKL libraries | ||
# | ||
# Options: | ||
# | ||
# MKL_STATAIC : use static linking | ||
# MKL_MULTI_THREADED: use multi-threading | ||
# MKL_SDL : Single Dynamic Library interface | ||
# MKL_USE_SINGLE_DYNAMIC_LIBRARY : use single dynamic library interface | ||
# MKL_USE_STATIC_LIBS : use static libraries | ||
# MKL_MULTI_THREADED : use multi-threading | ||
# | ||
# This module defines the following variables: | ||
# | ||
# MKL_FOUND : True if MKL_INCLUDE_DIR are found | ||
# MKL_INCLUDE_DIR : where to find mkl.h, etc. | ||
# MKL_INCLUDE_DIRS : set when MKL_INCLUDE_DIR found | ||
# MKL_LIBRARIES : the library to link against. | ||
# MKL_FOUND : True mkl is found | ||
# MKL_INCLUDE_DIR : unclude directory | ||
# MKL_LIBRARIES : the libraries to link against. | ||
|
||
|
||
include(FindPackageHandleStandardArgs) | ||
# ---[ Options | ||
caffe_option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON) | ||
caffe_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) | ||
caffe_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) | ||
|
||
# ---[ Root folders | ||
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs") | ||
set(MKL_ROOT ${INTEL_ROOT}/mkl CACHE PATH "Folder contains MKL") | ||
|
||
# Find include dir | ||
find_path(MKL_INCLUDE_DIR mkl.h | ||
PATHS ${MKL_ROOT}/include) | ||
|
||
# Find include directory | ||
# There is no include folder under linux | ||
if(WIN32) | ||
find_path(INTEL_INCLUDE_DIR omp.h | ||
PATHS ${INTEL_ROOT}/include) | ||
set(MKL_INCLUDE_DIR ${MKL_INCLUDE_DIR} ${INTEL_INCLUDE_DIR}) | ||
endif() | ||
find_path(MKL_ROOT include/mkl.h PATHS $ENV{MKL_ROOT} ${INTEL_ROOT}/mkl | ||
DOC "Folder contains MKL") | ||
|
||
# Find libraries | ||
# ---[ Find include dir | ||
find_path(MKL_INCLUDE_DIR mkl.h PATHS ${MKL_ROOT} PATH_SUFFIXES include) | ||
set(__looked_for MKL_INCLUDE_DIR) | ||
|
||
# Handle suffix | ||
set(_MKL_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
# ---[ Find libraries | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
set(__path_suffixes lib lib/ia32) | ||
else() | ||
set(__path_suffixes lib lib/intel64) | ||
endif() | ||
|
||
if(WIN32) | ||
if(MKL_STATAIC) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib) | ||
else() | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES _dll.lib) | ||
endif() | ||
set(__mkl_libs "") | ||
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY) | ||
list(APPEND __mkl_libs rt) | ||
else() | ||
if(MKL_STATAIC) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
if(WIN32) | ||
list(APPEND __mkl_libs intel_c) | ||
else() | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES .so) | ||
list(APPEND __mkl_libs intel gf) | ||
endif() | ||
else() | ||
list(APPEND __mkl_libs intel_lp64 gf_lp64) | ||
endif() | ||
|
||
if(MKL_MULTI_THREADED) | ||
list(APPEND __mkl_libs intel_thread) | ||
else() | ||
list(APPEND __mkl_libs sequential) | ||
endif() | ||
|
||
list(APPEND __mkl_libs core cdft_core) | ||
endif() | ||
|
||
|
||
# MKL is composed by four layers: Interface, Threading, Computational and RTL | ||
foreach (__lib ${__mkl_libs}) | ||
set(__mkl_lib "mkl_${__lib}") | ||
string(TOUPPER ${__mkl_lib} __mkl_lib_upper) | ||
|
||
if(MKL_SDL) | ||
find_library(MKL_LIBRARY mkl_rt | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
if(MKL_USE_STATIC_LIBS) | ||
set(__mkl_lib "lib${__mkl_lib}.a") | ||
endif() | ||
|
||
set(MKL_MINIMAL_LIBRARY ${MKL_LIBRARY}) | ||
else() | ||
######################### Interface layer ####################### | ||
if(WIN32) | ||
set(MKL_INTERFACE_LIBNAME mkl_intel_c) | ||
else() | ||
set(MKL_INTERFACE_LIBNAME mkl_intel) | ||
endif() | ||
find_library(${__mkl_lib_upper}_LIBRARY | ||
NAMES ${__mkl_lib} | ||
PATHS ${MKL_ROOT} "${MKL_INCLUDE_DIR}/.." | ||
PATH_SUFFIXES ${__path_suffixes} | ||
DOC "The path to Intel(R) MKL ${__mkl_lib} library") | ||
mark_as_advanced(${__mkl_lib_upper}_LIBRARY) | ||
|
||
find_library(MKL_INTERFACE_LIBRARY ${MKL_INTERFACE_LIBNAME} | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
list(APPEND __looked_for ${__mkl_lib_upper}_LIBRARY) | ||
list(APPEND MKL_LIBRARIES ${${__mkl_lib_upper}_LIBRARY}) | ||
endforeach() | ||
|
||
######################## Threading layer ######################## | ||
if(MKL_MULTI_THREADED) | ||
set(MKL_THREADING_LIBNAME mkl_intel_thread) | ||
else() | ||
set(MKL_THREADING_LIBNAME mkl_sequential) | ||
endif() | ||
|
||
find_library(MKL_THREADING_LIBRARY ${MKL_THREADING_LIBNAME} | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) | ||
if (MKL_USE_STATIC_LIBS) | ||
set(__iomp5_libs iomp5 libiomp5mt.lib) | ||
else() | ||
set(__iomp5_libs iomp5 libiomp5md.lib) | ||
endif() | ||
|
||
####################### Computational layer ##################### | ||
find_library(MKL_CORE_LIBRARY mkl_core | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
find_library(MKL_FFT_LIBRARY mkl_cdft_core | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
find_library(MKL_SCALAPACK_LIBRARY mkl_scalapack_core | ||
PATHS ${MKL_ROOT}/lib/ia32/) | ||
if(WIN32) | ||
find_path(INTEL_INCLUDE_DIR omp.h PATHS ${INTEL_ROOT} PATH_SUFFIXES include) | ||
list(APPEND __looked_for INTEL_INCLUDE_DIR) | ||
endif() | ||
|
||
############################ RTL layer ########################## | ||
if(WIN32) | ||
set(MKL_RTL_LIBNAME libiomp5md) | ||
else() | ||
set(MKL_RTL_LIBNAME libiomp5) | ||
endif() | ||
find_library(MKL_RTL_LIBRARY ${MKL_RTL_LIBNAME} | ||
PATHS ${INTEL_RTL_ROOT}/lib) | ||
find_library(MKL_RTL_LIBRARY ${__iomp5_libs} | ||
PATHS ${INTEL_RTL_ROOT} ${INTEL_ROOT}/compiler ${MKL_ROOT}/.. ${MKL_ROOT}/../compiler | ||
PATH_SUFFIXES ${__path_suffixes} | ||
DOC "Path to Path to OpenMP runtime library") | ||
|
||
set(MKL_LIBRARY ${MKL_INTERFACE_LIBRARY} ${MKL_THREADING_LIBRARY} ${MKL_CORE_LIBRARY} ${MKL_FFT_LIBRARY} ${MKL_SCALAPACK_LIBRARY} ${MKL_RTL_LIBRARY}) | ||
set(MKL_MINIMAL_LIBRARY ${MKL_INTERFACE_LIBRARY} ${MKL_THREADING_LIBRARY} ${MKL_CORE_LIBRARY} ${MKL_RTL_LIBRARY}) | ||
list(APPEND __looked_for MKL_RTL_LIBRARY) | ||
list(APPEND MKL_LIBRARIES ${MKL_RTL_LIBRARY}) | ||
endif() | ||
|
||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_MKL_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
|
||
find_package_handle_standard_args(MKL DEFAULT_MSG | ||
MKL_INCLUDE_DIR MKL_LIBRARY MKL_MINIMAL_LIBRARY) | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(MKL DEFAULT_MSG ${__looked_for}) | ||
|
||
if(MKL_FOUND) | ||
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR}) | ||
set(MKL_LIBRARIES ${MKL_LIBRARY}) | ||
set(MKL_MINIMAL_LIBRARIES ${MKL_LIBRARY}) | ||
message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}") | ||
endif() | ||
|
||
caffe_clear_vars(__looked_for __mkl_libs __path_suffixes __lib_suffix __iomp5_libs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters