Skip to content

Commit 12e0e79

Browse files
committed
Make command-buffer creation descriptor mandatory
Closes oneapi-src#2673
1 parent 95e03b4 commit 12e0e79

File tree

16 files changed

+48
-39
lines changed

16 files changed

+48
-39
lines changed

include/ur_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10104,6 +10104,7 @@ typedef struct ur_exp_command_buffer_command_handle_t_
1010410104
/// + `NULL == hContext`
1010510105
/// + `NULL == hDevice`
1010610106
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
10107+
/// + `NULL == pCommandBufferDesc`
1010710108
/// + `NULL == phCommandBuffer`
1010810109
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
1010910110
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
@@ -10118,7 +10119,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
1011810119
ur_context_handle_t hContext,
1011910120
/// [in] Handle of the device object.
1012010121
ur_device_handle_t hDevice,
10121-
/// [in][optional] command-buffer descriptor.
10122+
/// [in] Command-buffer descriptor.
1012210123
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
1012310124
/// [out] Pointer to command-Buffer handle.
1012410125
ur_exp_command_buffer_handle_t *phCommandBuffer);

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] Pointer to command-Buffer handle."

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);

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);

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) &&

source/adapters/mock/ur_mockddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8395,7 +8395,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
83958395
ur_context_handle_t hContext,
83968396
/// [in] Handle of the device object.
83978397
ur_device_handle_t hDevice,
8398-
/// [in][optional] command-buffer descriptor.
8398+
/// [in] Command-buffer descriptor.
83998399
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
84008400
/// [out] Pointer to command-Buffer handle.
84018401
ur_exp_command_buffer_handle_t *phCommandBuffer) try {

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);

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6970,7 +6970,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
69706970
ur_context_handle_t hContext,
69716971
/// [in] Handle of the device object.
69726972
ur_device_handle_t hDevice,
6973-
/// [in][optional] command-buffer descriptor.
6973+
/// [in] Command-buffer descriptor.
69746974
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
69756975
/// [out] Pointer to command-Buffer handle.
69766976
ur_exp_command_buffer_handle_t *phCommandBuffer) {

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7607,7 +7607,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
76077607
ur_context_handle_t hContext,
76087608
/// [in] Handle of the device object.
76097609
ur_device_handle_t hDevice,
7610-
/// [in][optional] command-buffer descriptor.
7610+
/// [in] Command-buffer descriptor.
76117611
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
76127612
/// [out] Pointer to command-Buffer handle.
76137613
ur_exp_command_buffer_handle_t *phCommandBuffer) {
@@ -7624,6 +7624,9 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
76247624
if (NULL == hDevice)
76257625
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
76267626

7627+
if (NULL == pCommandBufferDesc)
7628+
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
7629+
76277630
if (NULL == phCommandBuffer)
76287631
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
76297632
}

