Skip to content

Commit ffc213a

Browse files
authored
add tracing for cl_intel_create_buffer_with_properties (#365)
1 parent fbdf8a8 commit ffc213a

File tree

4 files changed

+91
-4
lines changed

4 files changed

+91
-4
lines changed

intercept/src/cli_ext.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,20 @@ typedef struct _cl_queue_family_properties_intel {
12471247
#define CL_QUEUE_CAPABILITY_BARRIER_INTEL (1 << 25)
12481248
#define CL_QUEUE_CAPABILITY_KERNEL_INTEL (1 << 26)
12491249

1250+
///////////////////////////////////////////////////////////////////////////////
1251+
// cl_intel_create_buffer_with_properties
1252+
1253+
typedef cl_properties cl_mem_properties_intel;
1254+
1255+
extern CL_API_ENTRY
1256+
cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(
1257+
cl_context context,
1258+
const cl_mem_properties_intel* properties,
1259+
cl_mem_flags flags,
1260+
size_t size,
1261+
void* host_ptr,
1262+
cl_int* errcode_ret);
1263+
12501264
///////////////////////////////////////////////////////////////////////////////
12511265
// cl_intel_device_attribute_query
12521266
typedef cl_bitfield cl_device_feature_capabilities_intel;
@@ -1498,9 +1512,7 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
14981512
#define CL_QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL (((cl_bitfield)1) << 31)
14991513

15001514
///////////////////////////////////////////////////////////////////////////////
1501-
// cl_intel_unified_shared_memory POC
1502-
1503-
// These enums are in sync with revision Q of the USM spec.
1515+
// cl_intel_unified_shared_memory
15041516

15051517
// cl_device_info
15061518
#define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190
@@ -1517,7 +1529,8 @@ typedef cl_bitfield cl_device_unified_shared_memory_capabilities_intel;
15171529
#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS_INTEL (1 << 2)
15181530
#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS_INTEL (1 << 3)
15191531

1520-
typedef cl_properties cl_mem_properties_intel;
1532+
// Declared previously:
1533+
// typedef cl_properties cl_mem_properties_intel;
15211534

15221535
// cl_mem_properties_intel
15231536
#define CL_MEM_ALLOC_FLAGS_INTEL 0x4195

intercept/src/dispatch.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,68 @@ CL_API_ENTRY cl_mem CL_API_CALL CLIRN(clCreateBufferWithProperties)(
10701070
NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
10711071
}
10721072

1073+
///////////////////////////////////////////////////////////////////////////////
1074+
//
1075+
// cl_intel_create_buffer_with_properties
1076+
// This function should stay in sync with clCreateBufferWithProperties, above.
1077+
CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(
1078+
cl_context context,
1079+
const cl_mem_properties_intel* properties,
1080+
cl_mem_flags flags,
1081+
size_t size,
1082+
void* host_ptr,
1083+
cl_int* errcode_ret )
1084+
{
1085+
CLIntercept* pIntercept = GetIntercept();
1086+
1087+
if( pIntercept )
1088+
{
1089+
const auto& dispatchX = pIntercept->dispatchX(context);
1090+
if( dispatchX.clCreateBufferWithPropertiesINTEL )
1091+
{
1092+
GET_ENQUEUE_COUNTER();
1093+
1094+
std::string propsStr;
1095+
if( pIntercept->config().CallLogging )
1096+
{
1097+
pIntercept->getMemPropertiesString(
1098+
properties,
1099+
propsStr );
1100+
}
1101+
CALL_LOGGING_ENTER( "context = %p, properties = [ %s ], flags = %s (%llX), size = %zu, host_ptr = %p",
1102+
context,
1103+
propsStr.c_str(),
1104+
pIntercept->enumName().name_mem_flags( flags ).c_str(),
1105+
flags,
1106+
size,
1107+
host_ptr );
1108+
INITIALIZE_BUFFER_CONTENTS_INIT( flags, size, host_ptr );
1109+
CHECK_ERROR_INIT( errcode_ret );
1110+
HOST_PERFORMANCE_TIMING_START();
1111+
1112+
cl_mem retVal = dispatchX.clCreateBufferWithPropertiesINTEL(
1113+
context,
1114+
properties,
1115+
flags,
1116+
size,
1117+
host_ptr,
1118+
errcode_ret );
1119+
1120+
HOST_PERFORMANCE_TIMING_END();
1121+
ADD_BUFFER( retVal );
1122+
INITIALIZE_BUFFER_CONTENTS_CLEANUP( flags, host_ptr );
1123+
DUMP_BUFFER_AFTER_CREATE( retVal, flags, host_ptr, size );
1124+
CHECK_ERROR( errcode_ret[0] );
1125+
ADD_OBJECT_ALLOCATION( retVal );
1126+
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );
1127+
1128+
return retVal;
1129+
}
1130+
}
1131+
1132+
NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
1133+
}
1134+
10731135
///////////////////////////////////////////////////////////////////////////////
10741136
//
10751137
// cl_nv_create_buffer

intercept/src/dispatch.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,15 @@ struct CLdispatchX
535535
cl_int (CL_API_CALL *clReleaseAcceleratorINTEL) (
536536
cl_accelerator_intel accelerator );
537537

538+
// cl_intel_create_buffer_with_properties
539+
cl_mem (CL_API_CALL *clCreateBufferWithPropertiesINTEL) (
540+
cl_context context,
541+
const cl_mem_properties_intel* properties,
542+
cl_mem_flags flags,
543+
size_t size,
544+
void* host_ptr,
545+
cl_int* errcode_ret);
546+
538547
#if defined(_WIN32)
539548
// cl_intel_dx9_media_sharing
540549
cl_int (CL_API_CALL *clGetDeviceIDsFromDX9INTEL) (

intercept/src/intercept.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13171,6 +13171,9 @@ void* CLIntercept::getExtensionFunctionAddress(
1317113171
CHECK_RETURN_EXTENSION_FUNCTION( clRetainAcceleratorINTEL );
1317213172
CHECK_RETURN_EXTENSION_FUNCTION( clReleaseAcceleratorINTEL );
1317313173

13174+
// cl_intel_create_buffer_with_properties
13175+
CHECK_RETURN_EXTENSION_FUNCTION( clCreateBufferWithPropertiesINTEL );
13176+
1317413177
#if defined(_WIN32)
1317513178
// cl_intel_dx9_media_sharing
1317613179
CHECK_RETURN_EXTENSION_FUNCTION( clGetDeviceIDsFromDX9INTEL );

0 commit comments

Comments
 (0)