diff --git a/projects/roctracer/script/kfdap.py b/projects/roctracer/script/kfdap.py index d822cf2752..c46bf60d78 100755 --- a/projects/roctracer/script/kfdap.py +++ b/projects/roctracer/script/kfdap.py @@ -406,8 +406,7 @@ class API_DescrParser: call_id = self.api_id[call]; ret_type = struct['ret'] self.content_h += ret_type + ' ' + call + '_callback(' + struct['args'] + ') {\n' # 'static ' + - if call == 'hsaKmtOpenKFD': - self.content_h += ' if (' + name + '_table == NULL) intercept_KFDApiTable();\n' + self.content_h += ' if (' + name + '_table == NULL) intercept_KFDApiTable();\n' self.content_h += ' kfd_api_data_t api_data{};\n' for var in struct['alst']: self.content_h += ' api_data.args.' + call + '.' + var.replace("[]","") + ' = ' + var.replace("[]","") + ';\n' @@ -525,7 +524,7 @@ class API_DescrParser: self.content_cpp += ' return true;\n'; self.content_cpp += '}\n\n'; - if call != '-': + if call != '-' and call != 'hsaKmtCloseKFD' and call != 'hsaKmtOpenKFD': self.content_cpp += 'PUBLIC_API ' + struct['ret'] + " " + call + '(' + struct['args'] + ') { return roctracer::kfd_support::' + call + '_callback(' for i in range(0,len(struct['alst'])): if i == (len(struct['alst'])-1): diff --git a/projects/roctracer/test/tool/tracer_tool.cpp b/projects/roctracer/test/tool/tracer_tool.cpp index f300c69388..ad1e9ee3f7 100644 --- a/projects/roctracer/test/tool/tracer_tool.cpp +++ b/projects/roctracer/test/tool/tracer_tool.cpp @@ -435,6 +435,7 @@ void hcc_activity_callback(const char* begin, const char* end, void* arg) { // KFD API tracing // KFD API callback function +static thread_local bool in_kfd_api_callback = false; void kfd_api_callback( uint32_t domain, uint32_t cid, @@ -442,6 +443,8 @@ void kfd_api_callback( void* arg) { (void)arg; + if (in_kfd_api_callback) return; + in_kfd_api_callback = true; const kfd_api_data_t* data = reinterpret_cast(callback_data); if (data->phase == ACTIVITY_API_PHASE_ENTER) { kfd_begin_timestamp = timer->timestamp_fn_ns(); @@ -451,6 +454,7 @@ void kfd_api_callback( os << kfd_begin_timestamp << ":" << end_timestamp << " " << GetPid() << ":" << GetTid() << " " << kfd_api_data_pair_t(cid, *data); fprintf(kfd_api_file_handle, "%s\n", os.str().c_str()); } + in_kfd_api_callback = false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////