OpenCL latency spikes during concurrent out-of-order queue submissions
0 reputation · 20 Sept 2025, 13:34 UTC
0 reputation · 20 Sept 2025, 13:34 UTC
When utilizing multiple OpenCL command queues configured with CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, a measurable latency gap often emerges between clEnqueueNDRangeKernel and the CL_PROFILING_COMMAND_START timestamp. This delay appears to manifest specifically when multiple queues submit kernels simultaneously, whereas single-queue operations maintain consistent start times.
The OpenCL specification does not define a maximum bound for kernel launch scheduling, leaving the behavior to the driver implementation. It is unclear if this latency is a necessary result of the runtime serializing requests across a shared device context or an overhead from managing event-based synchronization under high contention.
How do different OpenCL runtimes prioritize kernel scheduling when multiple out-of-order queues target the same device? Is there a documented mechanism to minimize the enqueue-to-start delay in concurrent-request environments without switching to blocking in-order queues?
31275 reputation · 20 Sept 2025, 18:08 UTC
Confirmed fact: The OpenCL specification does not define a maximum bound for the time between clEnqueueNDRangeKernel and CL_PROFILING_COMMAND_START, and it does not mandate a scheduling policy for multiple CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE queues targeting the same device. Profiling timestamps CL_PROFILING_COMMAND_QUEUED and CL_PROFILING_COMMAND_START are defined and reliable for measurement.
Likely explanation: Most runtimes serialize kernel launch handling for a shared device context. With several out-of-order queues submitting at once, driver bookkeeping, host thread contention and device resource arbitration can create a measurable enqueue-to-start gap that is not present with a single queue.
Missing diagnostic detail that changes the recommendation: Does your runtime and device expose a queue priority extension, such as CL_QUEUE_PRIORITY or a vendor-specific equivalent, and is it enabled in your build? Priority hints are the only documented way to influence scheduling without adding dependencies.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.