Skip to content

Commit 1397916

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 31d0fe1 commit 1397916

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
@@ -8022,19 +8021,6 @@ typedef struct ur_exp_command_buffer_update_value_arg_desc_t {
80228021

80238022
} ur_exp_command_buffer_update_value_arg_desc_t;
80248023

8025-
///////////////////////////////////////////////////////////////////////////////
8026-
/// @brief Descriptor type for updating kernel command execution info.
8027-
typedef struct ur_exp_command_buffer_update_exec_info_desc_t {
8028-
ur_structure_type_t stype; ///< [in] type of this structure, must be
8029-
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC
8030-
const void *pNext; ///< [in][optional] pointer to extension-specific structure
8031-
ur_kernel_exec_info_t propName; ///< [in] Name of execution attribute.
8032-
size_t propSize; ///< [in] Size of execution attribute.
8033-
const ur_kernel_exec_info_properties_t *pProperties; ///< [in][optional] Pointer to execution info properties.
8034-
const void *pNewExecInfo; ///< [in] Pointer to memory location holding the execution info value.
8035-
8036-
} ur_exp_command_buffer_update_exec_info_desc_t;
8037-
80388024
///////////////////////////////////////////////////////////////////////////////
80398025
/// @brief Descriptor type for updating a kernel launch command.
80408026
typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
@@ -8044,24 +8030,23 @@ typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
80448030
uint32_t numNewMemObjArgs; ///< [in] Length of pNewMemObjArgList.
80458031
uint32_t numNewPointerArgs; ///< [in] Length of pNewPointerArgList.
80468032
uint32_t numNewValueArgs; ///< [in] Length of pNewValueArgList.
8047-
uint32_t numNewExecInfos; ///< [in] Length of pNewExecInfoList.
80488033
uint32_t newWorkDim; ///< [in] Number of work dimensions in the kernel ND-range, from 1-3.
80498034
const ur_exp_command_buffer_update_memobj_arg_desc_t *pNewMemObjArgList; ///< [in][optional][range(0, numNewMemObjArgs)] An array describing the new
80508035
///< kernel mem obj arguments for the command.
80518036
const ur_exp_command_buffer_update_pointer_arg_desc_t *pNewPointerArgList; ///< [in][optional][range(0, numNewPointerArgs)] An array describing the
80528037
///< new kernel pointer arguments for the command.
80538038
const ur_exp_command_buffer_update_value_arg_desc_t *pNewValueArgList; ///< [in][optional][range(0, numNewValueArgs)] An array describing the new
80548039
///< kernel value arguments for the command.
8055-
const ur_exp_command_buffer_update_exec_info_desc_t *pNewExecInfoList; ///< [in][optional][range(0, numNewExecInfos)] An array describing the
8056-
///< execution info objects for the command.
80578040
size_t *pNewGlobalWorkOffset; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80588041
///< values that describe the offset used to calculate the global ID.
80598042
size_t *pNewGlobalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80608043
///< values that describe the number of global work-items.
80618044
size_t *pNewLocalWorkSize; ///< [in][optional][range(0, newWorkDim)] Array of newWorkDim unsigned
80628045
///< values that describe the number of work-items that make up a
8063-
///< work-group. If nullptr, the runtime implementation will choose the
8064-
///< work-group size.
8046+
///< work-group. If newWorkDim is non-zero and pNewLocalWorkSize is
8047+
///< nullptr, then runtime implementation will choose the work-group size.
8048+
///< If newWorkDim is zero and pNewLocalWorkSize is nullptr, then the local
8049+
///< work size is unchanged.
80658050

80668051
} ur_exp_command_buffer_update_kernel_launch_desc_t;
80678052

