From e576d187587b97375a86a132d709a9ab150d42a7 Mon Sep 17 00:00:00 2001 From: baihuawei Date: Mon, 28 Mar 2022 11:04:57 +0800 Subject: [PATCH] add patch for onednn --- cmake/external_libs/mkl_dnn.cmake | 1 + .../0003-fix-zero-threads-identified-on-AMD.patch | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch diff --git a/cmake/external_libs/mkl_dnn.cmake b/cmake/external_libs/mkl_dnn.cmake index b991e176579..2f841903b40 100644 --- a/cmake/external_libs/mkl_dnn.cmake +++ b/cmake/external_libs/mkl_dnn.cmake @@ -28,6 +28,7 @@ else() MD5 ${MD5} PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0002-fix-pool-nthr-bug.patch + PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF ${USE_MS_THREADPOOL} -DDNNL_ENABLE_CONCURRENT_EXEC=ON) endif() diff --git a/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch b/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch new file mode 100644 index 00000000000..9118ffc295e --- /dev/null +++ b/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch @@ -0,0 +1,13 @@ +diff --git a/src/cpu/platform.cpp b/src/cpu/platform.cpp +index 1397073ba..041a3436f 100644 +--- a/src/cpu/platform.cpp ++++ b/src/cpu/platform.cpp +@@ -154,6 +154,8 @@ unsigned get_num_cores() { + // function supports process affinity. + unsigned get_max_threads_to_use() { + int num_cores_per_socket = (int)dnnl::impl::cpu::platform::get_num_cores(); ++ if (num_cores_per_socket == 0) ++ num_cores_per_socket = std::thread::hardware_concurrency(); + #if defined(_WIN32) + DWORD_PTR proc_affinity_mask; + DWORD_PTR sys_affinity_mask;