From cc4558fb4ef62d64dccecb208a167573de385412 Mon Sep 17 00:00:00 2001 From: Glue Crow Date: Tue, 25 Apr 2017 16:46:17 +0800 Subject: [PATCH 1/3] Supports finding MKL on Windows --- cmake/Modules/FindMKL.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 8ac6fc0c1e3..7c9a704da35 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -19,7 +19,13 @@ caffe_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT MKL_USE_SINGL 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") +if(WIN32) + set(ProgramFilesx86 "ProgramFiles(x86)") + set(INTEL_ROOT $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows CACHE PATH "Folder contains intel libs") +endif() +if(UNIX) + set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs") +endif() find_path(MKL_ROOT include/mkl.h PATHS $ENV{MKLROOT} ${INTEL_ROOT}/mkl DOC "Folder contains MKL") From 1e3275a6396b75797be18b95f91c23b94979c9a6 Mon Sep 17 00:00:00 2001 From: Glue Crow Date: Wed, 26 Apr 2017 04:47:55 +0800 Subject: [PATCH 2/3] Change the library links according to https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor --- cmake/Modules/FindMKL.cmake | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 7c9a704da35..dcb684ea212 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -22,8 +22,7 @@ caffe_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT MKL_USE_SINGL if(WIN32) set(ProgramFilesx86 "ProgramFiles(x86)") set(INTEL_ROOT $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows CACHE PATH "Folder contains intel libs") -endif() -if(UNIX) +else() set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs") endif() find_path(MKL_ROOT include/mkl.h PATHS $ENV{MKLROOT} ${INTEL_ROOT}/mkl @@ -68,8 +67,16 @@ foreach (__lib ${__mkl_libs}) set(__mkl_lib "mkl_${__lib}") string(TOUPPER ${__mkl_lib} __mkl_lib_upper) - if(MKL_USE_STATIC_LIBS) - set(__mkl_lib "lib${__mkl_lib}.a") + if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) + if(MKL_USE_STATIC_LIBS) + if(NOT WIN32) + set(__mkl_lib "lib${__mkl_lib}.a") + endif() + else() + if(WIN32) + set(__mkl_lib "${__mkl_lib}_dll") + endif() + endif() endif() find_library(${__mkl_lib_upper}_LIBRARY @@ -84,17 +91,8 @@ foreach (__lib ${__mkl_libs}) endforeach() -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() - - if(WIN32) - find_path(INTEL_INCLUDE_DIR omp.h PATHS ${INTEL_ROOT} PATH_SUFFIXES include) - list(APPEND __looked_for INTEL_INCLUDE_DIR) - endif() +if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY AND MKL_MULTI_THREADED) + set(__iomp5_libs iomp5 libiomp5md) find_library(MKL_RTL_LIBRARY ${__iomp5_libs} PATHS ${INTEL_RTL_ROOT} ${INTEL_ROOT}/compiler ${MKL_ROOT}/.. ${MKL_ROOT}/../compiler From 63bd20a796c2f183ced0b641365623c3b949fee7 Mon Sep 17 00:00:00 2001 From: Glue Crow Date: Wed, 26 Apr 2017 05:33:04 +0800 Subject: [PATCH 3/3] Remove mkl_gf* and mkl_cdft_core --- cmake/Modules/FindMKL.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index dcb684ea212..a77aff1a8d8 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -47,10 +47,12 @@ else() if(WIN32) list(APPEND __mkl_libs intel_c) else() - list(APPEND __mkl_libs intel gf) + list(APPEND __mkl_libs intel) + #list(APPEND __mkl_libs intel gf) endif() else() - list(APPEND __mkl_libs intel_lp64 gf_lp64) + list(APPEND __mkl_libs intel_lp64) + #list(APPEND __mkl_libs intel_lp64 intel_gf_lp64) endif() if(MKL_MULTI_THREADED) @@ -59,7 +61,8 @@ else() list(APPEND __mkl_libs sequential) endif() - list(APPEND __mkl_libs core cdft_core) + list(APPEND __mkl_libs core) + #list(APPEND __mkl_libs core cdft_core) endif()