diff --git a/intercept/src/dispatch.cpp b/intercept/src/dispatch.cpp index 5fa1652e..0cebbb3c 100644 --- a/intercept/src/dispatch.cpp +++ b/intercept/src/dispatch.cpp @@ -625,9 +625,9 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)( { GET_ENQUEUE_COUNTER(); - cl_uint ref_count = - pIntercept->config().CallLogging ? - pIntercept->getRefCount( context ) : 0; + // Note: we use the ref count to for device performance timing checks, + // so get it unconditionally. + cl_uint ref_count = pIntercept->getRefCount( context ); CALL_LOGGING_ENTER( "[ ref count = %d ] context = %p", ref_count, context ); @@ -639,7 +639,8 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)( HOST_PERFORMANCE_TIMING_END(); CHECK_ERROR( retVal ); ADD_OBJECT_RELEASE( context ); - CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", --ref_count ); + --ref_count; + CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", ref_count ); DEVICE_PERFORMANCE_TIMING_CHECK_CONDITIONAL( ref_count == 0 ); FLUSH_CHROME_TRACE_BUFFERING_CONDITIONAL( ref_count == 0 );