diff --git a/include/ur_api.h b/include/ur_api.h index 8579ff0326..2e932ceeb6 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -7929,6 +7929,8 @@ typedef struct ur_exp_command_buffer_command_handle_t_ *ur_exp_command_buffer_co /// + `NULL == phCommandBuffer` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_OPERATION +/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES UR_APIEXPORT ur_result_t UR_APICALL diff --git a/scripts/core/exp-command-buffer.yml b/scripts/core/exp-command-buffer.yml index d2292ceb22..1f8934d4b2 100644 --- a/scripts/core/exp-command-buffer.yml +++ b/scripts/core/exp-command-buffer.yml @@ -261,6 +261,8 @@ params: returns: - $X_RESULT_ERROR_INVALID_CONTEXT - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_OPERATION: + - "If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP." - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY - $X_RESULT_ERROR_OUT_OF_RESOURCES --- #-------------------------------------------------------------------------- diff --git a/source/adapters/opencl/command_buffer.cpp b/source/adapters/opencl/command_buffer.cpp index 9772bb4a23..436b82a5b6 100644 --- a/source/adapters/opencl/command_buffer.cpp +++ b/source/adapters/opencl/command_buffer.cpp @@ -73,23 +73,25 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp( const bool IsUpdatable = pCommandBufferDesc ? pCommandBufferDesc->isUpdatable : false; - bool SupportsUpdate = false; + bool DeviceSupportsUpdate = false; cl_device_id CLDevice = cl_adapter::cast(hDevice); - CL_RETURN_ON_FAILURE( - deviceSupportsURCommandBufferKernelUpdate(CLDevice, SupportsUpdate)); + CL_RETURN_ON_FAILURE(deviceSupportsURCommandBufferKernelUpdate( + CLDevice, DeviceSupportsUpdate)); - const bool Updatable = IsUpdatable && SupportsUpdate; + if (IsUpdatable && !DeviceSupportsUpdate) { + return UR_RESULT_ERROR_INVALID_OPERATION; + } cl_command_buffer_properties_khr Properties[3] = { CL_COMMAND_BUFFER_FLAGS_KHR, - Updatable ? CL_COMMAND_BUFFER_MUTABLE_KHR : 0u, 0}; + IsUpdatable ? CL_COMMAND_BUFFER_MUTABLE_KHR : 0u, 0}; auto CLCommandBuffer = clCreateCommandBufferKHR( 1, cl_adapter::cast(&Queue), Properties, &Res); CL_RETURN_ON_FAILURE_AND_SET_NULL(Res, phCommandBuffer); try { auto URCommandBuffer = std::make_unique( - Queue, hContext, CLCommandBuffer, Updatable); + Queue, hContext, CLCommandBuffer, IsUpdatable); *phCommandBuffer = URCommandBuffer.release(); } catch (...) { return UR_RESULT_ERROR_OUT_OF_RESOURCES; @@ -499,7 +501,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( ArgPointerList[i]; cl_mutable_dispatch_arg_khr &USMArg = CLUSMArgs[i]; USMArg.arg_index = URPointerArg.argIndex; - USMArg.arg_value = *(void **)URPointerArg.pNewPointerArg; + USMArg.arg_value = *(void *const *)URPointerArg.pNewPointerArg; } // Find the memory object and scalar arguments to the kernel. diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 1e9400aaa4..cc51a13267 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -7030,6 +7030,8 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( /// + `NULL == phCommandBuffer` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_OPERATION +/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urCommandBufferCreateExp( diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 5ee68ce529..330ae083c0 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -5966,6 +5966,8 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( /// + `NULL == phCommandBuffer` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_OPERATION +/// + If `pCommandBufferDesc->isUpdatable` is true and `hDevice` does not support UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urCommandBufferCreateExp(