From 699d17b73318e90c5eb2f0d5dfd75c9b1aee6ce2 Mon Sep 17 00:00:00 2001 From: Ammar ELWazir Date: Thu, 18 Aug 2022 21:46:58 -0500 Subject: [PATCH] Fixing issues caused by the plugin patches - Multithreaded Applications and plugin destruction - Fixing Async-copy trace in file plugin - Adding the assert checkups for every trace buffer flush function Change-Id: I96e096fd7ee2604931200a0b446edb5ce49959dd [ROCm/roctracer commit: 4cd7497a87c3369171aa98b89ba2f872e0710e0d] --- projects/roctracer/plugin/file/file.cpp | 2 +- .../roctracer/src/tracer_tool/tracer_tool.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/projects/roctracer/plugin/file/file.cpp b/projects/roctracer/plugin/file/file.cpp index 4f6369ab73..5b89852e88 100644 --- a/projects/roctracer/plugin/file/file.cpp +++ b/projects/roctracer/plugin/file/file.cpp @@ -322,7 +322,7 @@ class file_plugin_t { output_file = get_output_file(ACTIVITY_DOMAIN_HSA_OPS, begin->op); if (begin->op == HSA_OP_ID_COPY) { *output_file << std::dec << begin->begin_ns << ":" << begin->end_ns - << " async-copy:" << begin->correlation_id << " " << GetPid() << std::endl; + << " async-copy:" << begin->correlation_id << ":" << GetPid() << std::endl; break; } else if (begin->op == HSA_OP_ID_RESERVED1) { *output_file << std::dec << begin->pc_sample.se << " " << begin->pc_sample.cycle << " " diff --git a/projects/roctracer/src/tracer_tool/tracer_tool.cpp b/projects/roctracer/src/tracer_tool/tracer_tool.cpp index 67d5c0fdc1..79fbde8d96 100644 --- a/projects/roctracer/src/tracer_tool/tracer_tool.cpp +++ b/projects/roctracer/src/tracer_tool/tracer_tool.cpp @@ -222,11 +222,11 @@ struct roctx_trace_entry_t { } }; -roctracer::TraceBuffer roctx_trace_buffer("rocTX API", 0x200000, - [](roctx_trace_entry_t* entry) { - plugin->write_callback_record( - &entry->record, &entry->data); - }); +roctracer::TraceBuffer roctx_trace_buffer( + "rocTX API", 0x200000, [](roctx_trace_entry_t* entry) { + assert(plugin && "plugin is not initialized"); + plugin->write_callback_record(&entry->record, &entry->data); + }); // rocTX callback function void roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, @@ -265,6 +265,7 @@ struct hsa_api_trace_entry_t { roctracer::TraceBuffer hsa_api_trace_buffer( "HSA API", 0x200000, [](hsa_api_trace_entry_t* entry) { + assert(plugin && "plugin is not initialized"); plugin->write_callback_record(&entry->record, &entry->data); }); @@ -400,6 +401,7 @@ static std::optional getKernelName(uint32_t cid, const hip_api_data roctracer::TraceBuffer hip_api_trace_buffer( "HIP API", 0x200000, [](hip_api_trace_entry_t* entry) { + assert(plugin && "plugin is not initialized"); plugin->write_callback_record(&entry->record, &entry->data); }); @@ -495,6 +497,7 @@ void open_tracing_pool() { roctracer_properties_t properties{}; properties.buffer_size = 0x80000; properties.buffer_callback_fun = [](const char* begin, const char* end, void* /* arg */) { + assert(plugin && "plugin is not initialized"); plugin->write_activity_records(reinterpret_cast(begin), reinterpret_cast(end)); }; @@ -550,8 +553,6 @@ void tool_unload() { // Flush tracing pool close_tracing_pool(); roctracer::TraceBufferBase::FlushAll(); - - plugin.reset(); } // tool load method