adding kernel name to the dispatch callback data
This commit is contained in:
@@ -180,8 +180,9 @@ hsa_status_t rocprofiler_reset(rocprofiler_t* context, // [in] profiling contex
|
||||
// Profiling callback data
|
||||
typedef struct {
|
||||
hsa_agent_t agent;
|
||||
uint64_t kernel_object;
|
||||
uint64_t queue_index;
|
||||
uint64_t kernel_object;
|
||||
const char* kernel_name;
|
||||
} rocprofiler_callback_data_t;
|
||||
|
||||
// Profiling callback type
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef _SRC_CORE_INTERCEPT_QUEUE_H
|
||||
#define _SRC_CORE_INTERCEPT_QUEUE_H
|
||||
|
||||
#include <amd_hsa_kernel_code.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -90,8 +92,9 @@ class InterceptQueue {
|
||||
rocprofiler_group_t group = {};
|
||||
const hsa_kernel_dispatch_packet_t* dispatch_packet =
|
||||
reinterpret_cast<const hsa_kernel_dispatch_packet_t*>(packet);
|
||||
rocprofiler_callback_data_t data = {obj->agent_info_->dev_id,
|
||||
dispatch_packet->kernel_object, user_que_idx};
|
||||
rocprofiler_callback_data_t data = {obj->agent_info_->dev_id, user_que_idx,
|
||||
dispatch_packet->kernel_object,
|
||||
GetKernelName(dispatch_packet)};
|
||||
hsa_status_t status = on_dispatch_cb_(&data, on_dispatch_cb_data_, &group);
|
||||
if (status == HSA_STATUS_SUCCESS) {
|
||||
Context* context = reinterpret_cast<Context*>(group.context);
|
||||
@@ -145,6 +148,21 @@ class InterceptQueue {
|
||||
return (*header >> HSA_PACKET_HEADER_TYPE) & header_type_mask;
|
||||
}
|
||||
|
||||
static const char* GetKernelName(const hsa_kernel_dispatch_packet_t* dispatch_packet) {
|
||||
const amd_kernel_code_t* kernel_code = NULL;
|
||||
hsa_status_t status =
|
||||
util::HsaRsrcFactory::Instance().LoaderApi()->hsa_ven_amd_loader_query_host_address(
|
||||
reinterpret_cast<const void*>(dispatch_packet->kernel_object),
|
||||
reinterpret_cast<const void**>(&kernel_code));
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
kernel_code = reinterpret_cast<amd_kernel_code_t*>(dispatch_packet->kernel_object);
|
||||
}
|
||||
amd_runtime_loader_debug_info_t* dbg_info = reinterpret_cast<amd_runtime_loader_debug_info_t*>(
|
||||
kernel_code->runtime_loader_kernel_symbol);
|
||||
const char* kernel_name = (dbg_info != NULL) ? dbg_info->kernel_name : NULL;
|
||||
return (kernel_name != NULL) ? strdup(kernel_name) : NULL;
|
||||
}
|
||||
|
||||
static mutex_t mutex_;
|
||||
static const packet_word_t header_type_mask = (1ul << HSA_PACKET_HEADER_WIDTH_TYPE) - 1;
|
||||
static rocprofiler_callback_t on_dispatch_cb_;
|
||||
|
||||
@@ -83,8 +83,14 @@ HsaRsrcFactory::HsaRsrcFactory() {
|
||||
CHECK_STATUS("Error Calling hsa_iterate_agents", status);
|
||||
|
||||
// Get AqlProfile API table
|
||||
aqlprofile_api_ = {0};
|
||||
status = hsa_system_get_extension_table(HSA_EXTENSION_AMD_AQLPROFILE, 1, 0, &aqlprofile_api_);
|
||||
CHECK_STATUS("aqlprofile API table query failed", status);
|
||||
|
||||
// Get Loader API table
|
||||
loader_api_ = {0};
|
||||
status = hsa_system_get_extension_table(HSA_EXTENSION_AMD_LOADER, 1, 0, &loader_api_);
|
||||
CHECK_STATUS("loader API table query failed", status);
|
||||
}
|
||||
|
||||
// Destructor of the class
|
||||
|
||||
@@ -28,6 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <hsa.h>
|
||||
#include <hsa_ext_finalize.h>
|
||||
#include <hsa_ven_amd_aqlprofile.h>
|
||||
#include <hsa_ven_amd_loader.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -223,6 +224,9 @@ class HsaRsrcFactory {
|
||||
// Return AqlProfile API table
|
||||
const hsa_ven_amd_aqlprofile_1_00_pfn_t* AqlProfileApi() const { return &aqlprofile_api_; }
|
||||
|
||||
// Return Loader API table
|
||||
const hsa_ven_amd_loader_1_00_pfn_t* LoaderApi() const { return &loader_api_; }
|
||||
|
||||
private:
|
||||
// System agents iterating callback
|
||||
static hsa_status_t GetHsaAgentsCallback(hsa_agent_t agent, void* data);
|
||||
@@ -254,6 +258,9 @@ class HsaRsrcFactory {
|
||||
|
||||
// AqlProfile API table
|
||||
hsa_ven_amd_aqlprofile_1_00_pfn_t aqlprofile_api_;
|
||||
|
||||
// Loader API table
|
||||
hsa_ven_amd_loader_1_00_pfn_t loader_api_;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
|
||||
@@ -192,7 +192,9 @@ void dump_context(context_entry_t* entry) {
|
||||
const unsigned feature_count = entry->feature_count;
|
||||
FILE* file_handle = entry->file_handle;
|
||||
|
||||
fprintf(file_handle, "Dispatch[%u], kernel_object(0x%lx):\n", index, entry->data.kernel_object);
|
||||
fprintf(file_handle,
|
||||
"Dispatch[%u], queue_index(%lu), kernel_object(0x%lx), kernel_name(\"%s\"):\n", index,
|
||||
entry->data.queue_index, entry->data.kernel_object, entry->data.kernel_name);
|
||||
|
||||
status = rocprofiler_group_get_data(&group);
|
||||
check_status(status);
|
||||
|
||||
Reference in New Issue
Block a user