source/loader/ur_ldrddi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7036,7 +7036,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp(
70367036
ur_context_handle_t hContext,
70377037
/// [in] Handle of the device object.
70387038
ur_device_handle_t hDevice,
7039-
/// [in][optional] command-buffer descriptor.
7039+
/// [in] Command-buffer descriptor.
70407040
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
70417041
/// [out] Pointer to command-Buffer handle.
70427042
ur_exp_command_buffer_handle_t *phCommandBuffer) {

source/loader/ur_libapi.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7612,6 +7612,7 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp(
76127612
/// + `NULL == hContext`
76137613
/// + `NULL == hDevice`
76147614
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7615+
/// + `NULL == pCommandBufferDesc`
76157616
/// + `NULL == phCommandBuffer`
76167617
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
76177618
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
@@ -7626,7 +7627,7 @@ ur_result_t UR_APICALL urCommandBufferCreateExp(
76267627
ur_context_handle_t hContext,
76277628
/// [in] Handle of the device object.
76287629
ur_device_handle_t hDevice,
7629-
/// [in][optional] command-buffer descriptor.
7630+
/// [in] Command-buffer descriptor.
76307631
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
76317632
/// [out] Pointer to command-Buffer handle.
76327633
ur_exp_command_buffer_handle_t *phCommandBuffer) try {

source/ur_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6657,6 +6657,7 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp(
66576657
/// + `NULL == hContext`
66586658
/// + `NULL == hDevice`
66596659
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
6660+
/// + `NULL == pCommandBufferDesc`
66606661
/// + `NULL == phCommandBuffer`
66616662
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
66626663
/// - ::UR_RESULT_ERROR_INVALID_DEVICE
@@ -6671,7 +6672,7 @@ ur_result_t UR_APICALL urCommandBufferCreateExp(
66716672
ur_context_handle_t hContext,
66726673
/// [in] Handle of the device object.
66736674
ur_device_handle_t hDevice,
6674-
/// [in][optional] command-buffer descriptor.
6675+
/// [in] Command-buffer descriptor.
66756676
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
66766677
/// [out] Pointer to command-Buffer handle.
66776678
ur_exp_command_buffer_handle_t *phCommandBuffer) {

test/conformance/exp_command_buffer/fixtures.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ struct urCommandBufferExpTest : uur::urContextTest {
6060
UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTest::SetUp());
6161

6262
UUR_RETURN_ON_FATAL_FAILURE(checkCommandBufferSupport(device));
63+
64+
ur_exp_command_buffer_desc_t desc{
65+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, false, false, false,
66+
};
6367
ASSERT_SUCCESS(
64-
urCommandBufferCreateExp(context, device, nullptr, &cmd_buf_handle));
68+
urCommandBufferCreateExp(context, device, &desc, &cmd_buf_handle));
6569
ASSERT_NE(cmd_buf_handle, nullptr);
6670
}
6771

@@ -83,8 +87,11 @@ struct urCommandBufferExpTestWithParam : urQueueTestWithParam<T> {
8387
UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam<T>::SetUp());
8488

8589
UUR_RETURN_ON_FATAL_FAILURE(checkCommandBufferSupport(this->device));
86-
ASSERT_SUCCESS(urCommandBufferCreateExp(this->context, this->device,
87-
nullptr, &cmd_buf_handle));
90+
91+
ur_exp_command_buffer_desc_t desc{UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC,
92+
nullptr, false, false, false};
93+
ASSERT_SUCCESS(urCommandBufferCreateExp(this->context, this->device, &desc,
94+
&cmd_buf_handle));
8895
ASSERT_NE(cmd_buf_handle, nullptr);
8996
}
9097

@@ -105,8 +112,11 @@ struct urCommandBufferExpExecutionTest : uur::urKernelExecutionTest {
105112
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
106113

107114
UUR_RETURN_ON_FATAL_FAILURE(checkCommandBufferSupport(device));
115+
116+
ur_exp_command_buffer_desc_t desc{UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC,
117+
nullptr, false, false, false};
108118
ASSERT_SUCCESS(
109-
urCommandBufferCreateExp(context, device, nullptr, &cmd_buf_handle));
119+
urCommandBufferCreateExp(context, device, &desc, &cmd_buf_handle));
110120
ASSERT_NE(cmd_buf_handle, nullptr);
111121
}
112122

@@ -333,15 +343,8 @@ struct urCommandEventSyncTest : urCommandBufferExpTest {
333343
ASSERT_NE(buffer, nullptr);
334344
}
335345

336-
// Create a command-buffer with update enabled.
337-
ur_exp_command_buffer_desc_t desc{
338-
/*.stype=*/UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC,
339-
/*.pNext =*/nullptr,
340-
/*.isUpdatable =*/false,
341-
/*.isInOrder =*/false,
342-
/*.enableProfiling =*/false,
343-
};
344-
346+
ur_exp_command_buffer_desc_t desc{UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC,
347+
nullptr, true, false, false};
345348
ASSERT_SUCCESS(urCommandBufferCreateExp(context, device, &desc,
346349
&second_cmd_buf_handle));
347350
ASSERT_NE(second_cmd_buf_handle, nullptr);

test/conformance/exp_command_buffer/kernel_event_sync.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct KernelCommandEventSyncTest
4040
ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 3, nullptr, device_ptrs[1]));
4141

4242
// Create second command-buffer
43+
ur_exp_command_buffer_desc_t desc{
44+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, false, false, false,
45+
};
4346
ASSERT_SUCCESS(urCommandBufferCreateExp(context, device, nullptr,
4447
&second_cmd_buf_handle));
4548
ASSERT_NE(second_cmd_buf_handle, nullptr);

test/conformance/exp_command_buffer/update/invalid_update.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ TEST_P(InvalidUpdateTest, NotFinalizedCommandBuffer) {
109109
TEST_P(InvalidUpdateTest, NotUpdatableCommandBuffer) {
110110
// Create a command-buffer without isUpdatable
111111
ur_exp_command_buffer_handle_t test_cmd_buf_handle = nullptr;
112+
ur_exp_command_buffer_desc_t desc{
113+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, false, false, false,
114+
};
112115
ASSERT_SUCCESS(
113-
urCommandBufferCreateExp(context, device, nullptr, &test_cmd_buf_handle));
116+
urCommandBufferCreateExp(context, device, &desc, &test_cmd_buf_handle));
114117
EXPECT_NE(test_cmd_buf_handle, nullptr);
115118

116119
// Append a kernel commands to command-buffer and close command-buffer

test/conformance/program/urMultiDeviceProgramCreateWithBinary.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,12 @@ TEST_P(urMultiDeviceCommandBufferExpTest, Enqueue) {
311311
}
312312

313313
// Create command-buffer
314+
ur_exp_command_buffer_desc_t desc{
315+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, false, false, false,
316+
};
314317
uur::raii::CommandBuffer cmd_buf_handle;
315-
ASSERT_SUCCESS(urCommandBufferCreateExp(context, device, nullptr,
316-
cmd_buf_handle.ptr()));
318+
ASSERT_SUCCESS(
319+
urCommandBufferCreateExp(context, device, &desc, cmd_buf_handle.ptr()));
317320

318321
// Append kernel command to command-buffer and close command-buffer
319322
ASSERT_SUCCESS(urCommandBufferAppendKernelLaunchExp(

0 commit comments

Comments
 (0)