Skip to content

setting kernel arguments before recording it in command buffer#1382

Merged
bashbaug merged 207 commits intoKhronosGroup:mainfrom
aharon-abramson:issue_1329
Sep 9, 2025
Merged

setting kernel arguments before recording it in command buffer#1382
bashbaug merged 207 commits intoKhronosGroup:mainfrom
aharon-abramson:issue_1329

Conversation

@aharon-abramson
Copy link
Contributor

Add an image for the life cycle in mutable command buffers and specify that there is no need to set all the kernel arguments before recording it.

aharon-abramson and others added 30 commits November 6, 2023 14:53
Add type cl_mutable_dispatch_promises_khr and its possible values
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
Co-authored-by: Sun Serega <sunserega2@gmail.com>
Co-authored-by: Sun Serega <sunserega2@gmail.com>
replace error with undefined behavior
Co-authored-by: Sun Serega <sunserega2@gmail.com>
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
Co-authored-by: Sun Serega <sunserega2@gmail.com>
Delete obsolete comment in cl_khr_semaphore.  Issue
…#991)

* Use hexapdf instead of ghostscript for PDF optimization

Resulting PDFs tend to be considerably smaller, and also runs about 15%
faster when doing a full PDF build (2:39 vs. 3:06 on my machine).

The hexapdf tool does need to be installed in the build environment - it
is in the khronosgroup/docker-images:asciidoctor-spec Docker image.

* Add hexapdf to Travis environment.
…hronosGroup#996)

