Skip to content

Commit 69941b8

Browse files
authored
[UR] Make command-buffer creation descriptor mandatory (#17058)
As discussed in oneapi-src/unified-runtime#2670 (comment) the `pCommandBufferDesc` parameter to `urCommandBufferCreateExp` is optional. However, the UR spec doesn't state what the configuration of the created command-buffer is when this isn't passed, and being optional is also inconsistent with the description parameters to urSamplerCreate & urMemImageCreate which are not optional. This PR updates the descriptor parameter to command-buffer creation to be mandatory to address these concerns. Closes oneapi-src/unified-runtime#2673 **Note**: This UR patch was previously approved and ready-to-merge in oneapi-src/unified-runtime#2676 prior to the repo move
1 parent 0b979bf commit 69941b8

File tree

16 files changed

+49
-40
lines changed

16 files changed

+49
-40
lines changed

unified-runtime/include/ur_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10111,6 +10111,7 @@ typedef struct ur_exp_command_buffer_command_handle_t_
1011110111
/// + `NULL == hContext`
1011210112
/// + `NULL == hDevice`
1011310113
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
10114+
/// + `NULL == pCommandBufferDesc`
1011410115
/// + `NULL == phCommandBuffer`
1011510116
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
1011610117
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
@@ -10125,7 +10126,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
1012510126
ur_context_handle_t hContext,
1012610127
/// [in] Handle of the device object.
1012710128
ur_device_handle_t hDevice,
10128-
/// [in][optional] command-buffer descriptor.
10129+
/// [in] Command-buffer descriptor.
1012910130
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
1013010131
/// [out][alloc] Pointer to command-Buffer handle.
1013110132
ur_exp_command_buffer_handle_t *phCommandBuffer);

unified-runtime/scripts/core/exp-command-buffer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ params:
282282
desc: "[in] Handle of the device object."
283283
- type: "const $x_exp_command_buffer_desc_t*"
284284
name: pCommandBufferDesc
285-
desc: "[in][optional] command-buffer descriptor."
285+
desc: "[in] Command-buffer descriptor."
286286
- type: "$x_exp_command_buffer_handle_t*"
287287
name: phCommandBuffer
288288
desc: "[out][alloc] Pointer to command-Buffer handle."

