diff --git a/third_party/mkl_dnn/mkldnn_v1.BUILD b/third_party/mkl_dnn/mkldnn_v1.BUILD index 1a14edaec30ea8..71505bf0c2063a 100644 --- a/third_party/mkl_dnn/mkldnn_v1.BUILD +++ b/third_party/mkl_dnn/mkldnn_v1.BUILD @@ -101,7 +101,9 @@ _COPTS_LIST = select({ "-UUSE_MKL", "-UUSE_CBLAS", "-DDNNL_ENABLE_MAX_CPU_ISA", + "-DDNNL_ENABLE_MEM_DEBUG", "-fno-omit-frame-pointer", + "-g", ] + tf_openmp_copts() _INCLUDES_LIST = [ diff --git a/third_party/mkl_dnn/onednn_unwind_stack.patch b/third_party/mkl_dnn/onednn_unwind_stack.patch new file mode 100644 index 00000000000000..36d6e1153a2107 --- /dev/null +++ b/third_party/mkl_dnn/onednn_unwind_stack.patch @@ -0,0 +1,50 @@ +diff --git a/src/cpu/x64/jit_generator.hpp b/src/cpu/x64/jit_generator.hpp +index a6b1c3397e..c8ebe0f33b 100644 +--- a/src/cpu/x64/jit_generator.hpp ++++ b/src/cpu/x64/jit_generator.hpp +@@ -103,8 +103,8 @@ static inline void tc_configure_tile( + + #ifdef XBYAK64 + constexpr Xbyak::Operand::Code abi_save_gpr_regs[] = { +- Xbyak::Operand::RBX, + Xbyak::Operand::RBP, ++ Xbyak::Operand::RBX, + Xbyak::Operand::R12, + Xbyak::Operand::R13, + Xbyak::Operand::R14, +@@ -194,11 +194,17 @@ public: + uni_vmovdqu(ptr[rsp + i * xmm_len], + Xbyak::Xmm(xmm_to_preserve_start + i)); + } +- for (size_t i = 0; i < num_abi_save_gpr_regs; ++i) ++ for (size_t i = 0; i < num_abi_save_gpr_regs; ++i) { + push(Xbyak::Reg64(abi_save_gpr_regs[i])); ++ // Stack magic: save rsp into rbp state to be able to unwind stack. ++ if (i == 0) mov(rbp, rsp); ++ } ++#ifndef DNNL_ENABLE_MEM_DEBUG ++ // do not use RBP in mem debug mode to enable backtracing from jit code + if (is_valid_isa(avx512_core)) { + mov(reg_EVEX_max_8b_offt, 2 * EVEX_max_8b_offt); + } ++#endif + + #ifdef DNNL_ENABLE_MEM_DEBUG + // This section poisons vector registers with NaNs to catch situations +@@ -277,6 +283,8 @@ public: + + int scale = 0; + ++#ifndef DNNL_ENABLE_MEM_DEBUG ++ // do not use RBP in mem debug mode to enable backtracing from jit code + if (EVEX_max_8b_offt <= offt && offt < 3 * EVEX_max_8b_offt) { + offt = offt - 2 * EVEX_max_8b_offt; + scale = 1; +@@ -285,6 +293,7 @@ public: + offt = offt - 4 * EVEX_max_8b_offt; + scale = 2; + } ++#endif + + auto re = RegExp() + base + offt; + if (scale) re = re + reg_EVEX_max_8b_offt * scale;