From 3766a9cd06353d3e3a321da56470d7d8a39840dc Mon Sep 17 00:00:00 2001 From: baihuawei Date: Wed, 12 Jan 2022 15:44:27 +0800 Subject: [PATCH] oneDNN patch --- cmake/external_libs/mkl_dnn.cmake | 1 + .../onednn/0001-fix-user-threadpool-bug.patch | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 third_party/patch/onednn/0001-fix-user-threadpool-bug.patch diff --git a/cmake/external_libs/mkl_dnn.cmake b/cmake/external_libs/mkl_dnn.cmake index be69f0296c0..9ac1be5fb06 100644 --- a/cmake/external_libs/mkl_dnn.cmake +++ b/cmake/external_libs/mkl_dnn.cmake @@ -21,6 +21,7 @@ else() LIBS dnnl mkldnn URL ${REQ_URL} MD5 ${MD5} + PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF -DDNNL_ENABLE_CONCURRENT_EXEC=ON) endif() diff --git a/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch b/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch new file mode 100644 index 00000000000..f5256517751 --- /dev/null +++ b/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch @@ -0,0 +1,20 @@ +diff --git a/src/common/dnnl_thread.hpp b/src/common/dnnl_thread.hpp +index 342bc3b00..0b9190f9c 100644 +--- a/src/common/dnnl_thread.hpp ++++ b/src/common/dnnl_thread.hpp +@@ -104,10 +104,11 @@ inline int dnnl_get_max_threads() { + def_max_threads + = (int)dnnl::impl::cpu::platform::get_max_threads_to_use(); + assert(def_max_threads > 0); +- // Use the default value if the threadpool-provided is outside the range +- // [1, def_max_threads] +- return tp ? std::min(std::max(1, tp->get_num_threads()), def_max_threads) +- : def_max_threads; ++ ++ // Make user responsible for number of threads provided at execution time. ++ // This relates to the fact that the library may identify `def_max_threads` ++ // incorrectly for a platform. ++ return tp ? std::max(1, tp->get_num_threads()) : def_max_threads; + } + inline int dnnl_in_parallel() { + using namespace dnnl::impl::threadpool_utils;