diff --git a/projects/roctracer/src/core/loader.h b/projects/roctracer/src/core/loader.h index 413fe2f98b..d73bc383a6 100644 --- a/projects/roctracer/src/core/loader.h +++ b/projects/roctracer/src/core/loader.h @@ -115,6 +115,7 @@ class HipApi { typedef decltype(hipRemoveActivityCallback) RemoveActivityCallback_t; typedef decltype(hipKernelNameRef) KernelNameRef_t; typedef decltype(hipKernelNameRefByPtr) KernelNameRefByPtr_t; + typedef decltype(hipGetStreamDeviceId) GetStreamDeviceId_t; typedef decltype(hipApiName) ApiName_t; RegisterApiCallback_t* RegisterApiCallback; @@ -123,6 +124,7 @@ class HipApi { RemoveActivityCallback_t* RemoveActivityCallback; KernelNameRef_t* KernelNameRef; KernelNameRefByPtr_t* KernelNameRefByPtr; + GetStreamDeviceId_t* GetStreamDeviceId; ApiName_t* ApiName; protected: @@ -133,6 +135,7 @@ class HipApi { RemoveActivityCallback = loader->GetFun("hipRemoveActivityCallback"); KernelNameRef = loader->GetFun("hipKernelNameRef"); KernelNameRefByPtr = loader->GetFun("hipKernelNameRefByPtr"); + GetStreamDeviceId = loader->GetFun("hipGetStreamDeviceId"); ApiName = loader->GetFun("hipApiName"); } }; diff --git a/projects/roctracer/test/tool/tracer_tool.cpp b/projects/roctracer/test/tool/tracer_tool.cpp index 53c14df57f..18ea69d118 100644 --- a/projects/roctracer/test/tool/tracer_tool.cpp +++ b/projects/roctracer/test/tool/tracer_tool.cpp @@ -348,12 +348,10 @@ 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_hipExtLaunchMultiKernelMultiDevice) || + (cid == HIP_API_ID_hipLaunchKernel) || (cid == HIP_API_ID_hipLaunchCooperativeKernel) || (cid == HIP_API_ID_hipLaunchCooperativeKernelMultiDevice) || -#endif - (cid == HIP_API_ID_hipLaunchKernel) || + (cid == HIP_API_ID_hipExtLaunchMultiKernelMultiDevice) || (cid == HIP_API_ID_hipModuleLaunchKernel) || (cid == HIP_API_ID_hipExtModuleLaunchKernel) || (cid == HIP_API_ID_hipHccModuleLaunchKernel); @@ -389,13 +387,36 @@ void hip_api_callback( if (cid == HIP_API_ID_hipMalloc) { entry->ptr = *(data->args.hipMalloc.ptr); } else if (is_hip_kernel_launch_api(cid)) { - 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)); + switch(cid) { + case HIP_API_ID_hipExtLaunchMultiKernelMultiDevice: + case HIP_API_ID_hipLaunchCooperativeKernelMultiDevice: + { + const hipLaunchParams* listKernels = data->args.hipLaunchCooperativeKernelMultiDevice.launchParamsList; + std::string name_str = ""; + for (int i = 0; i < data->args.hipLaunchCooperativeKernelMultiDevice.numDevices; ++i) { + const hipLaunchParams& lp = listKernels[i]; + if (lp.func != NULL) { + const char* kernel_name = roctracer::HipLoader::Instance().KernelNameRefByPtr(lp.func, lp.stream); + const int device_id = roctracer::HipLoader::Instance().GetStreamDeviceId(lp.stream); + name_str += std::string(kernel_name) + ":" + std::to_string(device_id) + ";"; + } + } + entry->name = strdup(name_str.c_str()); + break; + } + case HIP_API_ID_hipLaunchKernel: + case HIP_API_ID_hipLaunchCooperativeKernel: + { + 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)); + break; + } + default: + { + const hipFunction_t f = data->args.hipModuleLaunchKernel.f; + if (f != NULL) entry->name = strdup(roctracer::HipLoader::Instance().KernelNameRef(f)); + } } } }