Skip to content

Commit b51ecc0

Browse files
authored
roctracer: Only store correlations for calls with activities (#425)
1 parent 3fd9a8c commit b51ecc0

File tree

1 file changed

+62
-12
lines changed

1 file changed

+62
-12
lines changed

src/services/roctracer/RocTracer.cpp

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,35 +183,85 @@ class RocTracerService {
183183

184184
if (instance->m_enable_tracing) {
185185
// When tracing, store a correlation id with the kernel name and the
186-
// current region context
186+
// current region context. We only store correlation IDs for the subset
187+
// of calls that produce activities.
187188
std::string kernel;
189+
cali::Node* node = nullptr;
188190

189-
if (instance->m_record_names) {
190-
switch (cid) {
191+
switch (cid) {
191192
case HIP_API_ID_hipLaunchKernel:
192193
case HIP_API_ID_hipExtLaunchKernel:
193194
{
194-
kernel = hipKernelNameRefByPtr(data->args.hipLaunchKernel.function_address,
195-
data->args.hipLaunchKernel.stream);
195+
Entry e = c.get(instance->m_api_attr);
196+
if (e.is_reference())
197+
node = e.node();
198+
if (instance->m_record_names) {
199+
kernel = hipKernelNameRefByPtr(data->args.hipLaunchKernel.function_address,
200+
data->args.hipLaunchKernel.stream);
201+
}
196202
}
197203
break;
198204
case HIP_API_ID_hipModuleLaunchKernel:
199205
case HIP_API_ID_hipExtModuleLaunchKernel:
200206
case HIP_API_ID_hipHccModuleLaunchKernel:
201207
{
202-
kernel = hipKernelNameRef(data->args.hipExtModuleLaunchKernel.f);
208+
Entry e = c.get(instance->m_api_attr);
209+
if (e.is_reference())
210+
node = e.node();
211+
if (instance->m_record_names) {
212+
kernel = hipKernelNameRef(data->args.hipExtModuleLaunchKernel.f);
213+
}
203214
}
204215
break;
216+
case HIP_API_ID_hipMemcpy:
217+
case HIP_API_ID_hipMemcpy2D:
218+
case HIP_API_ID_hipMemcpy2DAsync:
219+
case HIP_API_ID_hipMemcpy2DFromArray:
220+
case HIP_API_ID_hipMemcpy2DFromArrayAsync:
221+
case HIP_API_ID_hipMemcpy2DToArray:
222+
case HIP_API_ID_hipMemcpy2DToArrayAsync:
223+
case HIP_API_ID_hipMemcpy3D:
224+
case HIP_API_ID_hipMemcpy3DAsync:
225+
case HIP_API_ID_hipMemcpyAsync:
226+
case HIP_API_ID_hipMemcpyAtoH:
227+
case HIP_API_ID_hipMemcpyDtoD:
228+
case HIP_API_ID_hipMemcpyDtoDAsync:
229+
case HIP_API_ID_hipMemcpyDtoH:
230+
case HIP_API_ID_hipMemcpyDtoHAsync:
231+
case HIP_API_ID_hipMemcpyFromArray:
232+
case HIP_API_ID_hipMemcpyFromSymbol:
233+
case HIP_API_ID_hipMemcpyFromSymbolAsync:
234+
case HIP_API_ID_hipMemcpyHtoA:
235+
case HIP_API_ID_hipMemcpyHtoD:
236+
case HIP_API_ID_hipMemcpyHtoDAsync:
237+
case HIP_API_ID_hipMemcpyParam2D:
238+
case HIP_API_ID_hipMemcpyParam2DAsync:
239+
case HIP_API_ID_hipMemcpyPeer:
240+
case HIP_API_ID_hipMemcpyPeerAsync:
241+
case HIP_API_ID_hipMemcpyToArray:
242+
case HIP_API_ID_hipMemcpyToSymbol:
243+
case HIP_API_ID_hipMemcpyToSymbolAsync:
244+
case HIP_API_ID_hipMemcpyWithStream:
245+
case HIP_API_ID_hipMemset:
246+
case HIP_API_ID_hipMemset2D:
247+
case HIP_API_ID_hipMemset2DAsync:
248+
case HIP_API_ID_hipMemset3D:
249+
case HIP_API_ID_hipMemset3DAsync:
250+
case HIP_API_ID_hipMemsetAsync:
251+
case HIP_API_ID_hipMemsetD16:
252+
case HIP_API_ID_hipMemsetD32:
253+
case HIP_API_ID_hipMemsetD32Async:
254+
case HIP_API_ID_hipMemsetD8:
255+
case HIP_API_ID_hipMemsetD8Async:
256+
{
257+
Entry e = c.get(instance->m_api_attr);
258+
if (e.is_reference())
259+
node = e.node();
260+
}
205261
default:
206262
break;
207-
}
208263
}
209264

210-
Entry e = c.get(instance->m_api_attr);
211-
cali::Node* node = nullptr;
212-
213-
if (e.is_reference())
214-
node = e.node();
215265
if (!kernel.empty()) {
216266
kernel = util::demangle(kernel.c_str());
217267
node = c.make_tree_entry(instance->m_kernel_name_attr,

0 commit comments

Comments
 (0)