unified-runtime/source/adapters/cuda/command_buffer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
352352
ur_context_handle_t hContext, ur_device_handle_t hDevice,
353353
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
354354
ur_exp_command_buffer_handle_t *phCommandBuffer) {
355-
356-
const bool IsUpdatable =
357-
pCommandBufferDesc ? pCommandBufferDesc->isUpdatable : false;
358-
355+
const bool IsUpdatable = pCommandBufferDesc->isUpdatable;
359356
try {
360357
*phCommandBuffer =
361358
new ur_exp_command_buffer_handle_t_(hContext, hDevice, IsUpdatable);

unified-runtime/source/adapters/hip/command_buffer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
233233
ur_context_handle_t hContext, ur_device_handle_t hDevice,
234234
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
235235
ur_exp_command_buffer_handle_t *phCommandBuffer) {
236-
const bool IsUpdatable =
237-
pCommandBufferDesc ? pCommandBufferDesc->isUpdatable : false;
238-
236+
const bool IsUpdatable = pCommandBufferDesc->isUpdatable;
239237
try {
240238
*phCommandBuffer =
241239
new ur_exp_command_buffer_handle_t_(hContext, hDevice, IsUpdatable);

unified-runtime/source/adapters/level_zero/command_buffer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,7 @@ bool canBeInOrder(ur_context_handle_t Context,
586586
bool CompatibleDriver = Context->getPlatform()->isDriverVersionNewerOrSimilar(
587587
1, 3, L0_DRIVER_INORDER_MIN_VERSION);
588588
bool CanUseDriverInOrderLists = CompatibleDriver && DriverInOrderRequested;
589-
return CanUseDriverInOrderLists
590-
? (CommandBufferDesc ? CommandBufferDesc->isInOrder : false)
591-
: false;
589+
return CanUseDriverInOrderLists ? CommandBufferDesc->isInOrder : false;
592590
}
593591

594592
/**
@@ -624,9 +622,8 @@ urCommandBufferCreateExp(ur_context_handle_t Context, ur_device_handle_t Device,
624622
const ur_exp_command_buffer_desc_t *CommandBufferDesc,
625623
ur_exp_command_buffer_handle_t *CommandBuffer) {
626624
bool IsInOrder = canBeInOrder(Context, CommandBufferDesc);
627-
bool EnableProfiling =
628-
CommandBufferDesc && CommandBufferDesc->enableProfiling && !IsInOrder;
629-
bool IsUpdatable = CommandBufferDesc && CommandBufferDesc->isUpdatable;
625+
bool EnableProfiling = CommandBufferDesc->enableProfiling && !IsInOrder;
626+
bool IsUpdatable = CommandBufferDesc->isUpdatable;
630627
bool ImmediateAppendPath = checkImmediateAppendSupport(Context, Device);
631628
const bool WaitEventPath = !ImmediateAppendPath;
632629
bool UseCounterBasedEvents = checkCounterBasedEventsSupport(Device) &&

unified-runtime/source/adapters/mock/ur_mockddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8403,7 +8403,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
84038403
ur_context_handle_t hContext,
84048404
/// [in] Handle of the device object.
84058405
ur_device_handle_t hDevice,
8406-
/// [in][optional] command-buffer descriptor.
8406+
/// [in] Command-buffer descriptor.
84078407
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
84088408
/// [out][alloc] Pointer to command-Buffer handle.
84098409
ur_exp_command_buffer_handle_t *phCommandBuffer) try {

unified-runtime/source/adapters/opencl/command_buffer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
4343
CLContext, cl_ext::ExtFuncPtrCache->clCreateCommandBufferKHRCache,
4444
cl_ext::CreateCommandBufferName, &clCreateCommandBufferKHR));
4545

46-
const bool IsUpdatable =
47-
pCommandBufferDesc ? pCommandBufferDesc->isUpdatable : false;
46+
const bool IsUpdatable = pCommandBufferDesc->isUpdatable;
4847

4948
ur_device_command_buffer_update_capability_flags_t UpdateCapabilities;
5049
cl_device_id CLDevice = cl_adapter::cast<cl_device_id>(hDevice);

unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6978,7 +6978,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
69786978
ur_context_handle_t hContext,
69796979
/// [in] Handle of the device object.
69806980
ur_device_handle_t hDevice,
6981-
/// [in][optional] command-buffer descriptor.
6981+
/// [in] Command-buffer descriptor.
69826982
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
69836983
/// [out][alloc] Pointer to command-Buffer handle.
69846984
ur_exp_command_buffer_handle_t *phCommandBuffer) {

unified-runtime/source/loader/layers/validation/ur_valddi.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7615,7 +7615,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
76157615
ur_context_handle_t hContext,
76167616
/// [in] Handle of the device object.
76177617
ur_device_handle_t hDevice,
7618-
/// [in][optional] command-buffer descriptor.
7618+
/// [in] Command-buffer descriptor.
76197619
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
76207620
/// [out][alloc] Pointer to command-Buffer handle.
76217621
ur_exp_command_buffer_handle_t *phCommandBuffer) {
@@ -7632,6 +7632,9 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
76327632
if (NULL == hDevice)
76337633
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
76347634

7635+
if (NULL == pCommandBufferDesc)
7636+
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
7637+
76357638
if (NULL == phCommandBuffer)
76367639
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
76377640
}

unified-runtime/source/loader/ur_ldrddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7044,7 +7044,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
70447044
ur_context_handle_t hContext,
70457045
/// [in] Handle of the device object.
70467046
ur_device_handle_t hDevice,
7047-
/// [in][optional] command-buffer descriptor.
7047+
/// [in] Command-buffer descriptor.
70487048
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
70497049
/// [out][alloc] Pointer to command-Buffer handle.
70507050
ur_exp_command_buffer_handle_t *phCommandBuffer) {

0 commit comments

Comments
 (0)