* cl_khr_semaphore: Enforce one device semaphores (KhronosGroup#973)

Only permit semaphores to be associated with a single device.  Add an error code for invalid use.

* Changes wording according to review comments

* Change error code to CL_INVALID_PROPERTY if a context is multi-device, and no device is specified.
Since the layers spec is not published in the OpenCL extension spec
and is instead published on the OpenCL registry similar to EXT and
vendor extensions, it makes more sense to put it in the extensions
directory.
* cl_semaphore_khr: Query if semaphore is exportable

Add query to clGetSemaphoreInfoKHR that returns CL_TRUE if a semaphore is exportable.

* Change extension version to 0.9.1

* Add missing brackets around return types.
The default behavior when the device handle list is not specified
is now properly described, so the TODO comment can be removed.
Change-Id: I942c3ce47284e7aea93edc02cf0f327af95e4ed9
@joselopeqti
Copy link
Contributor

We are ok with allowing applications to call clFinalizeCommandBufferKHR when all of the kernel arguments are not said. However we do have concerns about what the implementation must track and report regarding the state of the command buffer. Some of these concerns overlap with issue #1311. The concerns are -

  1. Is the implementation expected to simply track whether or not all arguments have been set in a command buffer but not worry about which kernels have missing arguments?
  2. Distinguishing Pending vs either Finalized or Executable state will be expensive to implement. We would prefer not to have the Finalized
  3. Is the application expected to take responsibility for tracking command buffer state. Therefore neither the returned error message nor a direct query will be available to clearly detect finalized state

@aharon-abramson
Copy link
Contributor Author

  1. Yes, the implementation doesn't need to track which kernels have missing arguments.
  2. Tracking if all kernels have all their arguments set is already required today when calling clFinalizeCommandBufferKHR, so I don't think adding the extra state adds more work.
  3. I don't quite understand this point; is it a question?

@EwanC
Copy link
Contributor

EwanC commented Aug 26, 2025

Now that #1411 is merged, this PR can be rebased. Let me know if you have any questions about how to resolve the conflicts, since there will definitely be some.

@EwanC EwanC self-requested a review August 26, 2025 16:54
Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

Comments are all minor editorial points

Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

Spotted a couple other trivial things, but otherwise LGTM

aharon-abramson and others added 2 commits August 31, 2025 08:59
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
Copy link
Contributor

@kpet kpet left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@joselopeqti
Copy link
Contributor

Can we confirm that the only queryable command buffer states are recording, finalized and executable?

@EwanC
Copy link
Contributor

EwanC commented Sep 5, 2025

Can we confirm that the only queryable command buffer states are recording, finalized and executable?

Yup that's the case. After #1411 merged the only queryable states became finalized or executable, then this PR adds the finalized state to that.

@bashbaug
Copy link
Contributor

bashbaug commented Sep 5, 2025

I think there's a small typo / copy paste error, and this should be:

After #1411 merged the only queryable states became >>>recording<<< or executable, then this PR adds the finalized state to that.

@bashbaug
Copy link
Contributor

bashbaug commented Sep 9, 2025

Merging as discussed in the September 9th teleconference.

@bashbaug bashbaug merged commit 4648526 into KhronosGroup:main Sep 9, 2025
2 checks passed
EwanC added a commit to EwanC/OpenCL-Docs that referenced this pull request Oct 7, 2025
KhronosGroup#1382 added support
for deferring setting arguments on a kernel command which is updatable.
To achieve this we added an extra command-buffer state, "Finalized"
which is entered when a command-buffer has been finalized but doesn't
yet have all it's arguments set.

However, if a user tries to enqueue a command-buffer in this state
it shouldn't be valid. Therefore update our current wording about
when an command-buffer can be enqueued to say the specifically the executable
state, rather than just after the finalization operation, which could
result in the command-buffer being in either the finalization or executable
state.
EwanC added a commit to EwanC/OpenCL-Docs that referenced this pull request Oct 7, 2025
KhronosGroup#1382 added support
for deferring setting arguments on a kernel command which is updatable.
To achieve this we added an extra command-buffer state, "finalized"
which is entered when a command-buffer has been finalized but doesn't
yet have all it's arguments set.

However, if a user tries to enqueue a command-buffer in this state
it shouldn't be valid. Therefore update our current wording about
when an command-buffer can be enqueued to say the specifically the executable
state, when all arguments are available. Rather than defined as after the
finalization operation, which could result in the command-buffer being in
either the finalization or executable state.

We already have a NOTE above to this effect, which I've removed as it
felt like it didn't add any extra value above the error definition, but
can added back if folks think it's worthwhile.
EwanC added a commit to EwanC/OpenCL-CTS that referenced this pull request Oct 7, 2025
Tests the scenario outlined in
KhronosGroup#2520 (comment)
to verify the functionality added in OpenCL-Docs PR
KhronosGroup/OpenCL-Docs#1382.

Note that this bumps the required cl_khr_command_buffer_mutable_dispatch
minor version by 2 because
KhronosGroup#2477 is not yet merged
which test the intermediate version.

This also assumes the proposed OpenCL-Docs change in
KhronosGroup/OpenCL-Docs#1471 is merged, as
the PR does a negative test for command-buffer enqueue while the
command-buffer is in the finalized state.

Closes KhronosGroup#2520
bashbaug pushed a commit that referenced this pull request Oct 14, 2025
#1382 added support
for deferring setting arguments on a kernel command which is updatable.
To achieve this we added an extra command-buffer state, "finalized"
which is entered when a command-buffer has been finalized but doesn't
yet have all it's arguments set.

However, if a user tries to enqueue a command-buffer in this state
it shouldn't be valid. Therefore update our current wording about
when an command-buffer can be enqueued to say the specifically the executable
state, when all arguments are available. Rather than defined as after the
finalization operation, which could result in the command-buffer being in
either the finalization or executable state.

We already have a NOTE above to this effect, which I've removed as it
felt like it didn't add any extra value above the error definition, but
can added back if folks think it's worthwhile.
EwanC added a commit to EwanC/OpenCL-CTS that referenced this pull request Oct 17, 2025
Tests the scenario outlined in
KhronosGroup#2520 (comment)
to verify the functionality added in OpenCL-Docs PR
KhronosGroup/OpenCL-Docs#1382.

Note that this bumps the required cl_khr_command_buffer_mutable_dispatch
minor version by 2 because
KhronosGroup#2477 is not yet merged
which test the intermediate version.

This also assumes the proposed OpenCL-Docs change in
KhronosGroup/OpenCL-Docs#1471 is merged, as
the PR does a negative test for command-buffer enqueue while the
command-buffer is in the finalized state.

Closes KhronosGroup#2520
bashbaug added a commit to KhronosGroup/OpenCL-CTS that referenced this pull request Nov 27, 2025
Tests the scenario outlined in
#2520 (comment)
to verify the functionality added in OpenCL-Docs PR
KhronosGroup/OpenCL-Docs#1382.

Closes #2520

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cl_khr_command_buffer Relating to the command-buffer family of extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setting kernel arguments before recording it in command buffer