Commit 972dd2f5 authored by Amy Zhuang's avatar Amy Zhuang Committed by Scott Cyphers

Update MKLDNN to v1.1.1. (#4051)

* Update MKLDNN to v1.1.1.

* Modify mkldnn_v1 patch.

* Modify bf16 check for mkldnn-v1.
Co-authored-by: 's avatarbaojun <32073718+baojun-nervana@users.noreply.github.com>
Co-authored-by: 's avatarSang Ik Lee <sang.ik.lee@intel.com>
parent ee54282a
...@@ -18,30 +18,30 @@ include(ExternalProject) ...@@ -18,30 +18,30 @@ include(ExternalProject)
# Includes blas 3.8.0 in mkldnn # Includes blas 3.8.0 in mkldnn
set(NGRAPH_MKLDNN_SHORT_VERSION 1) set(NGRAPH_MKLDNN_SHORT_VERSION 1)
set(NGRAPH_MKLDNN_FULL_VERSION 1.0.4.0) set(NGRAPH_MKLDNN_FULL_VERSION 1.1.1.0)
set(NGRAPH_MKLDNN_MKLML_ASSET_VERSION "v0.21") set(NGRAPH_MKLDNN_MKLML_ASSET_VERSION "v0.21")
set(NGRAPH_MKLDNN_VERSION "v1.0.4") set(NGRAPH_MKLDNN_VERSION "v1.1.1")
set(NGRAPH_MKLDNN_MKLML_VERSION "2019.0.5.20190502") set(NGRAPH_MKLDNN_MKLML_VERSION "2019.0.5.20190502")
set(NGRAPH_MKLDNN_MKLML_WIN32_VERSION "2020.0.20190813") set(NGRAPH_MKLDNN_MKLML_WIN32_VERSION "2020.0.20190813")
set(NGRAPH_MKLDNN_GIT_TAG "v1.0.4") set(NGRAPH_MKLDNN_GIT_TAG "v1.1.1")
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Fetch and install MKL-DNN # Fetch and install MKL-DNN
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
set(MKLDNN_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLDNN_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}dnnl${CMAKE_SHARED_LIBRARY_SUFFIX})
if (LINUX) if (LINUX)
set(MKLML_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLML_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX})
set(OMP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}iomp5${CMAKE_SHARED_LIBRARY_SUFFIX}) set(OMP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}iomp5${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MKLDNN_SHORT_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn${CMAKE_SHARED_LIBRARY_SUFFIX}.${NGRAPH_MKLDNN_SHORT_VERSION}) set(MKLDNN_SHORT_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}dnnl${CMAKE_SHARED_LIBRARY_SUFFIX}.${NGRAPH_MKLDNN_SHORT_VERSION})
set(MKLDNN_FULL_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn${CMAKE_SHARED_LIBRARY_SUFFIX}.${NGRAPH_MKLDNN_FULL_VERSION}) set(MKLDNN_FULL_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}dnnl${CMAKE_SHARED_LIBRARY_SUFFIX}.${NGRAPH_MKLDNN_FULL_VERSION})
elseif (APPLE) elseif (APPLE)
set(MKLML_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mklml${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLML_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mklml${CMAKE_SHARED_LIBRARY_SUFFIX})
set(OMP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}iomp5${CMAKE_SHARED_LIBRARY_SUFFIX}) set(OMP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}iomp5${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MKLDNN_SHORT_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn.${NGRAPH_MKLDNN_SHORT_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLDNN_SHORT_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}dnnl.${NGRAPH_MKLDNN_SHORT_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MKLDNN_FULL_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn.${NGRAPH_MKLDNN_FULL_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLDNN_FULL_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}dnnl.${NGRAPH_MKLDNN_FULL_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
elseif (WIN32) elseif (WIN32)
set(MKLDNN_IMPLIB mkldnn${CMAKE_STATIC_LIBRARY_SUFFIX}) set(MKLDNN_IMPLIB dnnl${CMAKE_STATIC_LIBRARY_SUFFIX})
set(MKLML_LIB mklml${CMAKE_SHARED_LIBRARY_SUFFIX}) set(MKLML_LIB mklml${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MKLML_IMPLIB mklml${CMAKE_STATIC_LIBRARY_SUFFIX}) set(MKLML_IMPLIB mklml${CMAKE_STATIC_LIBRARY_SUFFIX})
set(OMP_LIB libiomp5md${CMAKE_SHARED_LIBRARY_SUFFIX}) set(OMP_LIB libiomp5md${CMAKE_SHARED_LIBRARY_SUFFIX})
......
diff --git a/cmake/OpenMP.cmake b/cmake/OpenMP.cmake diff --git a/cmake/OpenMP.cmake b/cmake/OpenMP.cmake
index 99970659..ef88a0a7 100644 index 0bc6ea57a..4fa0a22d1 100644
--- a/cmake/OpenMP.cmake --- a/cmake/OpenMP.cmake
+++ b/cmake/OpenMP.cmake +++ b/cmake/OpenMP.cmake
@@ -28,7 +28,7 @@ if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") @@ -28,7 +28,7 @@ if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
...@@ -18,7 +18,7 @@ index 99970659..ef88a0a7 100644 ...@@ -18,7 +18,7 @@ index 99970659..ef88a0a7 100644
+macro(use_intel_omp_rt) +macro(use_intel_omp_rt)
+ # fast return + # fast return
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ set(MKLDNN_USES_INTEL_OPENMP TRUE) + set(DNNL_USES_INTEL_OPENMP TRUE)
+ return() + return()
+ endif() + endif()
+ +
...@@ -41,10 +41,10 @@ index 99970659..ef88a0a7 100644 ...@@ -41,10 +41,10 @@ index 99970659..ef88a0a7 100644
+ endif() + endif()
+ list(APPEND EXTRA_SHARED_LIBS ${IOMP5LIB}) + list(APPEND EXTRA_SHARED_LIBS ${IOMP5LIB})
+ else() + else()
+ if (MKLDNN_THREADING STREQUAL "OMP:INTEL") + if (DNNL_THREADING STREQUAL "OMP:INTEL")
+ message(${_omp_severity} "Intel OpenMP runtime could not be found. " + message(${_omp_severity} "Intel OpenMP runtime could not be found. "
+ "Please either use OpenMP runtime that comes with the compiler " + "Please either use OpenMP runtime that comes with the compiler "
+ "(via -DMKLDNN_THREADING={OMP,OMP:COMP}), or " + "(via -DDNNL_THREADING={OMP,OMP:COMP}), or "
+ "explicitely provide the path to libiomp with the " + "explicitely provide the path to libiomp with the "
+ "-DCMAKE_LIBRARY_PATH option") + "-DCMAKE_LIBRARY_PATH option")
+ endif() + endif()
...@@ -54,27 +54,27 @@ index 99970659..ef88a0a7 100644 ...@@ -54,27 +54,27 @@ index 99970659..ef88a0a7 100644
if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
add_definitions(/Qpar) add_definitions(/Qpar)
add_definitions(/openmp) add_definitions(/openmp)
@@ -78,6 +114,7 @@ if (MKLDNN_CPU_RUNTIME MATCHES "OMP") @@ -79,6 +115,7 @@ if (DNNL_CPU_THREADING_RUNTIME MATCHES "OMP")
message(${_omp_severity} "OpenMP library could not be found. " # Override CPU threading to sequential if allowed to proceed
"Proceeding might lead to highly sub-optimal performance.") set(DNNL_CPU_THREADING_RUNTIME "SEQ")
endif() endif()
+ use_intel_omp_rt() + use_intel_omp_rt()
else() else()
# Compilation happens with OpenMP to enable `#pragma omp simd` # Compilation happens with OpenMP to enable `#pragma omp simd`
# but during linkage OpenMP dependency should be avoided # but during linkage OpenMP dependency should be avoided
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f99ec31ce..b3c1d9bb8 100644 index 4c774a11b..56fb4e294 100644
--- a/src/CMakeLists.txt --- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt +++ b/src/CMakeLists.txt
@@ -73,8 +73,10 @@ endif() @@ -78,8 +78,10 @@ endif()
add_library(${LIB_NAME} add_library(${LIB_NAME} ${DNNL_LIBRARY_TYPE}
${MKLDNN_LIBRARY_TYPE} ${HEADERS} ${${LIB_NAME}_SUB_OBJS}) ${VERSION_RESOURCE_FILE} ${HEADERS} ${${LIB_NAME}_SUB_OBJS})
-set_property(TARGET ${LIB_NAME} PROPERTY VERSION "${MKLDNN_VERSION_MAJOR}.${MKLDNN_VERSION_MINOR}") -set_property(TARGET ${LIB_NAME} PROPERTY VERSION "${DNNL_VERSION_MAJOR}.${DNNL_VERSION_MINOR}")
-set_property(TARGET ${LIB_NAME} PROPERTY SOVERSION "${MKLDNN_VERSION_MAJOR}") -set_property(TARGET ${LIB_NAME} PROPERTY SOVERSION "${DNNL_VERSION_MAJOR}")
+if(MKLDNN_LIB_VERSIONING_ENABLE) +if(MKLDNN_LIB_VERSIONING_ENABLE)
+ set_property(TARGET ${LIB_NAME} PROPERTY VERSION "${MKLDNN_VERSION_MAJOR}.${MKLDNN_VERSION_MINOR}") + set_property(TARGET ${LIB_NAME} PROPERTY VERSION "${DNNL_VERSION_MAJOR}.${DNNL_VERSION_MINOR}")
+ set_property(TARGET ${LIB_NAME} PROPERTY SOVERSION "${MKLDNN_VERSION_MAJOR}") + set_property(TARGET ${LIB_NAME} PROPERTY SOVERSION "${DNNL_VERSION_MAJOR}")
+endif() +endif()
set_property(TARGET ${LIB_NAME} PROPERTY PUBLIC_HEADER ${HEADERS}) set_property(TARGET ${LIB_NAME} PROPERTY PUBLIC_HEADER ${HEADERS})
......
...@@ -1746,12 +1746,27 @@ bool runtime::cpu::mkldnn_utils::is_bf16_supported() ...@@ -1746,12 +1746,27 @@ bool runtime::cpu::mkldnn_utils::is_bf16_supported()
{ {
try try
{ {
mkldnn::memory::dims dims{2, 3, 4, 5}; mkldnn::memory::dims input_dims{1, 1, 3, 5};
mkldnn::memory::dims strides{60, 20, 5, 1}; mkldnn::memory::dims input_strides{15, 15, 5, 1};
auto input_desc = mkldnn::memory::desc(dims, mkldnn::memory::data_type::f32, strides); mkldnn::memory::dims window_shape{2, 3};
auto result_desc = mkldnn::memory::desc(dims, mkldnn::memory::data_type::bf16, strides); mkldnn::memory::dims window_movement_strides{1, 1};
auto reorder_prim_desc = mkldnn::reorder::primitive_desc( mkldnn::memory::dims padding_below{0, 0};
executor::global_cpu_engine, input_desc, executor::global_cpu_engine, result_desc); mkldnn::memory::dims padding_above{0, 0};
mkldnn::memory::dims result_dims{1, 1, 2, 3};
auto input_desc =
mkldnn::memory::desc(input_dims, mkldnn::memory::data_type::bf16, input_strides);
auto result_desc = mkldnn::memory::desc(
result_dims, mkldnn::memory::data_type::bf16, mkldnn::memory::format_tag::any);
auto maxpool_desc = mkldnn::pooling_forward::desc(mkldnn::prop_kind::forward_inference,
mkldnn::algorithm::pooling_max,
input_desc,
result_desc,
window_movement_strides,
window_shape,
padding_below,
padding_above);
mkldnn::engine cpu_engine(mkldnn::engine::kind::cpu, 0);
auto maxpool_prim_desc = mkldnn::pooling_forward::primitive_desc(maxpool_desc, cpu_engine);
} }
catch (const mkldnn::error& e) catch (const mkldnn::error& e)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment