Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Closed
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
33 changes: 32 additions & 1 deletion ci/build_windows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Licensed to the Apache Software Foundation (ASF) under one
Expand Down 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_NOMKLDNN_MKL = 'WIN_CPU_NOMKLDNN_MKL'
WIN_GPU = 'WIN_GPU'
WIN_GPU_MKLDNN = 'WIN_GPU_MKLDNN'

Expand Down Expand Up @@ -72,6 +74,33 @@ 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_NOMKLDNN_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 '
Expand Down Expand Up @@ -218,6 +247,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
70 changes: 70 additions & 0 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,34 @@ def compile_unix_cmake_mkldnn_gpu() {
}]
}

def compile_unix_cmake_mkldnn_mkl_gpu() {
return ['GPU: CMake MKL MKLDNN': {
node(NODE_LINUX_CPU) {
ws('workspace/build-cmake-mkldnn-mkl-gpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_gpu', 'build_ubuntu_gpu_cmake_mkldnn_mkl', false)
utils.pack_lib('cmake_mkldnn_mkl_gpu', mx_cmake_mkldnn_mkl_lib, true)
}
}
}
}]
}

def compile_unix_cmake_nomkldnn_mkl_gpu() {
return ['GPU: CMake MKL NOMKLDNN': {
node(NODE_LINUX_CPU) {
ws('workspace/build-cmake-nomkldnn-mkl-gpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_gpu', 'build_ubuntu_gpu_cmake_nomkldnn_mkl', false)
utils.pack_lib('cmake_nomkldnn_mkl_gpu', mx_cmake_nomkldnn_mkl_lib, true)
}
}
}
}]
}

def compile_unix_cmake_gpu() {
return ['GPU: CMake': {
node(NODE_LINUX_CPU) {
Expand Down Expand Up @@ -515,6 +543,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_nomkldnn_mkl() {
return ['Build CPU NOMKLDNN MKL windows':{
node(NODE_WINDOWS_CPU) {
ws('workspace/build-cpu-nomkldnn-mkl') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git_win()
powershell 'py -3 ci/build_windows.py -f WIN_CPU_NOMKLDNN_MKL'
stash includes: 'windows_package.7z', name: 'windows_package_cpu_nomkldnn_mkl'
}
}
}
}]
}

def compile_windows_gpu() {
return ['Build GPU windows':{
node(NODE_WINDOWS_CPU) {
Expand Down
4 changes: 3 additions & 1 deletion ci/jenkins/Jenkinsfile_unix_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ core_logic: {
custom_steps.compile_unix_cmake_mkldnn_gpu(),
custom_steps.compile_unix_cmake_gpu(),
custom_steps.compile_unix_tensorrt_gpu(),
custom_steps.compile_unix_int64_gpu()
custom_steps.compile_unix_int64_gpu(),
custom_steps.compile_unix_cmake_mkl_mkldnn_gpu(),
custom_steps.compile_unix_cmake_mkl_nomkldnn_gpu()
])

utils.parallel_stage('Tests', [
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_nomkldnn_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
50 changes: 1 addition & 49 deletions cmake/Modules/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,55 +43,7 @@ endif()
# ---[ Root folders
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs")

if(USE_MKLDNN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though now it is convoluted in 1 file there is a configuration difference between full MKL and MKLML. For example, the librt library is present only in full MKL, OpenMP library needs to be configured explicitly for MKLML. Previously, I made an attempt to separate it to 2 different files, maybe you can reuse some code from there #11148

Copy link
Contributor Author

@yinghu5 yinghu5 May 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chancebair . @lebeg thank you a lot for the review. Yes, we actually need full MKL package install on CI machine. There are mainly two factors , which

  1. MKLDNN will don't depend on the MKLML in the future,
  2. second, but important, MXNET will use more MKL functions other than in MKLML.

So we decide to unlock MKLDNN (MKLML) and MKL dependency, which means,
use MKLDNN and USE_BLAS=mkl completely independent.

  1. MKLDNN is on, it will download MKLML automatically. doesn't use full MKL package.
  2. when USE_BLAS=mkl, only use the full MKL. (MKL_ROOT). won't detect MKLML (from MKLDNN).

Thanks


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 +145,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