From 802ee7dee6d0dbf1dac7a59e774c0f2000a9471b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 28 May 2020 10:07:50 -0500 Subject: [PATCH] hipLaunchKernel kernel name fix Change-Id: I59c63ec34f77fe39ed1edc8b6395db3871004e40 [ROCm/roctracer commit: 511f659a8eb655f0b46816c11a82a72db81e48c1] --- projects/roctracer/src/core/loader.h | 3 +++ projects/roctracer/test/tool/tracer_tool.cpp | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/projects/roctracer/src/core/loader.h b/projects/roctracer/src/core/loader.h index 928adef561..413fe2f98b 100644 --- a/projects/roctracer/src/core/loader.h +++ b/projects/roctracer/src/core/loader.h @@ -114,6 +114,7 @@ class HipApi { typedef decltype(hipRegisterActivityCallback) RegisterActivityCallback_t; typedef decltype(hipRemoveActivityCallback) RemoveActivityCallback_t; typedef decltype(hipKernelNameRef) KernelNameRef_t; + typedef decltype(hipKernelNameRefByPtr) KernelNameRefByPtr_t; typedef decltype(hipApiName) ApiName_t; RegisterApiCallback_t* RegisterApiCallback; @@ -121,6 +122,7 @@ class HipApi { RegisterActivityCallback_t* RegisterActivityCallback; RemoveActivityCallback_t* RemoveActivityCallback; KernelNameRef_t* KernelNameRef; + KernelNameRefByPtr_t* KernelNameRefByPtr; ApiName_t* ApiName; protected: @@ -130,6 +132,7 @@ class HipApi { RegisterActivityCallback = loader->GetFun("hipRegisterActivityCallback"); RemoveActivityCallback = loader->GetFun("hipRemoveActivityCallback"); KernelNameRef = loader->GetFun("hipKernelNameRef"); + KernelNameRefByPtr = loader->GetFun("hipKernelNameRefByPtr"); ApiName = loader->GetFun("hipApiName"); } }; diff --git a/projects/roctracer/test/tool/tracer_tool.cpp b/projects/roctracer/test/tool/tracer_tool.cpp index c5ed7a840d..cdbdbab4e8 100644 --- a/projects/roctracer/test/tool/tracer_tool.cpp +++ b/projects/roctracer/test/tool/tracer_tool.cpp @@ -347,11 +347,11 @@ roctracer::TraceBuffer hip_api_trace_buffer("HIP", 0x2000 static inline bool is_hip_kernel_launch_api(const uint32_t& cid) { bool ret = #if 0 // HIP_VDI - (cid == HIP_API_ID_hipLaunchKernel) || (cid == HIP_API_ID_hipExtLaunchMultiKernelMultiDevice) || (cid == HIP_API_ID_hipLaunchCooperativeKernel) || (cid == HIP_API_ID_hipLaunchCooperativeKernelMultiDevice) || #endif + (cid == HIP_API_ID_hipLaunchKernel) || (cid == HIP_API_ID_hipModuleLaunchKernel) || (cid == HIP_API_ID_hipExtModuleLaunchKernel) || (cid == HIP_API_ID_hipHccModuleLaunchKernel); @@ -387,9 +387,13 @@ void hip_api_callback( if (cid == HIP_API_ID_hipMalloc) { entry->ptr = *(data->args.hipMalloc.ptr); } else if (is_hip_kernel_launch_api(cid)) { - const hipFunction_t f = data->args.hipModuleLaunchKernel.f; - if (f != NULL) { - entry->name = strdup(roctracer::HipLoader::Instance().KernelNameRef(f)); + if (cid == HIP_API_ID_hipLaunchKernel) { + const void* f = data->args.hipLaunchKernel.function_address; + hipStream_t stream = data->args.hipLaunchKernel.stream; + if (f != NULL) entry->name = strdup(roctracer::HipLoader::Instance().KernelNameRefByPtr(f, stream)); + } else { + const hipFunction_t f = data->args.hipModuleLaunchKernel.f; + if (f != NULL) entry->name = strdup(roctracer::HipLoader::Instance().KernelNameRef(f)); } } }