Skip to content

Commit 1c8fd81

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 3609afc commit 1c8fd81

30 files changed

+713
-412
lines changed

include/ur_api.h

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ typedef enum ur_structure_type_t {
271271
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC = 0x1002, ///< ::ur_exp_command_buffer_update_memobj_arg_desc_t
272272
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC = 0x1003, ///< ::ur_exp_command_buffer_update_pointer_arg_desc_t
273273
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC = 0x1004, ///< ::ur_exp_command_buffer_update_value_arg_desc_t
274-
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC = 0x1005, ///< ::ur_exp_command_buffer_update_exec_info_desc_t
275274
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
276275
UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t
277276
UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t
@@ -7990,19 +7989,6 @@ typedef struct ur_exp_command_buffer_update_value_arg_desc_t {
79907989

79917990
} ur_exp_command_buffer_update_value_arg_desc_t;
79927991

7993-
///////////////////////////////////////////////////////////////////////////////
7994-
/// @brief Descriptor type for updating kernel command execution info.
7995-
typedef struct ur_exp_command_buffer_update_exec_info_desc_t {
7996-
ur_structure_type_t stype; ///< [in] type of this structure, must be
7997-
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC
7998-
const void *pNext; ///< [in][optional] pointer to extension-specific structure
7999-
ur_kernel_exec_info_t propName; ///< [in] Name of execution attribute.
8000-
size_t propSize; ///< [in] Size of execution attribute.
8001-
const ur_kernel_exec_info_properties_t *pProperties; ///< [in][optional] Pointer to execution info properties.
8002-
const void *pNewExecInfo; ///< [in] Pointer to memory location holding the execution info value.
8003-
8004-
} ur_exp_command_buffer_update_exec_info_desc_t;
8005-
80067992
///////////////////////////////////////////////////////////////////////////////
80077993
/// @brief Descriptor type for updating a kernel launch command.
80087994
typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
@@ -8012,24 +7998,23 @@ typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
80127998
uint32_t numNewMemObjArgs; ///< [in] Length of pNewMemObjArgList.
80137999
uint32_t numNewPointerArgs; ///< [in] Length of pNewPointerArgList.
80148000
uint32_t numNewValueArgs; ///< [in] Length of pNewValueArgList.
8015-
uint32_t numNewExecInfos; ///< [in] Length of pNewExecInfoList.
80168001
uint32_t newWorkDim; ///< [in] Number of work dimensions in the kernel ND-range, from 1-3.
80178002
const ur_exp_command_buffer_update_memobj_arg_desc_t *pNewMemObjArgList; ///< [in][optional][range(0, numNewMemObjArgs)] An array describing the new
80188003
///< kernel mem obj arguments for the command.
80198004
const ur_exp_command_buffer_update_pointer_arg_desc_t *pNewPointerArgList; ///< [in][optional][range(0, numNewPointerArgs)] An array describing the
80208005
///< new kernel pointer arguments for the command.
80218006
const ur_exp_command_buffer_update_value_arg_desc_t *pNewValueArgList; ///< [in][optional][range(0, numNewValueArgs)] An array describing the new
80228007
///< kernel value arguments for the command.
8023-
const ur_exp_command_buffer_update_exec_info_desc_t *pNewExecInfoList; ///< [in][optional][range(0, numNewExecInfos)] An array describing the
8024-
///< execution info objects for the command.
80258008
size_t *pNewGlobalWorkOffset; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80268009
///< values that describe the offset used to calculate the global ID.
80278010
size_t *pNewGlobalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80288011
///< values that describe the number of global work-items.
80298012
size_t *pNewLocalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80308013
///< values that describe the number of work-items that make up a
8031-
///< work-group. If nullptr, the runtime implementation will choose the
8032-
///< work-group size.
8014+
///< work-group. If newWorkDim is non-zero and pNewLocalWorkSize is
8015+
///< nullptr, then runtime implementation will choose the work-group size.
8016+
///< If newWorkDim is zero and pNewLocalWorkSize is nullptr, then the local
8017+
///< work size is unchanged.
80338018

80348019
} ur_exp_command_buffer_update_kernel_launch_desc_t;
80358020

