Skip to content

Commit ad3cbf9

Browse files
authored
improve logging for specialization constants (#476)
1 parent b60511c commit ad3cbf9

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

intercept/src/dispatch.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,10 +2491,19 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clSetProgramSpecializationConstant)(
24912491
if( pIntercept && pIntercept->dispatch().clSetProgramSpecializationConstant )
24922492
{
24932493
GET_ENQUEUE_COUNTER();
2494-
CALL_LOGGING_ENTER( "program = %p, spec_id = %u, spec_size = %zu",
2494+
std::string specConstString;
2495+
if( pIntercept->config().CallLogging )
2496+
{
2497+
pIntercept->getSpecConstantString(
2498+
spec_size,
2499+
spec_value,
2500+
specConstString );
2501+
}
2502+
CALL_LOGGING_ENTER( "program = %p, spec_id = %u, spec_size = %zu%s",
24952503
program,
24962504
spec_id,
2497-
spec_size );
2505+
spec_size,
2506+
specConstString.c_str() );
24982507
HOST_PERFORMANCE_TIMING_START();
24992508

25002509
cl_int retVal = pIntercept->dispatch().clSetProgramSpecializationConstant(

intercept/src/intercept.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,6 +3168,44 @@ void CLIntercept::getCreateSubBufferArgsString(
31683168
str = ss.str();
31693169
}
31703170

3171+
///////////////////////////////////////////////////////////////////////////////
3172+
//
3173+
void CLIntercept::getSpecConstantString(
3174+
size_t spec_size,
3175+
const void* spec_value,
3176+
std::string& str ) const
3177+
{
3178+
if( spec_value != NULL )
3179+
{
3180+
char s[256];
3181+
3182+
if( spec_size == sizeof(cl_uchar) )
3183+
{
3184+
cl_uchar* pData = (cl_uchar*)spec_value;
3185+
CLI_SPRINTF( s, 256, ", spec_value = 0x%x",
3186+
pData[0] );
3187+
}
3188+
else if( spec_size == sizeof(cl_uint) )
3189+
{
3190+
cl_uint* pData = (cl_uint*)spec_value;
3191+
CLI_SPRINTF( s, 256, ", spec_value = 0x%x",
3192+
pData[0] );
3193+
}
3194+
else if( spec_size == sizeof(cl_ulong) )
3195+
{
3196+
cl_ulong* pData = (cl_ulong*)spec_value;
3197+
CLI_SPRINTF( s, 256, ", spec_value = 0x%" PRIx64,
3198+
pData[0] );
3199+
}
3200+
3201+
str = s;
3202+
}
3203+
else
3204+
{
3205+
str = ", spec_value = NULL";
3206+
}
3207+
}
3208+
31713209
///////////////////////////////////////////////////////////////////////////////
31723210
//
31733211
void CLIntercept::logCLInfo()

intercept/src/intercept.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ class CLIntercept
204204
cl_buffer_create_type createType,
205205
const void *createInfo,
206206
std::string& str ) const;
207+
void getSpecConstantString(
208+
size_t spec_size,
209+
const void* spec_value,
210+
std::string& str ) const;
207211

208212
void logCLInfo();
209213
void logBuild(

0 commit comments

Comments
 (0)