Skip to content

[SYCL] Deprecate discard_events queue prop, make impl no-op #18059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: sycl
Choose a base branch
from

Conversation

JackAKirk
Copy link
Contributor

@JackAKirk JackAKirk commented Apr 16, 2025

Deprecates sycl_ext_oneapi_discard_queue_events in favour of the sycl_ext_oneapi_enqueue_functions extension.
In order to simplify/allow further simplifications to the handler/scheduler code the implementation of the discard_events queue property is also made a no-op immediately.

The main consequence of this is that users of discard_events will have to ensure they use the new submit_without_event / nd_launch etc APIs from https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_enqueue_functions.asciidoc
sycl::event is very lightweight already in the level_zero v2 adapter and discard_events already doesn't have a very big performance advantage for this case. Therefore the biggest consequence of this PR from a performance point of view is in the cuda/hip backends. Users of these backends need to be aware of the performance implications of making the discard_events no-op, and should ensure that they switch to using the sycl_ext_oneapi_enqueue_functions.

This PR leaves all other functionality working correctly.

Signed-off-by: JackAKirk <[email protected]>
Signed-off-by: JackAKirk <[email protected]>
@@ -9,8 +9,6 @@
__SYCL_DATA_LESS_PROP(property::queue, in_order, InOrder)
__SYCL_DATA_LESS_PROP(property::queue, enable_profiling, QueueEnableProfiling)

__SYCL_DATA_LESS_PROP(ext::oneapi::property::queue, discard_events,
Copy link
Contributor

Choose a reason for hiding this comment

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

So I think we'd like to still have the property exist to avoid a breaking change, but when it's seen, it's just ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK sure, I'll fix this. Thanks

Copy link
Contributor Author

@JackAKirk JackAKirk Apr 21, 2025

Choose a reason for hiding this comment

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

I've now kept the property but made it a no-op. I've updated the PR description accordingly.
I've kept all discard events tests other than those which test that the underlying sycl::event is nullptr, this this PR makes those tests obsolete.
I've also updated to docs to mark sycl_ext_oneapi_discard_queue_events deprecated.

@igchor
Copy link
Member

igchor commented Apr 16, 2025

@JackAKirk can you also cleanup event_impl? I still see some references to discard events there. Or is this still needed for some paths?

@JackAKirk
Copy link
Contributor Author

@JackAKirk can you also cleanup event_impl? I still see some references to discard events there. Or is this still needed for some paths?

When we use the submit_without_event path the handler_impl::MEventNeeded is still set false which leads to event_impl::isDiscarded being called which is currently used in queue::ext_oneapi_empty. So I think most of the "discard" in event_impl is still needed until events are fully removed from the submit_without_event path, which sounds like it is going to happen since apparently there is still a 1-2% overhead due to that.

But I think you might be right that I can still remove some of the event_impl "discard" stuff already here, since maybe the "discard" in event_impl::wait is only used with the discard_events property.
I'll check this. Thanks for the idea.

@JackAKirk
Copy link
Contributor Author

@JackAKirk can you also cleanup event_impl? I still see some references to discard events there. Or is this still needed for some paths?

I've removed one case that is definitely safe to remove. waitInternal could also potentially be cleaned up, although this depends on the way forward with host_task; in general I think that all of the internal discard event checks could be removed following on from #18018 . Apart from host_task the only other reason for keeping LastEvent is to keep this little potential optimization: https://github.com/intel/llvm/pull/18018/files#diff-f412476f167a41ca486ea41ab76bc7e861df86e8cf0542d4931b93947f41e6edL687

However as discussed this doesn't seem worth it.
You do still have a LastHostTaskEvent in the #18018 draft, so maybe it makes sense to wait until this PR is finalized/merged to finish the internal discard_event cleanup.
Could you get rid of LastHostTaskEvent completely, and instead submit a empty barrier to the native queue after the host_task is completed? This would guarantee that the host_task is synced with the in-order queue, and if users want to use multiple in order queues they can submit_with_event the host_task, and sync manually?
This would mean that sycl::queue::host_task matches exactly the semantics of cudaLaunchHostFunc(cudaStream_t, ...), see
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#host-functions-callbacks

- Make the prop no-op
- add back full testing initially
- deprecate discard_events extension

Signed-off-by: JackAKirk <[email protected]>
Signed-off-by: JackAKirk <[email protected]>
@igchor
Copy link
Member

igchor commented Apr 17, 2025

@JackAKirk can you also cleanup event_impl? I still see some references to discard events there. Or is this still needed for some paths?

I've removed one case that is definitely safe to remove. waitInternal could also potentially be cleaned up, although this depends on the way forward with host_task; in general I think that all of the internal discard event checks could be removed following on from #18018 . Apart from host_task the only other reason for keeping LastEvent is to keep this little potential optimization: https://github.com/intel/llvm/pull/18018/files#diff-f412476f167a41ca486ea41ab76bc7e861df86e8cf0542d4931b93947f41e6edL687

However as discussed this doesn't seem worth it. You do still have a LastHostTaskEvent in the #18018 draft, so maybe it makes sense to wait until this PR is finalized/merged to finish the internal discard_event cleanup. Could you get rid of LastHostTaskEvent completely, and instead submit a empty barrier to the native queue after the host_task is completed? This would guarantee that the host_task is synced with the in-order queue, and if users want to use multiple in order queues they can submit_with_event the host_task, and sync manually? This would mean that sycl::queue::host_task matches exactly the semantics of cudaLaunchHostFunc(cudaStream_t, ...), see https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#host-functions-callbacks

I believe @KseniyaTikhomirova is working on a similar approach (having host task signal an event that we can pass to next enqueue function). However, there are some issues related to memory residence with this approach so this will probably happen as a next step.

- Update docs
- Fix format

Signed-off-by: JackAKirk <[email protected]>
@JackAKirk JackAKirk changed the title [SYCL] Remove discard_events queue property [SYCL] Deprecate discard_events queue prop, make impl no-op Apr 21, 2025
@JackAKirk JackAKirk marked this pull request as ready for review April 21, 2025 12:59
@JackAKirk JackAKirk requested review from a team as code owners April 21, 2025 12:59
@JackAKirk JackAKirk requested a review from againull April 21, 2025 12:59
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

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

The title of the PR says that it deprecates the discard_events property, but I don't see anything in this PR that adds a deprecation warning. Was that done in a previous PR? The deprecation warning should direct people to use the sycl_ext_oneapi_enqueue_functions extension instead.

== Status

This extension has been deprecated. Although the interfaces defined in this
specification are still supported in {dpcpp}, we expect that they will be
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to define dpcpp as an asciidoc attribute at the top of the file.

extension: see link:../experimental/sycl_ext_oneapi_enqueue_functions.asciidoc[here].
*Shipping software products should stop using APIs defined in this
specification and use this alternative instead.*

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could add some words here noting that this extension no longer provides any benefit, and direct people to the enqueue function extension as an alternative.

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.

5 participants