Skip to content

Commit a442cbf

Browse files
committed
[EXP][Command-buffer] OpenCL kernel command update
Implement the API for updating the kernel commands in a command-buffer defined by oneapi-src#1089 for the OpenCL adapter. However, the following changes to the UR kernel update API have been made based on implementation experience: 1. Forbid updating the work-dim of the kernel, see KhronosGroup/OpenCL-Docs#1057 2. Remove struct fields to update exec info, after [DPC++ implementation prototype](intel/llvm#12840) shows this isn't needed. 3. Forbid changing the local work size from user to impl defined and vice-versa. See discussion in [L0 implementation PR](oneapi-src#1353 (comment)). This adapter implementation depends on support for the [cl_khr_command_buffer_mutable_dispatch](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_command_buffer_mutable_dispatch) extension. Tested on Intel GPU/CPUs OpenCL implementations with the [command-buffer emulation layer](https://github.com/bashbaug/SimpleOpenCLSamples/tree/main/layers/10_cmdbufemu). ```bash $ OPENCL_LAYERS=<path/to/SimpleOpenCLSamples/build/layers/10_cmdbufemu/libCmdBufEmu.so> ./bin/test-exp_command_buffer --platform="Intel(R) OpenCL Graphics" ``` DPC++ PR intel/llvm#12724
1 parent ec634ff commit a442cbf

28 files changed

+706
-367
lines changed

include/ur_api.h

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ typedef enum ur_structure_type_t {
270270
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC = 0x1002, ///< ::ur_exp_command_buffer_update_memobj_arg_desc_t
271271
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC = 0x1003, ///< ::ur_exp_command_buffer_update_pointer_arg_desc_t
272272
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC = 0x1004, ///< ::ur_exp_command_buffer_update_value_arg_desc_t
273-
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC = 0x1005, ///< ::ur_exp_command_buffer_update_exec_info_desc_t
274273
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
275274
UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t
276275
UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t
@@ -7897,19 +7896,6 @@ typedef struct ur_exp_command_buffer_update_value_arg_desc_t {
78977896

78987897
} ur_exp_command_buffer_update_value_arg_desc_t;
78997898

7900-
///////////////////////////////////////////////////////////////////////////////
7901-
/// @brief Descriptor type for updating kernel command execution info.
7902-
typedef struct ur_exp_command_buffer_update_exec_info_desc_t {
7903-
ur_structure_type_t stype; ///< [in] type of this structure, must be
7904-
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC
7905-
const void *pNext; ///< [in][optional] pointer to extension-specific structure
7906-
ur_kernel_exec_info_t propName; ///< [in] Name of execution attribute.
7907-
size_t propSize; ///< [in] Size of execution attribute.
7908-
const ur_kernel_exec_info_properties_t *pProperties; ///< [in][optional] Pointer to execution info properties.
7909-
const void *pNewExecInfo; ///< [in] Pointer to memory location holding the execution info value.
7910-
7911-
} ur_exp_command_buffer_update_exec_info_desc_t;
7912-
79137899
///////////////////////////////////////////////////////////////////////////////
79147900
/// @brief Descriptor type for updating a kernel launch command.
79157901
typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
@@ -7919,24 +7905,23 @@ typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
79197905
uint32_t numNewMemObjArgs; ///< [in] Length of pNewMemObjArgList.
79207906
uint32_t numNewPointerArgs; ///< [in] Length of pNewPointerArgList.
79217907
uint32_t numNewValueArgs; ///< [in] Length of pNewValueArgList.
7922-
uint32_t numNewExecInfos; ///< [in] Length of pNewExecInfoList.
79237908
uint32_t newWorkDim; ///< [in] Number of work dimensions in the kernel ND-range, from 1-3.
79247909
const ur_exp_command_buffer_update_memobj_arg_desc_t *pNewMemObjArgList; ///< [in][optional][range(0, numNewMemObjArgs)] An array describing the new
79257910
///< kernel mem obj arguments for the command.
79267911
const ur_exp_command_buffer_update_pointer_arg_desc_t *pNewPointerArgList; ///< [in][optional][range(0, numNewPointerArgs)] An array describing the
79277912
///< new kernel pointer arguments for the command.
79287913
const ur_exp_command_buffer_update_value_arg_desc_t *pNewValueArgList; ///< [in][optional][range(0, numNewValueArgs)] An array describing the new
79297914
///< kernel value arguments for the command.
7930-
const ur_exp_command_buffer_update_exec_info_desc_t *pNewExecInfoList; ///< [in][optional][range(0, numNewExecInfos)] An array describing the
7931-
///< execution info objects for the command.
79327915
size_t *pNewGlobalWorkOffset; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
79337916
///< values that describe the offset used to calculate the global ID.
79347917
size_t *pNewGlobalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
79357918
///< values that describe the number of global work-items.
79367919
size_t *pNewLocalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
79377920
///< values that describe the number of work-items that make up a
7938-
///< work-group. If nullptr, the runtime implementation will choose the
7939-
///< work-group size.
7921+
///< work-group. If newWorkDim is non-zero and pNewLocalWorkSize is
7922+
///< nullptr, then runtime implementation will choose the work-group size.
7923+
///< If newWorkDim is zero and pNewLocalWorkSize is nullptr, then the local
7924+
///< work size is unchanged.
79407925

79417926
} ur_exp_command_buffer_update_kernel_launch_desc_t;
79427927

@@ -7971,6 +7956,8 @@ typedef struct ur_exp_command_buffer_command_handle_t_ *ur_exp_command_buffer_co
79717956
/// + `NULL == phCommandBuffer`
79727957
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
79737958
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
7959+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
7960+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
79747961
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
79757962
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
79767963
UR_APIEXPORT ur_result_t UR_APICALL
@@ -8051,7 +8038,6 @@ urCommandBufferFinalizeExp(
80518038
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
80528039
/// + `NULL == pGlobalWorkOffset`
80538040
/// + `NULL == pGlobalWorkSize`
8054-
/// + `NULL == pLocalWorkSize`
80558041
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP
80568042
/// - ::UR_RESULT_ERROR_INVALID_KERNEL
80578043
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
@@ -8070,7 +8056,7 @@ urCommandBufferAppendKernelLaunchExp(
80708056
uint32_t workDim, ///< [in] Dimension of the kernel execution.
80718057
const size_t *pGlobalWorkOffset, ///< [in] Offset to use when executing kernel.
80728058
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
8073-
const size_t *pLocalWorkSize, ///< [in] Local work size to use when executing kernel.
8059+
const size_t *pLocalWorkSize, ///< [in][optional] Local work size to use when executing kernel.
80748060
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
80758061
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
80768062
ur_exp_command_buffer_sync_point_t *pSyncPoint, ///< [out][optional] Sync point associated with this command.
@@ -8572,6 +8558,10 @@ urCommandBufferReleaseCommandExp(
85728558
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
85738559
/// + If ::ur_exp_command_buffer_desc_t::isUpdatable was not set to true on creation of the command buffer `hCommand` belongs to.
85748560
/// + If the command-buffer `hCommand` belongs to has not been finalized.
8561+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and different from the work-dim used on creation of `hCommand`.
8562+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and `pUpdateKernelLaunch->pNewLocalWorkSize` is set to a non-NULL value and `pUpdateKernelLaunch->pNewGlobalWorkSize` is NULL.
8563+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and `pUpdateKernelLaunch->pNewLocalWorkSize` is set to a non-NULL value when `hCommand` was created with a NULL local work size.
8564+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and `pUpdateKernelLaunch->pNewLocalWorkSize` is set to a NULL value when `hCommand` was created with a non-NULL local work size.
85758565
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_COMMAND_HANDLE_EXP
85768566
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
85778567
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX

include/ur_print.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -978,14 +978,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdatePointerArgDesc(
978978
/// - `buff_size < out_size`
979979
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateValueArgDesc(const struct ur_exp_command_buffer_update_value_arg_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
980980

981-
///////////////////////////////////////////////////////////////////////////////
982-
/// @brief Print ur_exp_command_buffer_update_exec_info_desc_t struct
983-
/// @returns
984-
/// - ::UR_RESULT_SUCCESS
985-
/// - ::UR_RESULT_ERROR_INVALID_SIZE
986-
/// - `buff_size < out_size`
987-
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateExecInfoDesc(const struct ur_exp_command_buffer_update_exec_info_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
988-
989981
///////////////////////////////////////////////////////////////////////////////
990982
/// @brief Print ur_exp_command_buffer_update_kernel_launch_desc_t struct
991983
/// @returns

include/ur_print.hpp

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
332332
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_memobj_arg_desc_t params);
333333
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_pointer_arg_desc_t params);
334334
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_value_arg_desc_t params);
335-
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_exec_info_desc_t params);
336335
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_kernel_launch_desc_t params);
337336
inline std::ostream &operator<<(std::ostream &os, enum ur_exp_peer_info_t value);
338337

@@ -1044,9 +1043,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value
10441043
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC:
10451044
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC";
10461045
break;
1047-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC:
1048-
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC";
1049-
break;
10501046
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES:
10511047
os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES";
10521048
break;
@@ -1282,11 +1278,6 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
12821278
printPtr(os, pstruct);
12831279
} break;
12841280

