Skip to content

Commit dae7052

Browse files
committed
add record tags for command buffer kernel records
1 parent 778572d commit dae7052

File tree

3 files changed

+92
-27
lines changed

3 files changed

+92
-27
lines changed

intercept/src/dispatch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11425,13 +11425,14 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandNDRangeKernelKHR(
1142511425
command_queue,
1142611426
kernel,
1142711427
argsString.c_str() );
11428-
GET_TIMING_TAGS_COMMAND_BUFFER_KERNEL(
11428+
GET_RECORD_TAG_COMMAND_BUFFER_KERNEL(
1142911429
command_buffer,
1143011430
kernel,
1143111431
work_dim,
1143211432
global_work_offset,
1143311433
global_work_size,
11434-
local_work_size );
11434+
local_work_size,
11435+
mutable_handle );
1143511436
HOST_PERFORMANCE_TIMING_START();
1143611437

1143711438
cl_int retVal = dispatchX.clCommandNDRangeKernelKHR(

intercept/src/intercept.cpp

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6005,30 +6005,93 @@ void CLIntercept::getTimingTagsKernel(
60056005

60066006
///////////////////////////////////////////////////////////////////////////////
60076007
//
6008-
void CLIntercept::getTimingTagsCommandBufferKernel(
6008+
void CLIntercept::getRecordTagCommandBufferKernel(
60096009
const cl_command_buffer_khr cmdbuf,
60106010
const cl_kernel kernel,
60116011
const cl_uint workDim,
60126012
const size_t* gwo,
60136013
const size_t* gws,
60146014
const size_t* lws,
6015-
std::string& hostTag,
6016-
std::string& deviceTag )
6015+
const cl_mutable_command_khr* mutable_handle,
6016+
std::string& recordTag )
60176017
{
6018-
cl_command_queue queue = getCommandBufferCommandQueue(
6019-
0,
6020-
nullptr,
6021-
cmdbuf );
6018+
std::lock_guard<std::mutex> lock(m_Mutex);
60226019

6023-
getTimingTagsKernel(
6024-
queue,
6025-
kernel,
6026-
workDim,
6027-
gwo,
6028-
gws,
6029-
lws,
6030-
hostTag,
6031-
deviceTag );
6020+
if( kernel )
6021+
{
6022+
std::ostringstream ss;
6023+
6024+
recordTag += getShortKernelNameWithHash(kernel);
6025+
6026+
if( gwo )
6027+
{
6028+
ss << " GWO[ ";
6029+
if( workDim >= 1 )
6030+
{
6031+
ss << gwo[0];
6032+
}
6033+
if( workDim >= 2 )
6034+
{
6035+
ss << ", " << gwo[1];
6036+
}
6037+
if( workDim >= 3 )
6038+
{
6039+
ss << ", " << gwo[2];
6040+
}
6041+
ss << " ]";
6042+
}
6043+
6044+
ss << " GWS[ ";
6045+
if( gws )
6046+
{
6047+
if( workDim >= 1 )
6048+
{
6049+
ss << gws[0];
6050+
}
6051+
if( workDim >= 2 )
6052+
{
6053+
ss << " x " << gws[1];
6054+
}
6055+
if( workDim >= 3 )
6056+
{
6057+
ss << " x " << gws[2];
6058+
}
6059+
}
6060+
else
6061+
{
6062+
ss << "NULL";
6063+
}
6064+
ss << " ]";
6065+
6066+
ss << " LWS[ ";
6067+
if( lws )
6068+
{
6069+
if( workDim >= 1 )
6070+
{
6071+
ss << lws[0];
6072+
}
6073+
if( workDim >= 2 )
6074+
{
6075+
ss << " x " << lws[1];
6076+
}
6077+
if( workDim >= 3 )
6078+
{
6079+
ss << " x " << lws[2];
6080+
}
6081+
}
6082+
else
6083+
{
6084+
ss << "NULL";
6085+
}
6086+
ss << " ]";
6087+
6088+
if( mutable_handle )
6089+
{
6090+
ss << " [MUTABLE]";
6091+
}
6092+
6093+
recordTag += ss.str();
6094+
}
60326095
}
60336096

60346097
///////////////////////////////////////////////////////////////////////////////
@@ -7171,6 +7234,7 @@ void CLIntercept::checkRemoveCommandBufferInfo(
71717234
if( errorCode == CL_SUCCESS && refCount == 1 )
71727235
{
71737236
m_CommandBufferInfoMap.erase( iter );
7237+
m_CommandBufferRecordMap.erase( cmdbuf );
71747238

71757239
CCommandBufferMutableCommandsMap::iterator cmditer =
71767240
m_CommandBufferMutableCommandsMap.find( cmdbuf );

intercept/src/intercept.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,15 @@ class CLIntercept
419419
const size_t* lws,
420420
std::string& hostTag,
421421
std::string& deviceTag );
422-
void getTimingTagsCommandBufferKernel(
422+
void getRecordTagCommandBufferKernel(
423423
const cl_command_buffer_khr cmdbuf,
424424
const cl_kernel kernel,
425425
const cl_uint workDim,
426426
const size_t* gwo,
427427
const size_t* gws,
428428
const size_t* lws,
429-
std::string& hostTag,
430-
std::string& deviceTag );
429+
const cl_mutable_command_khr* mutable_handle,
430+
std::string& recordTag);
431431

432432
void updateHostTimingStats(
433433
const char* functionName,
@@ -3203,19 +3203,19 @@ inline bool CLIntercept::checkAubCaptureEnqueueLimits(
32033203
deviceTag ); \
32043204
}
32053205

3206-
#define GET_TIMING_TAGS_COMMAND_BUFFER_KERNEL( _cmdbuf, _kernel, _dim, _gwo, _gws, _lws )\
3207-
std::string hostTag, deviceTag; \
3206+
#define GET_RECORD_TAG_COMMAND_BUFFER_KERNEL( _cmdbuf, _kernel, _dim, _gwo, _gws, _lws, _mh )\
3207+
std::string recordTag; \
32083208
if( pIntercept->config().DumpCommandBuffers ) \
32093209
{ \
3210-
pIntercept->getTimingTagsCommandBufferKernel( \
3210+
pIntercept->getRecordTagCommandBufferKernel( \
32113211
_cmdbuf, \
32123212
_kernel, \
32133213
_dim, \
32143214
_gwo, \
32153215
_gws, \
32163216
_lws, \
3217-
hostTag, \
3218-
deviceTag ); \
3217+
_mh, \
3218+
recordTag ); \
32193219
}
32203220

32213221
///////////////////////////////////////////////////////////////////////////////
@@ -3518,7 +3518,7 @@ inline void CLIntercept::flushChromeTraceBuffering()
35183518
pIntercept->recordCommandBufferCommand( \
35193519
_cmdbuf, \
35203520
__FUNCTION__, \
3521-
hostTag, \
3521+
recordTag, \
35223522
_nspwl, \
35233523
_spwl, \
35243524
_sp); \

0 commit comments

Comments
 (0)