check that devices match in the command buffer emulation layer - #173
Merged
Conversation
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.
There was a problem hiding this comment.
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_DEVICEwhen it does not match the command-buffer device.
Suppressed comments (1)
layers/10_cmdbufemu/emulate.cpp:1537
clGetCommandQueueInfoforqueue_deviceignores its return value. On failure,queue_devicemay 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Specifically, check for this error condition for
clEnqueueCommandBufferKHR: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.