1285-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC: {
1286-
const ur_exp_command_buffer_update_exec_info_desc_t *pstruct = (const ur_exp_command_buffer_update_exec_info_desc_t *)ptr;
1287-
printPtr(os, pstruct);
1288-
} break;
1289-
12901281
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: {
12911282
const ur_exp_sampler_mip_properties_t *pstruct = (const ur_exp_sampler_mip_properties_t *)ptr;
12921283
printPtr(os, pstruct);
@@ -9513,46 +9504,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
95139504
return os;
95149505
}
95159506
///////////////////////////////////////////////////////////////////////////////
9516-
/// @brief Print operator for the ur_exp_command_buffer_update_exec_info_desc_t type
9517-
/// @returns
9518-
/// std::ostream &
9519-
inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_buffer_update_exec_info_desc_t params) {
9520-
os << "(struct ur_exp_command_buffer_update_exec_info_desc_t){";
9521-
9522-
os << ".stype = ";
9523-
9524-
os << (params.stype);
9525-
9526-
os << ", ";
9527-
os << ".pNext = ";
9528-
9529-
ur::details::printStruct(os,
9530-
(params.pNext));
9531-
9532-
os << ", ";
9533-
os << ".propName = ";
9534-
9535-
os << (params.propName);
9536-
9537-
os << ", ";
9538-
os << ".propSize = ";
9539-
9540-
os << (params.propSize);
9541-
9542-
os << ", ";
9543-
os << ".pProperties = ";
9544-
9545-
os << (params.pProperties);
9546-
9547-
os << ", ";
9548-
os << ".pNewExecInfo = ";
9549-
9550-
os << (params.pNewExecInfo);
9551-
9552-
os << "}";
9553-
return os;
9554-
}
9555-
///////////////////////////////////////////////////////////////////////////////
95569507
/// @brief Print operator for the ur_exp_command_buffer_update_kernel_launch_desc_t type
95579508
/// @returns
95589509
/// std::ostream &
@@ -9584,11 +9535,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
95849535

95859536
os << (params.numNewValueArgs);
95869537

9587-
os << ", ";
9588-
os << ".numNewExecInfos = ";
9589-
9590-
os << (params.numNewExecInfos);
9591-
95929538
os << ", ";
95939539
os << ".newWorkDim = ";
95949540

@@ -9627,17 +9573,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
96279573
}
96289574
os << "}";
96299575

9630-
os << ", ";
9631-
os << ".pNewExecInfoList = {";
9632-
for (size_t i = 0; (params.pNewExecInfoList) != NULL && i < params.numNewExecInfos; ++i) {
9633-
if (i != 0) {
9634-
os << ", ";
9635-
}
9636-
9637-
os << ((params.pNewExecInfoList))[i];
9638-
}
9639-
os << "}";
9640-
96419576
os << ", ";
96429577
os << ".pNewGlobalWorkOffset = {";
96439578
for (size_t i = 0; (params.pNewGlobalWorkOffset) != NULL && i < params.newWorkDim; ++i) {

scripts/core/EXP-COMMAND-BUFFER.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ Enums
256256
* ${X}_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC
257257
* ${X}_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC
258258
* ${X}_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC
259-
* ${X}_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC
260259
* ${x}_command_t
261260
* ${X}_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP
262261
* ${x}_function_t
@@ -290,7 +289,6 @@ Types
290289
* ${x}_exp_command_buffer_update_memobj_arg_desc_t
291290
* ${x}_exp_command_buffer_update_pointer_arg_desc_t
292291
* ${x}_exp_command_buffer_update_value_arg_desc_t
293-
* ${x}_exp_command_buffer_update_exec_info_desc_t
294292
* ${x}_exp_command_buffer_sync_point_t
295293
* ${x}_exp_command_buffer_handle_t
296294
* ${x}_exp_command_buffer_command_handle_t

0 commit comments

Comments
 (0)