From 63087b968dbd8b3099a95da2e35b2e25075a1400 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 6 Sep 2018 13:46:23 -0500 Subject: [PATCH] adding kernel free callback and recursion guard Change-Id: I1ff6bba3503150745d7fc533c9db24480d476d23 [ROCm/rocprofiler commit: 704420bead861aaf576ab84326b57e21aa67317f] --- projects/rocprofiler/src/core/hsa_interceptor.h | 9 +++++++-- projects/rocprofiler/src/core/rocprofiler.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/rocprofiler/src/core/hsa_interceptor.h b/projects/rocprofiler/src/core/hsa_interceptor.h index 0f285d49f4..dcc495725d 100644 --- a/projects/rocprofiler/src/core/hsa_interceptor.h +++ b/projects/rocprofiler/src/core/hsa_interceptor.h @@ -50,10 +50,14 @@ SOFTWARE. (ID == ROCPROFILER_HSA_CB_ID_DEVICE) ? callbacks_.device: \ (ID == ROCPROFILER_HSA_CB_ID_MEMCOPY) ? callbacks_.memcopy: \ callbacks_.submit; \ - if (__callback != NULL) + if ((__callback != NULL) && (recursion_ == false)) #define DO_HSA_CALLBACK \ - do { __callback(__id, &data, __arg); } while (0) + do { \ + recursion_ = true; \ + __callback(__id, &data, __arg); \ + recursion_ = false; \ + } while (0) #define ISSUE_HSA_CALLBACK(ID) \ do { IS_HSA_CALLBACK(ID) { DO_HSA_CALLBACK; } } while(0) @@ -370,6 +374,7 @@ class HsaInterceptor { } static bool enable_; + static thread_local bool recursion_; static hsa_ven_amd_loader_1_01_pfn_t LoaderApiTable; static rocprofiler_hsa_callbacks_t callbacks_; static arg_t arg_; diff --git a/projects/rocprofiler/src/core/rocprofiler.cpp b/projects/rocprofiler/src/core/rocprofiler.cpp index 2fe9777b0e..14a370fcd5 100644 --- a/projects/rocprofiler/src/core/rocprofiler.cpp +++ b/projects/rocprofiler/src/core/rocprofiler.cpp @@ -885,6 +885,7 @@ hsa_status_t rocprofiler_get_time( // Static fields bool rocprofiler::HsaInterceptor::enable_ = false; +thread_local bool rocprofiler::HsaInterceptor::recursion_ = false;; rocprofiler_hsa_callbacks_t rocprofiler::HsaInterceptor::callbacks_{}; rocprofiler::HsaInterceptor::arg_t rocprofiler::HsaInterceptor::arg_{}; hsa_ven_amd_loader_1_01_pfn_t rocprofiler::HsaInterceptor::LoaderApiTable{};