Skip to content
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

[SYCL][NFC] Reduce ambiguity between discarding SYCL and PI events #12547

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
getExtendDependencyList(DepEvents, MutableDepEvents, Lock);

if (areEventsSafeForSchedulerBypass(ExpandedDepEvents, MContext)) {
if (MHasDiscardEventsSupport) {
if (MSupportsDiscardingPiEvents) {
MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents),
/*PiEvent*/ nullptr, /*EventImplPtr*/ nullptr);
return createDiscardedEvent();
Expand Down
27 changes: 14 additions & 13 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class queue_impl {
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()),
MHasDiscardEventsSupport(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)),
MSupportsDiscardingPiEvents(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)),
MQueueID{
MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} {
if (has_property<property::queue::enable_profiling>()) {
Expand Down Expand Up @@ -288,8 +288,8 @@ class queue_impl {
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()),
MHasDiscardEventsSupport(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)),
MSupportsDiscardingPiEvents(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)),
MQueueID{
MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} {
queue_impl_interop(PiQueue);
Expand All @@ -310,8 +310,8 @@ class queue_impl {
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()),
MHasDiscardEventsSupport(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)) {
MSupportsDiscardingPiEvents(MDiscardEvents &&
(MHostQueue ? true : MIsInorder)) {
queue_impl_interop(PiQueue);
}

Expand Down Expand Up @@ -367,7 +367,9 @@ class queue_impl {
bool is_host() const { return MHostQueue; }

/// \return true if this queue has discard_events support.
bool has_discard_events_support() const { return MHasDiscardEventsSupport; }
bool supportsDiscardingPiEvents() const {
return MSupportsDiscardingPiEvents;
}

bool isInOrder() const { return MIsInorder; }

Expand Down Expand Up @@ -959,12 +961,11 @@ class queue_impl {
const bool MIsProfilingEnabled;

protected:
// This flag says if we can discard events based on a queue "setup" which will
// be common for all operations submitted to the queue. This is a must
// condition for discarding, but even if it's true, in some cases, we won't be
// able to discard events, because the final decision is made right before the
// operation itself.
const bool MHasDiscardEventsSupport;
// Indicates whether the queue supports discarding PI events for tasks
// submitted to it. This condition is necessary but not sufficient, PI events
// should be discarded only if they also don't represent potential implicit
// dependencies for future tasks in other queues.
const bool MSupportsDiscardingPiEvents;

// Command graph which is associated with this queue for the purposes of
// recording commands to it.
Expand Down
10 changes: 5 additions & 5 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,7 @@ pi_int32 ExecCGCommand::enqueueImpCommandBuffer() {
}

sycl::detail::pi::PiEvent *Event =
(MQueue->has_discard_events_support() &&
(MQueue->supportsDiscardingPiEvents() &&
MCommandGroup->getRequirements().size() == 0)
? nullptr
: &MEvent->getHandleRef();
Expand Down Expand Up @@ -2825,11 +2825,11 @@ pi_int32 ExecCGCommand::enqueueImpQueue() {
auto RawEvents = getPiEvents(EventImpls);
flushCrossQueueDeps(EventImpls, getWorkerQueue());

bool DiscardEvent = (MQueue->has_discard_events_support() &&
MCommandGroup->getRequirements().size() == 0);
bool DiscardPiEvent = (MQueue->supportsDiscardingPiEvents() &&
MCommandGroup->getRequirements().size() == 0);
sycl::detail::pi::PiEvent *Event =
DiscardEvent ? nullptr : &MEvent->getHandleRef();
detail::EventImplPtr EventImpl = DiscardEvent ? nullptr : MEvent;
DiscardPiEvent ? nullptr : &MEvent->getHandleRef();
detail::EventImplPtr EventImpl = DiscardPiEvent ? nullptr : MEvent;

switch (MCommandGroup->getType()) {

Expand Down
2 changes: 1 addition & 1 deletion sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ event handler::finalize() {
};

bool DiscardEvent = false;
if (MQueue->has_discard_events_support()) {
if (MQueue->supportsDiscardingPiEvents()) {
// Kernel only uses assert if it's non interop one
bool KernelUsesAssert =
!(MKernel && MKernel->isInterop()) &&
Expand Down
Loading