From 5486b9de3a04c5be1c04e3ac594dc2dedab6f36a Mon Sep 17 00:00:00 2001 From: Saurabh Verma Date: Fri, 10 Nov 2023 16:11:59 -0600 Subject: [PATCH] Fixed format of presenting MI300 counters for individual xccs 1. Modified rocprofiler_record_profiler_t to include xcc_index 2. Modified file plugin to add additional column XCC_Index to the csv Change-Id: Ic526c739e16b50dca5704070ccabbcbecd994d6a [ROCm/rocprofiler commit: b18bc9930bca9b868691c6746ce724698963d14e] --- projects/rocprofiler/include/rocprofiler/v2/rocprofiler.h | 6 +++++- projects/rocprofiler/plugin/file/file.cpp | 6 ++++++ projects/rocprofiler/src/core/hsa/queues/queue.cpp | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler/include/rocprofiler/v2/rocprofiler.h b/projects/rocprofiler/include/rocprofiler/v2/rocprofiler.h index ed51b99f71..ff233c7809 100644 --- a/projects/rocprofiler/include/rocprofiler/v2/rocprofiler.h +++ b/projects/rocprofiler/include/rocprofiler/v2/rocprofiler.h @@ -1102,6 +1102,10 @@ typedef struct { * The count of the counters that were collected by the profiler */ rocprofiler_record_counters_instances_count_t counters_count; /* Counters Count */ + /** + * The index of the xcc from which these counters were collected + */ + uint32_t xcc_index; /** * kernel properties, including the grid size, work group size, * registers count, wave size and completion signal @@ -2394,7 +2398,7 @@ rocprofiler_codeobj_capture_free(rocprofiler_record_id_t id); * \param[in] id record handle. * \retval ::ROCPROFILER_STATUS_SUCCESS The function has been executed successfully. * \retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENTS invalid ID. - */ + */ ROCPROFILER_API rocprofiler_status_t rocprofiler_codeobj_capture_start(rocprofiler_record_id_t id); diff --git a/projects/rocprofiler/plugin/file/file.cpp b/projects/rocprofiler/plugin/file/file.cpp index 2648c811a0..2ce3c81b53 100644 --- a/projects/rocprofiler/plugin/file/file.cpp +++ b/projects/rocprofiler/plugin/file/file.cpp @@ -175,6 +175,9 @@ class file_plugin_t { file_plugin_t(void* data) { if (data) counter_names_ = GetCounterNames(); + const char* str = getenv("ROCPROFILER_INDIVIDUAL_XCC_MODE"); + if (str != NULL) is_individual_xcc_mode = (atol(str) > 0); + valid_ = true; } @@ -342,6 +345,7 @@ class file_plugin_t { if (!counter_header_written_) { if (profiler_record->counters) { + if(is_individual_xcc_mode) ss << ',' << "XCC_Index"; for (uint64_t i = 0; i < profiler_record->counters_count.value; i++) { auto counter_handler = profiler_record->counters[i].counter_handler; if (!counter_handler.handle) continue; @@ -393,6 +397,7 @@ class file_plugin_t { // For Counters if (profiler_record->counters) { + if(is_individual_xcc_mode) ss << "," << profiler_record->xcc_index; for (uint64_t i = 0; i < profiler_record->counters_count.value; i++) { if (profiler_record->counters[i].counter_handler.handle > 0) { ss << "," << std::to_string(profiler_record->counters[i].value.value); @@ -456,6 +461,7 @@ class file_plugin_t { private: bool valid_{false}; bool counter_header_written_ = false; + bool is_individual_xcc_mode=false; std::vector counter_names_; std::atomic roctx_header_written_{false}, hsa_api_header_written_{false}, diff --git a/projects/rocprofiler/src/core/hsa/queues/queue.cpp b/projects/rocprofiler/src/core/hsa/queues/queue.cpp index b02e238f4f..35f0b77551 100644 --- a/projects/rocprofiler/src/core/hsa/queues/queue.cpp +++ b/projects/rocprofiler/src/core/hsa/queues/queue.cpp @@ -434,6 +434,7 @@ bool AsyncSignalHandler(hsa_signal_value_t signal_value, void* data) { record.queue_idx = rocprofiler_queue_index_t{pending->queue_index}; record.timestamps = rocprofiler_record_header_timestamp_t{time.start, time.end}; record.queue_id = rocprofiler_queue_id_t{queue_info_session->queue_id}; + record.xcc_index = xcc_id; // Kernel Descriptor is the right record id generated in the WriteInterceptor function and // will be used to handle the kernel name of that dispatch record.header = rocprofiler_record_header_t{