Skip to content

Commit 4a68f61

Browse files
authored
Merge pull request #2287 from Bensuo/fabio/fix_level_zero_updates
[Command-Buffer] Fix update validation for L0 and OpenCL
2 parents a13fc7e + 8d60ded commit 4a68f61

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ ur_result_t validateCommandDesc(
13721372
logger::debug("Mutable features supported by device {}", SupportedFeatures);
13731373

13741374
// Kernel handle updates are not yet supported.
1375-
if (CommandDesc->hNewKernel != Command->Kernel) {
1375+
if (CommandDesc->hNewKernel && CommandDesc->hNewKernel != Command->Kernel) {
13761376
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
13771377
}
13781378

source/adapters/opencl/command_buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
547547
*pUpdateKernelLaunch) {
548548

549549
// Kernel handle updates are not yet supported.
550-
if (pUpdateKernelLaunch->hNewKernel != hCommand->Kernel) {
550+
if (pUpdateKernelLaunch->hNewKernel &&
551+
pUpdateKernelLaunch->hNewKernel != hCommand->Kernel) {
551552
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
552553
}
553554

test/conformance/exp_command_buffer/exp_command_buffer_adapter_native_cpu.match

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{{OPT}}USMSaxpyKernelTest.UpdateParameters/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
2222
{{OPT}}USMMultiSaxpyKernelTest.UpdateParameters/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
2323
{{OPT}}USMMultiSaxpyKernelTest.UpdateWithoutBlocking/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
24+
{{OPT}}USMMultiSaxpyKernelTest.UpdateNullptrKernel/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
2425
{{OPT}}NDRangeUpdateTest.Update3D/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
2526
{{OPT}}NDRangeUpdateTest.Update2D/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
2627
{{OPT}}NDRangeUpdateTest.Update1D/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}

test/conformance/exp_command_buffer/update/usm_saxpy_kernel_update.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,59 @@ TEST_P(USMMultiSaxpyKernelTest, UpdateParameters) {
284284
Validate(new_output, new_X, new_Y, new_A, global_size);
285285
}
286286

287+
// Checks that passing nullptr to hNewKernel even when kernel binary updates
288+
// is not supported by the adapter.
289+
TEST_P(USMMultiSaxpyKernelTest, UpdateNullptrKernel) {
290+
ASSERT_SUCCESS(urCommandBufferEnqueueExp(updatable_cmd_buf_handle, queue, 0,
291+
nullptr, nullptr));
292+
ASSERT_SUCCESS(urQueueFinish(queue));
293+
294+
uint32_t *output = (uint32_t *)shared_ptrs[0];
295+
uint32_t *X = (uint32_t *)shared_ptrs[1];
296+
uint32_t *Y = (uint32_t *)shared_ptrs[2];
297+
Validate(output, X, Y, A, global_size);
298+
299+
// New A at index 1
300+
uint32_t new_A = 33;
301+
ur_exp_command_buffer_update_value_arg_desc_t new_A_desc = {
302+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC, // stype
303+
nullptr, // pNext
304+
1, // argIndex
305+
sizeof(new_A), // argSize
306+
nullptr, // pProperties
307+
&new_A, // hArgValue
308+
};
309+
310+
// Update kernel inputs
311+
ur_exp_command_buffer_update_kernel_launch_desc_t update_desc = {
312+
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC, // stype
313+
nullptr, // pNext
314+
nullptr, // hNewKernel
315+
0, // numNewMemObjArgs
316+
0, // numNewPointerArgs
317+
1, // numNewValueArgs
318+
n_dimensions, // newWorkDim
319+
nullptr, // pNewMemObjArgList
320+
nullptr, // pNewPointerArgList
321+
&new_A_desc, // pNewValueArgList
322+
nullptr, // pNewGlobalWorkOffset
323+
nullptr, // pNewGlobalWorkSize
324+
nullptr, // pNewLocalWorkSize
325+
};
326+
327+
for (auto &handle : command_handles) {
328+
ASSERT_SUCCESS(
329+
urCommandBufferUpdateKernelLaunchExp(handle, &update_desc));
330+
}
331+
ASSERT_SUCCESS(urCommandBufferEnqueueExp(updatable_cmd_buf_handle, queue, 0,
332+
nullptr, nullptr));
333+
ASSERT_SUCCESS(urQueueFinish(queue));
334+
335+
// Verify that update occurred correctly
336+
uint32_t *new_output = (uint32_t *)shared_ptrs[0];
337+
Validate(new_output, X, Y, new_A, global_size);
338+
}
339+
287340
TEST_P(USMMultiSaxpyKernelTest, UpdateWithoutBlocking) {
288341
// Prepare new inputs
289342
ur_exp_command_buffer_update_pointer_arg_desc_t new_input_descs[2];

0 commit comments

Comments
 (0)