Skip to content

cl_khr_command_buffer_multi_device clEnqueueCommandBufferKHR clarification #1505

@AhmedAmraniAkdi

Description

@AhmedAmraniAkdi

Hi,

We have a few questions regarding clEnqueueCommandBufferKHR when multiple command queues are passed to it:

1- When does the event state transition happens?

We understand the status is set to CL_COMPLETE when the workload finishes across all command queues. What about CL_RUNNING and CL_SUBMITTED?

CL_SUBMITTED: The initial state for all user events. For all other events, indicates that the command has been submitted by the host to the device.

CL_RUNNING: Indicates that the device has started executing this command. In order for the execution status of an enqueued command to change from CL_SUBMITTED to CL_RUNNING, all events that this command is waiting on must have completed successfully i.e. their execution status must be CL_COMPLETE.

These states are with respect to the device the command is running on, but in this case we might have multiple devices. Would we have the following?

CL_SUBMITTED means command buffer has been submitted into all the queues.
CL_RUNNING means started running into all the queues.

2- Does clFlush/clFinish need to be called for all command queues in the command buffer when calling clEnqueueCommandBufferKHR?

Scenario A:

// A list of in-order command queues
cl_command_queue queues[num_queues];
// Create the command buffer for multiple command queues, record some commands across all queues and finalize it
// Assume no sync points when recording.
cl_command_buffer_khr command_buffer = clCreateCommandBufferKHR(num_queues, queues, ...);
...
clEnqueueCommandBuffer(0, NULL, command_buffer, 0, NULL, NULL);
clEnqueueNDRangeKernel(queues[0], some_kernel, ..., 0, NULL, NULL);
clFinish(queues[0]);

In this case, does clEnqueueNDRangeKernel execute because it only waits on the commands from queues[0], or does the code hang because it needs all queues to have finished to continue?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cl_khr_command_bufferRelating to the command-buffer family of extension

    Type

    No type

    Projects

    Status

    Needs Discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions