Skip to content

Commit e602a2e

Browse files
committed
fix the device performance timing checks for clReleaseContext
The device performance timing checks were only supposed to happen when the context reference count went to zero, but because the reference count was only queried when call logging was enabled, it was happening much more often. Fix by querying (and updating) the context reference count unconditionally.
1 parent 095be2a commit e602a2e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

intercept/src/dispatch.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,9 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)(
625625
{
626626
GET_ENQUEUE_COUNTER();
627627

628-
cl_uint ref_count =
629-
pIntercept->config().CallLogging ?
630-
pIntercept->getRefCount( context ) : 0;
628+
// Note: we use the ref count to for device performance timing checks,
629+
// so get it unconditionally.
630+
cl_uint ref_count = pIntercept->getRefCount( context );
631631
CALL_LOGGING_ENTER( "[ ref count = %d ] context = %p",
632632
ref_count,
633633
context );
@@ -639,7 +639,8 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)(
639639
HOST_PERFORMANCE_TIMING_END();
640640
CHECK_ERROR( retVal );
641641
ADD_OBJECT_RELEASE( context );
642-
CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", --ref_count );
642+
--ref_count;
643+
CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", ref_count );
643644
DEVICE_PERFORMANCE_TIMING_CHECK_CONDITIONAL( ref_count == 0 );
644645
FLUSH_CHROME_TRACE_BUFFERING_CONDITIONAL( ref_count == 0 );
645646

0 commit comments

Comments
 (0)