support for hip multi kernels

Change-Id: Idc8945f924ceb35081e153921181b96ee5f653b6


[ROCm/roctracer commit: 64ee8f29ef]
Bu işleme şunda yer alıyor:
Rachida Kebichi
2020-06-02 13:47:21 -04:00
işlemeyi yapan: Evgeny Shcherbakov
ebeveyn 78fc334ec3
işleme 09f3e5e402
2 değiştirilmiş dosya ile 35 ekleme ve 11 silme
+3
Dosyayı Görüntüle
@@ -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<RemoveActivityCallback_t>("hipRemoveActivityCallback");
KernelNameRef = loader->GetFun<KernelNameRef_t>("hipKernelNameRef");
KernelNameRefByPtr = loader->GetFun<KernelNameRefByPtr_t>("hipKernelNameRefByPtr");
GetStreamDeviceId = loader->GetFun<GetStreamDeviceId_t>("hipGetStreamDeviceId");
ApiName = loader->GetFun<ApiName_t>("hipApiName");
}
};
+32 -11
Dosyayı Görüntüle
@@ -348,12 +348,10 @@ roctracer::TraceBuffer<hip_api_trace_entry_t> 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));
}
}
}
}