KhronosGroup / KhronosGroup/OpenCL-Docs

cl_khr_command_buffer_multi_device clEnqueueCommandBufferKHR clarification

Open
#1,505 1 comment 0 reactions 0 assignees View on GitHub
cl_khr_command_buffer
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

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](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#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](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#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](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_SUBMITTED) to [CL_RUNNING](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_RUNNING), all events that this command is waiting on must have completed successfully i.e. their execution status must be [CL_COMPLETE](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#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.

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked OpenCL API definitions for CL_SUBMITTED and CL_RUNNING, then review the command-buffer multi-device semantics relevant to clEnqueueCommandBufferKHR, clFlush, and clFinish. Done means the event-state transitions and required queue synchronization behavior are resolved and documented unambiguously.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.