Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix the incorrect MKLDNN/MKL logic in cmake #14877

Merged
merged 20 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/mshadow
Submodule mshadow updated 1 files
+8 −8 cmake/mshadow.cmake
30 changes: 30 additions & 0 deletions ci/build_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
class BuildFlavour(Enum):
WIN_CPU = 'WIN_CPU'
WIN_CPU_MKLDNN = 'WIN_CPU_MKLDNN'
WIN_CPU_MKLDNN_MKL = 'WIN_CPU_MKLDNN_MKL'
WIN_CPU_MKL = 'WIN_CPU_MKL'
WIN_GPU = 'WIN_GPU'
WIN_GPU_MKLDNN = 'WIN_GPU_MKLDNN'

Expand Down Expand Up @@ -72,8 +74,34 @@ class BuildFlavour(Enum):
'-DUSE_LAPACK=1 '
'-DUSE_DIST_KVSTORE=0 '
'-DUSE_MKL_IF_AVAILABLE=1 '
'-DUSE_MKLDNN=1 '
'-DCMAKE_BUILD_TYPE=Release')

, 'WIN_CPU_MKLDNN_MKL': ('-DUSE_CUDA=0 '
'-DUSE_CUDNN=0 '
'-DUSE_NVRTC=0 '
'-DUSE_OPENCV=1 '
'-DUSE_OPENMP=1 '
'-DUSE_PROFILER=1 '
'-DUSE_BLAS=mkl '
'-DUSE_LAPACK=1 '
'-DUSE_DIST_KVSTORE=0 '
'-DUSE_MKL_IF_AVAILABLE=1 '
'-DUSE_MKLDNN=1 '
'-DCMAKE_BUILD_TYPE=Release')

, 'WIN_CPU_MKL': ('-DUSE_CUDA=0 '
'-DUSE_CUDNN=0 '
'-DUSE_NVRTC=0 '
'-DUSE_OPENCV=1 '
'-DUSE_OPENMP=1 '
'-DUSE_PROFILER=1 '
'-DUSE_BLAS=mkl '
'-DUSE_LAPACK=1 '
'-DUSE_DIST_KVSTORE=0 '
'-DUSE_MKL_IF_AVAILABLE=1 '
'-DUSE_MKLDNN=0 '
'-DCMAKE_BUILD_TYPE=Release')
, 'WIN_GPU': ('-DUSE_CUDA=1 '
'-DUSE_CUDNN=1 '
'-DUSE_NVRTC=1 '
Expand Down Expand Up @@ -218,6 +246,8 @@ def main():
os.environ["OpenCV_DIR"] = "C:\\Program Files\\OpenCV-v3.4.1\\build"
if 'CUDA_PATH' not in os.environ:
os.environ["CUDA_PATH"] = "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.2"
if 'MKL_ROOT' not in os.environ:
os.environ["MKL_ROOT"] = "C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries\\windows\\mkl"
windows_build(args)

elif system == 'Linux' or system == 'Darwin':
Expand Down
42 changes: 42 additions & 0 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,48 @@ def compile_windows_cpu() {
}]
}

def compile_windows_cpu_mkldnn() {
return ['Build CPU MKLDNN windows':{
node(NODE_WINDOWS_CPU) {
ws('workspace/build-cpu-mkldnn') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git_win()
powershell 'py -3 ci/build_windows.py -f WIN_CPU_MKLDNN'
stash includes: 'windows_package.7z', name: 'windows_package_cpu_mkldnn'
}
}
}
}]
}

def compile_windows_cpu_mkldnn_mkl() {
return ['Build CPU MKLDNN MKL windows':{
node(NODE_WINDOWS_CPU) {
ws('workspace/build-cpu-mkldnn-mkl') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git_win()
powershell 'py -3 ci/build_windows.py -f WIN_CPU_MKLDNN_MKL'
stash includes: 'windows_package.7z', name: 'windows_package_cpu_mkldnn_mkl'
}
}
}
}]
}

def compile_windows_cpu_mkl() {
return ['Build CPU MKL windows':{
node(NODE_WINDOWS_CPU) {
ws('workspace/build-cpu-mkl') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git_win()
powershell 'py -3 ci/build_windows.py -f WIN_CPU_MKL'
stash includes: 'windows_package.7z', name: 'windows_package_cpu_mkl'
}
}
}
}]
}

def compile_windows_gpu() {
return ['Build GPU windows':{
node(NODE_WINDOWS_CPU) {
Expand Down
5 changes: 4 additions & 1 deletion ci/jenkins/Jenkinsfile_windows_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ utils.assign_node_labels(utility: 'utility', windows_cpu: 'mxnetwindows-cpu')
utils.main_wrapper(
core_logic: {
utils.parallel_stage('Build', [
custom_steps.compile_windows_cpu()
custom_steps.compile_windows_cpu(),
custom_steps.compile_windows_cpu_mkldnn(),
custom_steps.compile_windows_cpu_mkldnn_mkl(),
custom_steps.compile_windows_cpu_mkl()
])

utils.parallel_stage('Tests', [
Expand Down
16 changes: 8 additions & 8 deletions cmake/ChooseBlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
set(BLAS "Open" CACHE STRING "Selected BLAS library")
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")

if(USE_MKL_IF_AVAILABLE)
if(NOT MKL_FOUND)
find_package(MKL)
endif()
if(MKL_FOUND)
if(USE_MKLDNN)
set(BLAS "open")
else()
if(DEFINED USE_BLAS)
set(BLAS "${USE_BLAS}")
else()
if(USE_MKL_IF_AVAILABLE)
if(NOT MKL_FOUND)
find_package(MKL)
endif()
if(MKL_FOUND)
set(BLAS "MKL")
endif()
endif()
Expand Down
51 changes: 1 addition & 50 deletions cmake/Modules/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,55 +43,6 @@ endif()
# ---[ Root folders
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs")

if(USE_MKLDNN)

find_path(MKL_ROOT include/mkl_blas.h
PATHS $ENV{MKL_ROOT}
${INTEL_ROOT}/mklml
${DIRECT_DEPENDENCY_ROOTS}
DOC "Folder contains MKL"
)

# ---[ Find include dir
find_path(MKL_INCLUDE_DIR mkl_blas.h PATHS ${MKL_ROOT} PATH_SUFFIXES include)
set(__looked_for MKL_INCLUDE_DIR)

# ---[ Find libraries
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(__path_suffixes lib lib/ia32)
else()
set(__path_suffixes lib lib/intel64)
endif()

set(__mkl_libs "")

if(WIN32)
list(APPEND __mkl_libs mklml_intel)
else()
list(APPEND __mkl_libs mklml_gnu)
endif()
list(APPEND __mkl_libs mkldnn)

foreach (__lib ${__mkl_libs})
set(__mkl_lib "${__lib}")
string(TOUPPER ${__mkl_lib} __mkl_lib_upper)

if(MKL_USE_STATIC_LIBS)
set(__mkl_lib "lib${__mkl_lib}.a")
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)

list(APPEND __looked_for ${__mkl_lib_upper}_LIBRARY)
list(APPEND MKL_LIBRARIES ${${__mkl_lib_upper}_LIBRARY})
endforeach()

else(USE_MKLDNN)

# ---[ Options
mxnet_option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON)
Expand Down Expand Up @@ -193,7 +144,7 @@ else(USE_MKLDNN)
list(APPEND MKL_LIBRARIES ${MKL_RTL_LIBRARY})
endif()

endif(USE_MKLDNN)


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG ${__looked_for})
Expand Down