Skip to content

Commit 5b2c079

Browse files
authored
add tracing for cl_nv_create_buffer (#164)
1 parent 1533ad8 commit 5b2c079

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

intercept/src/cli_ext.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,21 @@ clEnqueueMemAdviseINTEL(
953953
#define CL_DEVICE_PCI_BUS_ID_NV 0x4008
954954
#define CL_DEVICE_PCI_SLOT_ID_NV 0x4009
955955

956+
// cl_nv_create_buffer
957+
typedef cl_bitfield cl_mem_flags_NV;
958+
959+
extern CL_API_ENTRY cl_mem CL_API_CALL
960+
clCreateBufferNV(
961+
cl_context context,
962+
cl_mem_flags flags,
963+
cl_mem_flags_NV flags_NV,
964+
size_t size,
965+
void* host_ptr,
966+
cl_int* errcode_ret);
967+
968+
#define CL_MEM_LOCATION_HOST_NV (1 << 0)
969+
#define CL_MEM_PINNED_NV (1 << 1)
970+
956971
// cl_ext_atomic_counters
957972
#define CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT 0x4032
958973

intercept/src/dispatch.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,58 @@ CL_API_ENTRY cl_mem CL_API_CALL CLIRN(clCreateBufferWithProperties)(
10321032
NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
10331033
}
10341034

1035+
///////////////////////////////////////////////////////////////////////////////
1036+
//
1037+
// cl_nv_create_buffer
1038+
CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferNV(
1039+
cl_context context,
1040+
cl_mem_flags flags,
1041+
cl_mem_flags_NV flags_NV,
1042+
size_t size,
1043+
void* host_ptr,
1044+
cl_int* errcode_ret )
1045+
{
1046+
CLIntercept* pIntercept = GetIntercept();
1047+
1048+
if( pIntercept )
1049+
{
1050+
auto dispatchX = pIntercept->dispatchX(context);
1051+
if( dispatchX.clCreateBufferNV )
1052+
{
1053+
CALL_LOGGING_ENTER( "context = %p, flags = %s (%llX), flags_NV = %llX, size = %d, host_ptr = %p",
1054+
context,
1055+
pIntercept->enumName().name_mem_flags( flags ).c_str(),
1056+
flags,
1057+
flags_NV,
1058+
size,
1059+
host_ptr );
1060+
INITIALIZE_BUFFER_CONTENTS_INIT( flags, size, host_ptr );
1061+
CHECK_ERROR_INIT( errcode_ret );
1062+
CPU_PERFORMANCE_TIMING_START();
1063+
1064+
cl_mem retVal = dispatchX.clCreateBufferNV(
1065+
context,
1066+
flags,
1067+
flags_NV,
1068+
size,
1069+
host_ptr,
1070+
errcode_ret );
1071+
1072+
CPU_PERFORMANCE_TIMING_END();
1073+
ADD_BUFFER( retVal );
1074+
INITIALIZE_BUFFER_CONTENTS_CLEANUP( flags, host_ptr );
1075+
DUMP_BUFFER_AFTER_CREATE( retVal, flags, host_ptr, size );
1076+
CHECK_ERROR( errcode_ret[0] );
1077+
ADD_OBJECT_ALLOCATION( retVal );
1078+
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );
1079+
1080+
return retVal;
1081+
}
1082+
}
1083+
1084+
NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
1085+
}
1086+
10351087
///////////////////////////////////////////////////////////////////////////////
10361088
//
10371089
// OpenCL 1.1

intercept/src/dispatch.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,4 +1334,13 @@ struct CLdispatchX
13341334
cl_uint num_events_in_wait_list,
13351335
const cl_event* event_wait_list,
13361336
cl_event* event);
1337+
1338+
// cl_nv_create_buffer
1339+
cl_mem (CLI_API_CALL *clCreateBufferNV) (
1340+
cl_context context,
1341+
cl_mem_flags flags,
1342+
cl_mem_flags_NV flags_NV,
1343+
size_t size,
1344+
void* host_ptr,
1345+
cl_int* errcode_ret);
13371346
};

intercept/src/intercept.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10970,6 +10970,9 @@ void* CLIntercept::getExtensionFunctionAddress(
1097010970
CHECK_RETURN_EXTENSION_FUNCTION( clEnqueueMemAdviseINTEL );
1097110971
}
1097210972

10973+
// cl_nv_create_buffer
10974+
CHECK_RETURN_EXTENSION_FUNCTION( clCreateBufferNV );
10975+
1097310976
return NULL;
1097410977
}
1097510978

0 commit comments

Comments
 (0)