From 9b560ab0b17ccb3e0ca6098536b7e23f5debf60e Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Mon, 17 Mar 2025 21:33:40 +0100 Subject: [PATCH 1/3] Add -g to OneDNN build flags --- third_party/mkl_dnn/mkldnn_v1.BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/mkl_dnn/mkldnn_v1.BUILD b/third_party/mkl_dnn/mkldnn_v1.BUILD index 1a14edaec30ea8..ae00d6a53c4483 100644 --- a/third_party/mkl_dnn/mkldnn_v1.BUILD +++ b/third_party/mkl_dnn/mkldnn_v1.BUILD @@ -102,6 +102,7 @@ _COPTS_LIST = select({ "-UUSE_CBLAS", "-DDNNL_ENABLE_MAX_CPU_ISA", "-fno-omit-frame-pointer", + "-g", ] + tf_openmp_copts() _INCLUDES_LIST = [ From df3b5292cda2f7fa6a0579152b1535937afe519c Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Fri, 21 Mar 2025 19:22:29 +0100 Subject: [PATCH 2/3] Backport 54c3d053175c3fa02ad02aad7dc504baf4f859db as well --- third_party/mkl_dnn/onednn_unwind_stack.patch | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/third_party/mkl_dnn/onednn_unwind_stack.patch b/third_party/mkl_dnn/onednn_unwind_stack.patch index 2920d7e5685703..36d6e1153a2107 100644 --- a/third_party/mkl_dnn/onednn_unwind_stack.patch +++ b/third_party/mkl_dnn/onednn_unwind_stack.patch @@ -1,11 +1,5 @@ -commit 2ae24507835242a8d217b40fde629ef671b904de -Author: Wierschem, Keola -Date: Thu Sep 15 15:31:30 2022 -0700 - - cpu: x64: update RBP on entry to jit code - diff --git a/src/cpu/x64/jit_generator.hpp b/src/cpu/x64/jit_generator.hpp -index 60ec65211c..6399bc64d1 100644 +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( @@ -18,7 +12,7 @@ index 60ec65211c..6399bc64d1 100644 Xbyak::Operand::R12, Xbyak::Operand::R13, Xbyak::Operand::R14, -@@ -194,8 +194,11 @@ public: +@@ -194,11 +194,17 @@ public: uni_vmovdqu(ptr[rsp + i * xmm_len], Xbyak::Xmm(xmm_to_preserve_start + i)); } @@ -28,6 +22,29 @@ index 60ec65211c..6399bc64d1 100644 + // 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 ++#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; From debc07279b26a4718ca36419664afeba60c9c0f4 Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Fri, 21 Mar 2025 19:30:36 +0100 Subject: [PATCH 3/3] Renable memory debug with new stack trace patch --- third_party/mkl_dnn/mkldnn_v1.BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/mkl_dnn/mkldnn_v1.BUILD b/third_party/mkl_dnn/mkldnn_v1.BUILD index ae00d6a53c4483..71505bf0c2063a 100644 --- a/third_party/mkl_dnn/mkldnn_v1.BUILD +++ b/third_party/mkl_dnn/mkldnn_v1.BUILD @@ -101,6 +101,7 @@ _COPTS_LIST = select({ "-UUSE_MKL", "-UUSE_CBLAS", "-DDNNL_ENABLE_MAX_CPU_ISA", + "-DDNNL_ENABLE_MEM_DEBUG", "-fno-omit-frame-pointer", "-g", ] + tf_openmp_copts()