Move trace_buffer.h to the tool directory
A trace buffer is used to efficiently store synchronous event records so that they can be processed later, possibly in a different thread, when the buffer is flushed. This helps reduce the latency added by tracing API calls. The API does not need to use trace buffers as synchronous events are directly reported to the client with callbacks, and asynchronous events (activities) are saved in memory pools. The implentation of HSA asynchronous memory copy activities was using a trace buffer shared with the tracer tool to write the records to a file (async_copy_trace.txt), instead of using a memory pool and reporting the activity to the client. Removed the asynchronous memory copies trace buffer, and updated hsa_async_copy_handler to use the pool specified when the activity was enabled. Updated the tracer tool to read HSA_OP_ID_COPY records out of the default memory pool and write them to async_copy_trace.txt. Move trace_buffer.h to test/tool as tracer_tool.cpp is now the only file using it. Change-Id: Ida95aba2eaf3c3f2a979ed6c2b060374017b7424
This commit is contained in:
committed by
Laurent Morichetti
parent
48f4c82685
commit
61f35b0204
+13
-13
@@ -39,7 +39,7 @@
|
||||
#include <ext/hsa_rt_utils.hpp>
|
||||
|
||||
#include "src/core/loader.h"
|
||||
#include "src/core/trace_buffer.h"
|
||||
#include "test/tool/trace_buffer.h"
|
||||
#include "util/evt_stats.h"
|
||||
#include "util/hsa_rsrc_factory.h"
|
||||
#include "util/xml.h"
|
||||
@@ -357,14 +357,6 @@ void hsa_api_flush_cb(hsa_api_trace_entry_t* entry) {
|
||||
fflush(hsa_api_file_handle);
|
||||
}
|
||||
|
||||
void hsa_activity_callback(uint32_t op, activity_record_t* record, void* arg) {
|
||||
static uint64_t index = 0;
|
||||
fprintf(hsa_async_copy_file_handle, "%lu:%lu async-copy:%lu:%u\n", record->begin_ns,
|
||||
record->end_ns, index, my_pid);
|
||||
fflush(hsa_async_copy_file_handle);
|
||||
index++;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HIP API tracing
|
||||
|
||||
@@ -648,7 +640,13 @@ void pool_activity_callback(const char* begin, const char* end, void* arg) {
|
||||
}
|
||||
break;
|
||||
case ACTIVITY_DOMAIN_HSA_OPS:
|
||||
if (record->op == HSA_OP_ID_RESERVED1) {
|
||||
if (record->op == HSA_OP_ID_COPY) {
|
||||
static uint64_t index = 0;
|
||||
fprintf(hsa_async_copy_file_handle, "%lu:%lu async-copy:%lu:%u\n", record->begin_ns,
|
||||
record->end_ns, index, my_pid);
|
||||
fflush(hsa_async_copy_file_handle);
|
||||
index++;
|
||||
} else if (record->op == HSA_OP_ID_RESERVED1) {
|
||||
fprintf(pc_sample_file_handle, "%u %lu 0x%lx %s\n", record->pc_sample.se,
|
||||
record->pc_sample.cycle, record->pc_sample.pc, name);
|
||||
fflush(pc_sample_file_handle);
|
||||
@@ -1032,11 +1030,13 @@ extern "C" PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
|
||||
hsa_async_copy_file_handle = open_output_file(output_prefix, "async_copy_trace.txt");
|
||||
|
||||
// initialize HSA tracing
|
||||
roctracer::hsa_ops_properties_t ops_properties{
|
||||
table, reinterpret_cast<activity_async_callback_t>(hsa_activity_callback), NULL,
|
||||
output_prefix};
|
||||
roctracer::hsa_ops_properties_t ops_properties{};
|
||||
ops_properties.table = table;
|
||||
roctracer_set_properties(ACTIVITY_DOMAIN_HSA_OPS, &ops_properties);
|
||||
|
||||
// Allocating tracing pool
|
||||
open_tracing_pool();
|
||||
|
||||
fprintf(stdout, " HSA-activity-trace()\n");
|
||||
fflush(stdout);
|
||||
ROCTRACER_CALL(roctracer_enable_op_activity(ACTIVITY_DOMAIN_HSA_OPS, HSA_OP_ID_COPY));
|
||||
|
||||
Reference in New Issue
Block a user