@@ -8064,6 +8049,8 @@ typedef struct ur_exp_command_buffer_command_handle_t_ *ur_exp_command_buffer_co
80648049
/// + `NULL == phCommandBuffer`
80658050
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
80668051
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
8052+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
8053+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
80678054
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
80688055
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
80698056
UR_APIEXPORT ur_result_t UR_APICALL
@@ -8144,7 +8131,6 @@ urCommandBufferFinalizeExp(
81448131
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
81458132
/// + `NULL == pGlobalWorkOffset`
81468133
/// + `NULL == pGlobalWorkSize`
8147-
/// + `NULL == pLocalWorkSize`
81488134
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP
81498135
/// - ::UR_RESULT_ERROR_INVALID_KERNEL
81508136
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
@@ -8163,7 +8149,7 @@ urCommandBufferAppendKernelLaunchExp(
81638149
uint32_t workDim, ///< [in] Dimension of the kernel execution.
81648150
const size_t *pGlobalWorkOffset, ///< [in] Offset to use when executing kernel.
81658151
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
8166-
const size_t *pLocalWorkSize, ///< [in] Local work size to use when executing kernel.
8152+
const size_t *pLocalWorkSize, ///< [in][optional] Local work size to use when executing kernel.
81678153
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
81688154
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
81698155
ur_exp_command_buffer_sync_point_t *pSyncPoint, ///< [out][optional] Sync point associated with this command.
@@ -8665,6 +8651,10 @@ urCommandBufferReleaseCommandExp(
86658651
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
86668652
/// + If ::ur_exp_command_buffer_desc_t::isUpdatable was not set to true on creation of the command buffer `hCommand` belongs to.
86678653
/// + If the command-buffer `hCommand` belongs to has not been finalized.
8654+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and different from the work-dim used on creation of `hCommand`.
8655+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and `pUpdateKernelLaunch->pNewLocalWorkSize` is set to a non-NULL value and `pUpdateKernelLaunch->pNewGlobalWorkSize` is NULL.
8656+
/// + 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.
8657+
/// + 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.
86688658
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_COMMAND_HANDLE_EXP
86698659
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
86708660
/// - ::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

@@ -1047,9 +1046,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value
10471046
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC:
10481047
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC";
10491048
break;
1050-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC:
1051-
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC";
1052-
break;
10531049
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES:
10541050
os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES";
10551051
break;
@@ -1285,11 +1281,6 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
12851281
printPtr(os, pstruct);
12861282
} break;
12871283

1288-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC: {
1289-
const ur_exp_command_buffer_update_exec_info_desc_t *pstruct = (const ur_exp_command_buffer_update_exec_info_desc_t *)ptr;
1290-
printPtr(os, pstruct);
1291-
} break;
1292-
12931284
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: {
12941285
const ur_exp_sampler_mip_properties_t *pstruct = (const ur_exp_sampler_mip_properties_t *)ptr;
12951286
printPtr(os, pstruct);
@@ -9525,46 +9516,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
95259516
return os;
95269517
}
95279518
///////////////////////////////////////////////////////////////////////////////
9528-
/// @brief Print operator for the ur_exp_command_buffer_update_exec_info_desc_t type
9529-
/// @returns
9530-
/// std::ostream &
9531-
inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_buffer_update_exec_info_desc_t params) {
9532-
os << "(struct ur_exp_command_buffer_update_exec_info_desc_t){";
9533-
9534-
os << ".stype = ";
9535-
9536-
os << (params.stype);
9537-
9538-
os << ", ";
9539-
os << ".pNext = ";
9540-
9541-
ur::details::printStruct(os,
9542-
(params.pNext));
9543-
9544-
os << ", ";
9545-
os << ".propName = ";
9546-
9547-
os << (params.propName);
9548-
9549-
os << ", ";
9550-
os << ".propSize = ";
9551-
9552-
os << (params.propSize);
9553-
9554-
os << ", ";
9555-
os << ".pProperties = ";
9556-
9557-
os << (params.pProperties);
9558-
9559-
os << ", ";
9560-
os << ".pNewExecInfo = ";
9561-
9562-
os << (params.pNewExecInfo);
9563-
9564-
os << "}";
9565-
return os;
9566-
}
9567-
///////////////////////////////////////////////////////////////////////////////
95689519
/// @brief Print operator for the ur_exp_command_buffer_update_kernel_launch_desc_t type
95699520
/// @returns
95709521
/// std::ostream &
@@ -9596,11 +9547,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
95969547

95979548
os << (params.numNewValueArgs);
95989549

9599-
os << ", ";
9600-
os << ".numNewExecInfos = ";
9601-
9602-
os << (params.numNewExecInfos);
9603-
96049550
os << ", ";
96059551
os << ".newWorkDim = ";
96069552

@@ -9639,17 +9585,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
96399585
}
96409586
os << "}";
96419587

9642-
os << ", ";
9643-
os << ".pNewExecInfoList = {";
9644-
for (size_t i = 0; (params.pNewExecInfoList) != NULL && i < params.numNewExecInfos; ++i) {
9645-
if (i != 0) {
9646-
os << ", ";
9647-
}
9648-
9649-
os << ((params.pNewExecInfoList))[i];
9650-
}
9651-
os << "}";
9652-
96539588
os << ", ";
96549589
os << ".pNewGlobalWorkOffset = {";
96559590
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)