Skip to content

check that devices match in the command buffer emulation layer - #173

Merged
bashbaug merged 1 commit into
mainfrom
cmdbuf-match-devices
Aug 4, 2026
Merged

check that devices match in the command buffer emulation layer#173
bashbaug merged 1 commit into
mainfrom
cmdbuf-match-devices

Conversation

@bashbaug

@bashbaug bashbaug commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Specifically, check for this error condition for clEnqueueCommandBufferKHR:

CL_INVALID_DEVICE if any element of queues does not have the same device as the command-queue set on command_buffer creation at the same list index.

This is important for multi-device contexts, especially heterogeneous multi-device contexts, where a command-queue may be created against the same context but be for a very different device.

This error condition specifically:
CL_INVALID_DEVICE if any element of queues does not have the same device as the command-queue set on command_buffer creation at the same list index.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds stricter validation in the command-buffer emulation layer to ensure that queues passed to clEnqueueCommandBufferKHR are associated with the same device as the queue used when the command buffer was created, improving correctness for multi-device (including heterogeneous) contexts.

Changes:

  • Query the device associated with the command-buffer’s creation queue.
  • For each enqueue-time queue, query its device and return CL_INVALID_DEVICE when it does not match the command-buffer device.
Suppressed comments (1)

layers/10_cmdbufemu/emulate.cpp:1537

  • clGetCommandQueueInfo for queue_device ignores its return value. On failure, queue_device may remain null and the device-match check can incorrectly pass/fail. Handle the error and return it before comparing device IDs.
            cl_device_id queue_device = nullptr;
            g_pNextDispatch->clGetCommandQueueInfo(
                queues[q],
                CL_QUEUE_DEVICE,
                sizeof(queue_device),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread layers/10_cmdbufemu/emulate.cpp
@bashbaug
bashbaug merged commit 07a69d8 into main Aug 4, 2026
13 checks passed
@bashbaug
bashbaug deleted the cmdbuf-match-devices branch August 4, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants