Skip to content

Commit

Permalink
update to the latest command buffer APIs (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug authored Sep 6, 2024
1 parent 8793b7b commit 67d4c97
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 57 deletions.
37 changes: 20 additions & 17 deletions intercept/src/cli_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////
// cl_khr_command_buffer

// Note: This implements the provisional extension v0.9.2.
// Note: This implements the provisional extension v0.9.5.

typedef cl_bitfield cl_device_command_buffer_capabilities_khr;
typedef struct _cl_command_buffer_khr* cl_command_buffer_khr;
Expand All @@ -22,7 +22,7 @@ typedef cl_uint cl_command_buffer_info_khr;
typedef cl_uint cl_command_buffer_state_khr;
typedef cl_properties cl_command_buffer_properties_khr;
typedef cl_bitfield cl_command_buffer_flags_khr;
typedef cl_properties cl_ndrange_kernel_command_properties_khr;
typedef cl_properties cl_command_properties_khr;
typedef struct _cl_mutable_command_khr* cl_mutable_command_khr;

#define CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR 0x12A9
Expand Down Expand Up @@ -86,6 +86,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandBarrierWithWaitListKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_uint num_sync_points_in_wait_list,
const cl_sync_point_khr* sync_point_wait_list,
cl_sync_point_khr* sync_point,
Expand All @@ -95,6 +96,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandCopyBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_buffer,
size_t src_offset,
Expand All @@ -109,6 +111,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandCopyBufferRectKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_buffer,
const size_t* src_origin,
Expand All @@ -127,6 +130,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandCopyBufferToImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_image,
size_t src_offset,
Expand All @@ -141,6 +145,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandCopyImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_image,
cl_mem dst_image,
const size_t* src_origin,
Expand All @@ -155,6 +160,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandCopyImageToBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_image,
cl_mem dst_buffer,
const size_t* src_origin,
Expand All @@ -169,6 +175,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandFillBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem buffer,
const void* pattern,
size_t pattern_size,
Expand All @@ -183,6 +190,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandFillImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem image,
const void* fill_color,
const size_t* origin,
Expand All @@ -196,6 +204,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandSVMMemcpyKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
void* dst_ptr,
const void* src_ptr,
size_t size,
Expand All @@ -208,6 +217,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandSVMMemFillKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
void* svm_ptr,
const void* pattern,
size_t pattern_size,
Expand All @@ -221,7 +231,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clCommandNDRangeKernelKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_ndrange_kernel_command_properties_khr* properties,
const cl_command_properties_khr* properties,
cl_kernel kernel,
cl_uint work_dim,
const size_t* global_work_offset,
Expand Down Expand Up @@ -273,9 +283,9 @@ clRemapCommandBufferKHR(
///////////////////////////////////////////////////////////////////////////////
// cl_khr_command_buffer_mutable_dispatch

// Note: This implements the provisional extension v0.9.1.
// Note: This implements the provisional extension v0.9.3.

typedef cl_uint cl_command_buffer_structure_type_khr;
typedef cl_uint cl_command_buffer_update_type_khr;
typedef cl_bitfield cl_mutable_dispatch_fields_khr;
typedef cl_uint cl_mutable_command_info_khr;
typedef struct _cl_mutable_dispatch_arg_khr {
Expand All @@ -289,8 +299,6 @@ typedef struct _cl_mutable_dispatch_exec_info_khr {
const void* param_value;
} cl_mutable_dispatch_exec_info_khr;
typedef struct _cl_mutable_dispatch_config_khr {
cl_command_buffer_structure_type_khr type;
const void* next;
cl_mutable_command_khr command;
cl_uint num_args;
cl_uint num_svm_args;
Expand All @@ -303,12 +311,6 @@ typedef struct _cl_mutable_dispatch_config_khr {
const size_t* global_work_size;
const size_t* local_work_size;
} cl_mutable_dispatch_config_khr;
typedef struct _cl_mutable_base_config_khr {
cl_command_buffer_structure_type_khr type;
const void* next;
cl_uint num_mutable_dispatch;
const cl_mutable_dispatch_config_khr* mutable_dispatch_list;
} cl_mutable_base_config_khr;
typedef cl_bitfield cl_mutable_dispatch_asserts_khr;

#define CL_COMMAND_BUFFER_MUTABLE_KHR (1 << 1)
Expand All @@ -327,15 +329,14 @@ typedef cl_bitfield cl_mutable_dispatch_asserts_khr;
#define CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR 0x12A0
#define CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR 0x12A1
#define CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR 0x12AD
#define CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR 0x12A2
#define CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR 0x12A2
#define CL_MUTABLE_DISPATCH_KERNEL_KHR 0x12A3
#define CL_MUTABLE_DISPATCH_DIMENSIONS_KHR 0x12A4
#define CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR 0x12A5
#define CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR 0x12A6
#define CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR 0x12A7

#define CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR 0
#define CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR 1
#define CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR 0

#define CL_COMMAND_BUFFER_MUTABLE_DISPATCH_ASSERTS_KHR 0x12B7

Expand All @@ -346,7 +347,9 @@ typedef cl_bitfield cl_mutable_dispatch_asserts_khr;
extern CL_API_ENTRY cl_int CL_API_CALL
clUpdateMutableCommandsKHR(
cl_command_buffer_khr command_buffer,
const cl_mutable_base_config_khr* mutable_config) ;
cl_uint num_configs,
const cl_command_buffer_update_type_khr* config_types,
const void** configs);

extern CL_API_ENTRY cl_int CL_API_CALL
clGetMutableCommandInfoKHR(
Expand Down
41 changes: 33 additions & 8 deletions intercept/src/dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10665,6 +10665,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueCommandBufferKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandBarrierWithWaitListKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_uint num_sync_points_in_wait_list,
const cl_sync_point_khr* sync_point_wait_list,
cl_sync_point_khr* sync_point,
Expand Down Expand Up @@ -10694,6 +10695,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandBarrierWithWaitListKHR(
cl_int retVal = dispatchX.clCommandBarrierWithWaitListKHR(
command_buffer,
command_queue,
properties,
num_sync_points_in_wait_list,
sync_point_wait_list,
sync_point,
Expand All @@ -10717,6 +10719,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandBarrierWithWaitListKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_buffer,
size_t src_offset,
Expand Down Expand Up @@ -10751,6 +10754,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferKHR(
cl_int retVal = dispatchX.clCommandCopyBufferKHR(
command_buffer,
command_queue,
properties,
src_buffer,
dst_buffer,
src_offset,
Expand Down Expand Up @@ -10779,6 +10783,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferRectKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_buffer,
const size_t* src_origin,
Expand Down Expand Up @@ -10817,6 +10822,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferRectKHR(
cl_int retVal = dispatchX.clCommandCopyBufferRectKHR(
command_buffer,
command_queue,
properties,
src_buffer,
dst_buffer,
src_origin,
Expand Down Expand Up @@ -10849,6 +10855,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferRectKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferToImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_buffer,
cl_mem dst_image,
size_t src_offset,
Expand Down Expand Up @@ -10883,6 +10890,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferToImageKHR(
cl_int retVal = dispatchX.clCommandCopyBufferToImageKHR(
command_buffer,
command_queue,
properties,
src_buffer,
dst_image,
src_offset,
Expand Down Expand Up @@ -10911,6 +10919,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyBufferToImageKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_image,
cl_mem dst_image,
const size_t* src_origin,
Expand Down Expand Up @@ -10945,6 +10954,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageKHR(
cl_int retVal = dispatchX.clCommandCopyImageKHR(
command_buffer,
command_queue,
properties,
src_image,
dst_image,
src_origin,
Expand Down Expand Up @@ -10973,6 +10983,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageToBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem src_image,
cl_mem dst_buffer,
const size_t* src_origin,
Expand Down Expand Up @@ -11009,6 +11020,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageToBufferKHR(
cl_int retVal = dispatchX.clCommandCopyImageToBufferKHR(
command_buffer,
command_queue,
properties,
src_image,
dst_buffer,
src_origin,
Expand Down Expand Up @@ -11037,6 +11049,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandCopyImageToBufferKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandFillBufferKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem buffer,
const void* pattern,
size_t pattern_size,
Expand Down Expand Up @@ -11071,6 +11084,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandFillBufferKHR(
cl_int retVal = dispatchX.clCommandFillBufferKHR(
command_buffer,
command_queue,
properties,
buffer,
pattern,
pattern_size,
Expand Down Expand Up @@ -11099,6 +11113,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandFillBufferKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandFillImageKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_mem image,
const void* fill_color,
const size_t* origin,
Expand Down Expand Up @@ -11132,6 +11147,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandFillImageKHR(
cl_int retVal = dispatchX.clCommandFillImageKHR(
command_buffer,
command_queue,
properties,
image,
fill_color,
origin,
Expand Down Expand Up @@ -11159,6 +11175,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandFillImageKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemcpyKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
void* dst_ptr,
const void* src_ptr,
size_t size,
Expand Down Expand Up @@ -11194,6 +11211,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemcpyKHR(
cl_int retVal = dispatchX.clCommandSVMMemcpyKHR(
command_buffer,
command_queue,
properties,
dst_ptr,
src_ptr,
size,
Expand All @@ -11220,6 +11238,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemcpyKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemFillKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
void* svm_ptr,
const void* pattern,
size_t pattern_size,
Expand Down Expand Up @@ -11256,6 +11275,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemFillKHR(
cl_int retVal = dispatchX.clCommandSVMMemFillKHR(
command_buffer,
command_queue,
properties,
svm_ptr,
pattern,
pattern_size,
Expand Down Expand Up @@ -11283,7 +11303,7 @@ CL_API_ENTRY cl_int CL_API_CALL clCommandSVMMemFillKHR(
CL_API_ENTRY cl_int CL_API_CALL clCommandNDRangeKernelKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_ndrange_kernel_command_properties_khr* properties,
const cl_command_properties_khr* properties,
cl_kernel kernel,
cl_uint work_dim,
const size_t* global_work_offset,
Expand Down Expand Up @@ -11476,7 +11496,9 @@ CL_API_ENTRY cl_command_buffer_khr CL_API_CALL clRemapCommandBufferKHR(
// cl_khr_command_buffer_mutable_dispatch
CL_API_ENTRY cl_int CL_API_CALL clUpdateMutableCommandsKHR(
cl_command_buffer_khr command_buffer,
const cl_mutable_base_config_khr* mutable_config)
cl_uint num_configs,
const cl_command_buffer_update_type_khr* config_types,
const void** configs)
{
CLIntercept* pIntercept = GetIntercept();

Expand All @@ -11486,24 +11508,27 @@ CL_API_ENTRY cl_int CL_API_CALL clUpdateMutableCommandsKHR(
if( dispatchX.clUpdateMutableCommandsKHR )
{
GET_ENQUEUE_COUNTER();
CALL_LOGGING_ENTER( "command_buffer = %p, mutable_config = %p",
CALL_LOGGING_ENTER( "command_buffer = %p, num_configs = %u",
command_buffer,
mutable_config );
num_configs );
if( pIntercept->config().CallLogging )
{
std::string configStr;
pIntercept->getCommandBufferMutableConfigString(
mutable_config,
num_configs,
config_types,
configs,
configStr );
CALL_LOGGING_INFO("mutable_config %p: %s",
mutable_config,
CALL_LOGGING_INFO(" configs = %s",
configStr.c_str() );
}
HOST_PERFORMANCE_TIMING_START();

cl_int retVal = dispatchX.clUpdateMutableCommandsKHR(
command_buffer,
mutable_config );
num_configs,
config_types,
configs );

HOST_PERFORMANCE_TIMING_END();
CHECK_ERROR( retVal );
Expand Down
Loading

0 comments on commit 67d4c97

Please sign in to comment.