Skip to content

Commit 0d8b7d7

Browse files
author
Fábio Mestre
committed
Add kernel update to command-buffer documentation
1 parent 6414642 commit 0d8b7d7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/core/EXP-COMMAND-BUFFER.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,14 @@ ${X}_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP query.
173173
Updating kernel commands is done by passing the new kernel configuration
174174
to ${x}CommandBufferUpdateKernelLaunchExp along with the command handle of
175175
the kernel command to update. Configurations that can be changed are the
176-
parameters to the kernel and the execution ND-Range.
176+
kernel handle, the parameters to the kernel and the execution ND-Range.
177+
178+
To update the kernel handle, it is necessary to first register the new
179+
kernel handle before the command-buffer is finalized. This can be done
180+
using the ``phKernelAlternatives`` parameter of
181+
${x}CommandBufferUpdateKernelLaunchExp. The command-buffer can then
182+
be updated to use the new kernel handle by passing it to
183+
${x}CommandBufferUpdateKernelLaunchExp.
177184

178185
.. parsed-literal::
179186
@@ -187,12 +194,14 @@ parameters to the kernel and the execution ND-Range.
187194
${x}CommandBufferCreateExp(hContext, hDevice, &desc, &hCommandBuffer);
188195
189196
// Append a kernel command which has two buffer parameters, an input
190-
// and an output.
197+
// and an output. Register hNewKernel as an alternative kernel handle
198+
// which can later be used to change the kernel handle associated
199+
// with this command.
191200
${x}_exp_command_buffer_command_handle_t hCommand;
192201
${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim,
193202
pGlobalWorkOffset, pGlobalWorkSize,
194-
pLocalWorkSize, 0, nullptr, 0, nullptr,
195-
nullptr, &hCommand);
203+
pLocalWorkSize, 1, &hNewKernel,
204+
0, nullptr, nullptr, &hCommand);
196205
197206
// Close the command-buffer before updating
198207
${x}CommandBufferFinalizeExp(hCommandBuffer);
@@ -220,7 +229,7 @@ parameters to the kernel and the execution ND-Range.
220229
${x}_exp_command_buffer_update_kernel_launch_desc_t update {
221230
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC, // stype
222231
nullptr, // pNext
223-
hKernel //hNewKernel
232+
hNewKernel // hNewKernel
224233
2, // numNewMemobjArgs
225234
0, // numNewPointerArgs
226235
0, // numNewValueArgs

0 commit comments

Comments
 (0)