Skip to content

Commit 67da5d8

Browse files
committed
Error if updatable command-buffer created without device support
1 parent 7e40f62 commit 67da5d8

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

include/ur_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7929,6 +7929,8 @@ typedef struct ur_exp_command_buffer_command_handle_t_ *ur_exp_command_buffer_co
79297929
/// + `NULL == phCommandBuffer`
79307930
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
79317931
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
7932+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
7933+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
79327934
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
79337935
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
79347936
UR_APIEXPORT ur_result_t UR_APICALL

scripts/core/exp-command-buffer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ params:
261261
returns:
262262
- $X_RESULT_ERROR_INVALID_CONTEXT
263263
- $X_RESULT_ERROR_INVALID_DEVICE
264+
- $X_RESULT_ERROR_INVALID_OPERATION:
265+
- "If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP."
264266
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
265267
- $X_RESULT_ERROR_OUT_OF_RESOURCES
266268
--- #--------------------------------------------------------------------------

source/adapters/opencl/command_buffer.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,25 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
7373
const bool IsUpdatable =
7474
pCommandBufferDesc ? pCommandBufferDesc->isUpdatable : false;
7575

76-
bool SupportsUpdate = false;
76+
bool DeviceSupportsUpdate = false;
7777
cl_device_id CLDevice = cl_adapter::cast<cl_device_id>(hDevice);
78-
CL_RETURN_ON_FAILURE(
79-
deviceSupportsURCommandBufferKernelUpdate(CLDevice, SupportsUpdate));
78+
CL_RETURN_ON_FAILURE(deviceSupportsURCommandBufferKernelUpdate(
79+
CLDevice, DeviceSupportsUpdate));
8080

81-
const bool Updatable = IsUpdatable && SupportsUpdate;
81+
if (IsUpdatable && !DeviceSupportsUpdate) {
82+
return UR_RESULT_ERROR_INVALID_OPERATION;
83+
}
8284

8385
cl_command_buffer_properties_khr Properties[3] = {
8486
CL_COMMAND_BUFFER_FLAGS_KHR,
85-
Updatable ? CL_COMMAND_BUFFER_MUTABLE_KHR : 0u, 0};
87+
IsUpdatable ? CL_COMMAND_BUFFER_MUTABLE_KHR : 0u, 0};
8688
auto CLCommandBuffer = clCreateCommandBufferKHR(
8789
1, cl_adapter::cast<cl_command_queue *>(&Queue), Properties, &Res);
8890
CL_RETURN_ON_FAILURE_AND_SET_NULL(Res, phCommandBuffer);
8991

9092
try {
9193
auto URCommandBuffer = std::make_unique<ur_exp_command_buffer_handle_t_>(
92-
Queue, hContext, CLCommandBuffer, Updatable);
94+
Queue, hContext, CLCommandBuffer, IsUpdatable);
9395
*phCommandBuffer = URCommandBuffer.release();
9496
} catch (...) {
9597
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
@@ -499,7 +501,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
499501
ArgPointerList[i];
500502
cl_mutable_dispatch_arg_khr &USMArg = CLUSMArgs[i];
501503
USMArg.arg_index = URPointerArg.argIndex;
502-
USMArg.arg_value = *(void **)URPointerArg.pNewPointerArg;
504+
USMArg.arg_value = *(void *const *)URPointerArg.pNewPointerArg;
503505
}
504506

505507
// Find the memory object and scalar arguments to the kernel.

source/loader/ur_libapi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7030,6 +7030,8 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp(
70307030
/// + `NULL == phCommandBuffer`
70317031
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
70327032
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
7033+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
7034+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
70337035
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
70347036
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
70357037
ur_result_t UR_APICALL urCommandBufferCreateExp(

source/ur_api.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5966,6 +5966,8 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp(
59665966
/// + `NULL == phCommandBuffer`
59675967
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
59685968
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
5969+
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
5970+
/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP.
59695971
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
59705972
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
59715973
ur_result_t UR_APICALL urCommandBufferCreateExp(

0 commit comments

Comments
 (0)