Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions third_party/mkl_dnn/mkldnn_v1.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
50 changes: 50 additions & 0 deletions third_party/mkl_dnn/onednn_unwind_stack.patch
Original file line number Diff line number Diff line change
@@ -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;