diff --git a/ci/build_windows.py b/ci/build_windows.py index e8658995b68e..4100e1c06135 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one @@ -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' @@ -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 ' @@ -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': diff --git a/ci/jenkins/Jenkins_steps.groovy b/ci/jenkins/Jenkins_steps.groovy index 23230ac0442f..e54c4cd7b07d 100644 --- a/ci/jenkins/Jenkins_steps.groovy +++ b/ci/jenkins/Jenkins_steps.groovy @@ -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) { @@ -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) { diff --git a/ci/jenkins/Jenkinsfile_unix_gpu b/ci/jenkins/Jenkinsfile_unix_gpu index e2a089b0469b..05d1f0d247ec 100644 --- a/ci/jenkins/Jenkinsfile_unix_gpu +++ b/ci/jenkins/Jenkinsfile_unix_gpu @@ -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', [ diff --git a/ci/jenkins/Jenkinsfile_windows_cpu b/ci/jenkins/Jenkinsfile_windows_cpu index 5bc40d625930..3dbaacb64d87 100644 --- a/ci/jenkins/Jenkinsfile_windows_cpu +++ b/ci/jenkins/Jenkinsfile_windows_cpu @@ -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', [ diff --git a/cmake/ChooseBlas.cmake b/cmake/ChooseBlas.cmake index 5f4af2d89c91..e16594794ae8 100644 --- a/cmake/ChooseBlas.cmake +++ b/cmake/ChooseBlas.cmake @@ -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() diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 70405566d8ae..8ed6fcd2c4bd 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -43,55 +43,7 @@ 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) @@ -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})