@@ -8096,6 +8081,8 @@ typedef struct ur_exp_command_buffer_command_handle_t_ *ur_exp_command_buffer_co
80968081
/// + `NULL == phCommandBuffer`
80978082
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
80988083
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
8084+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
8085+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
80998086
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
81008087
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
81018088
UR_APIEXPORT ur_result_t UR_APICALL
@@ -8176,7 +8163,6 @@ urCommandBufferFinalizeExp(
81768163
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
81778164
/// + `NULL == pGlobalWorkOffset`
81788165
/// + `NULL == pGlobalWorkSize`
8179-
/// + `NULL == pLocalWorkSize`
81808166
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP
81818167
/// - ::UR_RESULT_ERROR_INVALID_KERNEL
81828168
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
@@ -8195,7 +8181,7 @@ urCommandBufferAppendKernelLaunchExp(
81958181
uint32_t workDim, ///< [in] Dimension of the kernel execution.
81968182
const size_t *pGlobalWorkOffset, ///< [in] Offset to use when executing kernel.
81978183
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
8198-
const size_t *pLocalWorkSize, ///< [in] Local work size to use when executing kernel.
8184+
const size_t *pLocalWorkSize, ///< [in][optional] Local work size to use when executing kernel.
81998185
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
82008186
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
82018187
ur_exp_command_buffer_sync_point_t *pSyncPoint, ///< [out][optional] Sync point associated with this command.
@@ -8697,6 +8683,10 @@ urCommandBufferReleaseCommandExp(
86978683
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
86988684
/// + If ::ur_exp_command_buffer_desc_t::isUpdatable was not set to true on creation of the command buffer `hCommand` belongs to.
86998685
/// + If the command-buffer `hCommand` belongs to has not been finalized.
8686+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and different from the work-dim used on creation of `hCommand`.
8687+
/// + If `pUpdateKernellaunch->newWorkDim` is non-zero and `pUpdateKernelLaunch->pNewLocalWorkSize` is set to a non-NULL value and `pUpdateKernelLaunch->pNewGlobalWorkSize` is NULL.
8688+
/// + 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.
8689+
/// + 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.
87008690
/// - ::UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_COMMAND_HANDLE_EXP
87018691
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
87028692
/// - ::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
@@ -994,14 +994,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdatePointerArgDesc(
994994
/// - `buff_size < out_size`
995995
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);
996996

997-
///////////////////////////////////////////////////////////////////////////////
998-
/// @brief Print ur_exp_command_buffer_update_exec_info_desc_t struct
999-
/// @returns
1000-
/// - ::UR_RESULT_SUCCESS
1001-
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1002-
/// - `buff_size < out_size`
1003-
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);
1004-
1005997
///////////////////////////////////////////////////////////////////////////////
1006998
/// @brief Print ur_exp_command_buffer_update_kernel_launch_desc_t struct
1007999
/// @returns

include/ur_print.hpp

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
334334
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_memobj_arg_desc_t params);
335335
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_pointer_arg_desc_t params);
336336
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_value_arg_desc_t params);
337-
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_exec_info_desc_t params);
338337
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_kernel_launch_desc_t params);
339338
inline std::ostream &operator<<(std::ostream &os, enum ur_exp_peer_info_t value);
340339

@@ -1049,9 +1048,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value
10491048
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC:
10501049
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC";
10511050
break;
1052-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC:
1053-
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC";
1054-
break;
10551051
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES:
10561052
os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES";
10571053
break;
@@ -1290,11 +1286,6 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
12901286
printPtr(os, pstruct);
12911287
} break;
12921288

1293-
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC: {
1294-
const ur_exp_command_buffer_update_exec_info_desc_t *pstruct = (const ur_exp_command_buffer_update_exec_info_desc_t *)ptr;
1295-
printPtr(os, pstruct);
1296-
} break;
1297-
12981289
case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: {
12991290
const ur_exp_sampler_mip_properties_t *pstruct = (const ur_exp_sampler_mip_properties_t *)ptr;
13001291
printPtr(os, pstruct);
@@ -9620,46 +9611,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
96209611
return os;
96219612
}
96229613
///////////////////////////////////////////////////////////////////////////////
9623-
/// @brief Print operator for the ur_exp_command_buffer_update_exec_info_desc_t type
9624-
/// @returns
9625-
/// std::ostream &
9626-
inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_buffer_update_exec_info_desc_t params) {
9627-
os << "(struct ur_exp_command_buffer_update_exec_info_desc_t){";
9628-
9629-
os << ".stype = ";
9630-
9631-
os << (params.stype);
9632-
9633-
os << ", ";
9634-
os << ".pNext = ";
9635-
9636-
ur::details::printStruct(os,
9637-
(params.pNext));
9638-
9639-
os << ", ";
9640-
os << ".propName = ";
9641-
9642-
os << (params.propName);
9643-
9644-
os << ", ";
9645-
os << ".propSize = ";
9646-
9647-
os << (params.propSize);
9648-
9649-
os << ", ";
9650-
os << ".pProperties = ";
9651-
9652-
os << (params.pProperties);
9653-
9654-
os << ", ";
9655-
os << ".pNewExecInfo = ";
9656-
9657-
os << (params.pNewExecInfo);
9658-
9659-
os << "}";
9660-
return os;
9661-
}
9662-
///////////////////////////////////////////////////////////////////////////////
96639614
/// @brief Print operator for the ur_exp_command_buffer_update_kernel_launch_desc_t type
96649615
/// @returns
96659616
/// std::ostream &
@@ -9691,11 +9642,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
96919642

96929643
os << (params.numNewValueArgs);
96939644

9694-
os << ", ";
9695-
os << ".numNewExecInfos = ";
9696-
9697-
os << (params.numNewExecInfos);
9698-
96999645
os << ", ";
97009646
os << ".newWorkDim = ";
97019647

@@ -9734,17 +9680,6 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
97349680
}
97359681
os << "}";
97369682

9737-
os << ", ";
9738-
os << ".pNewExecInfoList = {";
9739-
for (size_t i = 0; (params.pNewExecInfoList) != NULL && i < params.numNewExecInfos; ++i) {
9740-
if (i != 0) {
9741-
os << ", ";
9742-
}
9743-
9744-
os << ((params.pNewExecInfoList))[i];
9745-
}
9746-
os << "}";
9747-
97489683
os << ", ";
97499684
os << ".pNewGlobalWorkOffset = {";
97509685
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)