Skip to content

Command-buffer queue comptabaility #1142

@EwanC

Description

@EwanC

The current clCreateCommandBufferKHR API takes a list of queues on creation, and enforces that the properties of these queues must match the properties of the matching queues passed in clEnqueueCommandBufferKHR. However, this API design does not work well for applications that do not know at the time of command-buffer creation what the properties of the queue that the command-buffer will be executed on are.

In particular this is an issue for SYCL-Graph layering, where when the command-buffer is created during graph.finalize(), the SYCL-RT does not yet know what SYCL queue a user will submit the graph to. The graph is treated as a black box by the SYCL queue that is executed in-order or out-of-order with respect to the other SYCL queue commands depending on the type of queue.

There are two possible approaches to help with this in cl_khr_command_buffer that I've thought about so far:

  1. Optional feature to relax queue compatibility constraint - Add an optional feature to relax the constraint that the queues passed to clEnqueueCommandBuffer must be compatible with those set on creation (or maybe a query to check for "compatible" means for that vendor). The SYCL-RT could already use the clRemapCommandBufferKHR() API with CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR for this to created a remap of the command-buffer before each enqueue during graph submission, but we don't really want to incur the deep copy cost here and the cl_khr_command_buffer_multi_device extension also doesn't have a large amount of vendor coverage. However, a drawback of this is that the SYCL-RT would still need to create a placeholder OpenCL queue when the command-buffer is created and commands added, which has a construction overhead.

  2. Remove the queue object from the command-buffer interface enqueue time. We could replace the command-queue parameters with device parameters (and a context parameter on creation) on command-queue creation/command adding/remap and then only introduce the queues at clEnqueueCommandBuffer time. We'd probably still want more command-buffer properties so that a user can say up-front what type of queue they want the command-buffer to run on if they want a more optimized implementation. This is quite an invasive change.

I haven't really thought all this through yet but the design point has come up recently so I think it's worth creating an issue to track the discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cl_khr_command_bufferRelating to the command-buffer family of extensionneeds-cts-coverageThe CTS needs to be extended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions