Remove the roctx range message stack
The range message stack is mirrored in case ranges are pushed or popped while tracing is stopped (by the tracer tool?). When a stop event is reported, the tracer tool emits RangePop events by unwinding the stack, then when the start event is reported, it emits RangePush events again by unwinding the stack. The issue is that the RangePush events should be emitted in reverse order. For example: RangePush(M1); RangePush(M2); \ TracerStop; RangePop; RangePop; \ ...; \ TracerStart; RangePush(M2); RangePush(M1); \ <- In the wrong order RangePop; RangePop; It could be fixed by reversing the stack in RangeStackIterate but is it worth it? The roctx range markers are supposed to be unintrusive so that they can be left in the application even when it isn't being traced. Simplifying the roctx API and reducing its added latency by removing the range message stack mirroring seems like the better choise. TODO: A future change should make roctx events immune to tracer start and tracer stop requests. Or simply remove roctracer_start/stop. Change-Id: Ie4d76afb5ce8d263848dcf1b599af394db56ddab
このコミットが含まれているのは:
+9
-29
@@ -256,39 +256,22 @@ struct roctx_trace_entry_t {
|
||||
roctracer::TraceBuffer<roctx_trace_entry_t>* roctx_trace_buffer = NULL;
|
||||
|
||||
// rocTX callback function
|
||||
static inline void roctx_callback_fun(uint32_t domain, uint32_t cid, uint32_t tid,
|
||||
roctx_range_id_t rid, const char* message) {
|
||||
void roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data,
|
||||
void* /* user_arg */) {
|
||||
const roctx_api_data_t* data = reinterpret_cast<const roctx_api_data_t*>(callback_data);
|
||||
|
||||
roctx_trace_entry_t* entry = roctx_trace_buffer->GetEntry();
|
||||
entry->cid = cid;
|
||||
entry->time = util::timestamp_ns();
|
||||
entry->pid = GetPid();
|
||||
entry->tid = tid;
|
||||
entry->rid = rid;
|
||||
entry->message = (message != NULL) ? strdup(message) : NULL;
|
||||
entry->tid = GetTid();
|
||||
entry->rid = data->args.id;
|
||||
entry->message = (data->args.message != NULL)
|
||||
? strdup(data->args.message) /* FIXME: Who frees the message? */
|
||||
: NULL;
|
||||
entry->valid.store(roctracer::TRACE_ENTRY_COMPLETE, std::memory_order_release);
|
||||
}
|
||||
|
||||
void roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* arg) {
|
||||
(void)arg;
|
||||
const roctx_api_data_t* data = reinterpret_cast<const roctx_api_data_t*>(callback_data);
|
||||
roctx_callback_fun(domain, cid, GetTid(), data->args.id, data->args.message);
|
||||
}
|
||||
|
||||
// rocTX Start/Stop callbacks
|
||||
void roctx_range_start_callback(const roctx_range_data_t* data, void* arg) {
|
||||
roctx_callback_fun(ACTIVITY_DOMAIN_ROCTX, ROCTX_API_ID_roctxRangePushA, data->tid, 0,
|
||||
data->message);
|
||||
}
|
||||
void roctx_range_stop_callback(const roctx_range_data_t* data, void* arg) {
|
||||
roctx_callback_fun(ACTIVITY_DOMAIN_ROCTX, ROCTX_API_ID_roctxRangePop, data->tid, 0, NULL);
|
||||
}
|
||||
void start_callback() {
|
||||
roctracer::RocTxLoader::Instance().RangeStackIterate(roctx_range_start_callback, NULL);
|
||||
}
|
||||
void stop_callback() {
|
||||
roctracer::RocTxLoader::Instance().RangeStackIterate(roctx_range_stop_callback, NULL);
|
||||
}
|
||||
|
||||
// rocTX buffer flush function
|
||||
void roctx_flush_cb(roctx_trace_entry_t* entry) {
|
||||
std::ostringstream os;
|
||||
@@ -859,9 +842,6 @@ void tool_load() {
|
||||
roctx_file_handle = open_output_file(output_prefix, "roctx_trace.txt");
|
||||
|
||||
// initialize HSA tracing
|
||||
roctracer_ext_properties_t properties{start_callback, stop_callback};
|
||||
roctracer_set_properties(ACTIVITY_DOMAIN_EXT_API, &properties);
|
||||
|
||||
fprintf(stdout, " rocTX-trace()\n");
|
||||
fflush(stdout);
|
||||
ROCTRACER_CALL(
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする