Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a no-handler barrier submission path for ext_oneapi_submit_barrier to optimize barrier operations by bypassing the handler layer when command graphs are not involved.

Changes:

  • Modified ext_oneapi_submit_barrier to use a direct submission path when no command graph is present
  • Added submit_barrier_direct_impl and submit_barrier_direct_with_event methods to queue_impl for direct UR barrier submission
  • Updated test expectations to reflect the new behavior where non-empty event lists now trigger UR calls

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
sycl/source/queue.cpp Routes barrier submissions to direct path when command graphs aren't used
sycl/source/detail/queue_impl.hpp Declares new direct barrier submission methods
sycl/source/detail/queue_impl.cpp Implements direct barrier submission with UR event handling and dependency management
sycl/unittests/Extensions/ExtOneapiBarrierOpt.cpp Updates test to verify UR calls are made for non-empty event dependencies

@uditagarwal97 uditagarwal97 changed the title [SYCL] Add no-handler barrier submission path for ext_oneapi_submit_barrier [SYCL] Add no-handler barrier submission path for ext_oneapi_submit_barrier Jan 22, 2026
@uditagarwal97 uditagarwal97 marked this pull request as ready for review January 22, 2026 19:52
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner January 22, 2026 19:52
Comment on lines 486 to 524
// This is equivalent to handler::depends_on() and is required
// to handle events associated with graphs correctly.
if (Event->isHost()) {
detail::registerEventDependency(
Event, CGData.MEvents, this, this->getContextImpl(),
this->getDeviceImpl(), getCommandGraph().get(),
CGType::BarrierWaitlist);
continue;
}

// Throwaway events created with empty constructor will not have a context
// (which is set lazily) calling getContextImpl() would set that
// context, which we wish to avoid as it is expensive.
// Skip NOP events also.
if (Event->isDefaultConstructed() || Event->isNOP())
continue;

// If command has not been enqueued then we have to enqueue it.
// It may happen if async enqueue in a host task is involved.
// Interoperability events are special cases and they are not enqueued, as
// they don't have an associated queue and command.
if (!Event->isInterop() && !Event->isEnqueued()) {
if (!Event->getCommand() || !Event->getCommand()->producesPiEvent())
continue;
std::vector<Command *> AuxCmds;
Scheduler::getInstance().enqueueCommandForCG(*Event, AuxCmds, BLOCKING);
}

// Do not add redundant event dependencies for in-order queues.
// At this stage dependency is definitely UR task and need to check if
// current one is a host task. In this case we should not skip UR event
// due to different sync mechanisms for different task types on in-order
// queue. If the resulting event is supposed to have a specific event
// mode, redundant events may still differ from the resulting event, so
// they are kept.
if (Event->getWorkerQueue().get() == this && this->isInOrder())
continue;

RetUrEvents.push_back(Event->getHandle());
Copy link
Contributor

Choose a reason for hiding this comment

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

This duplicates the code from Command::getUrEventsBlocking. Can we move it out into a separate function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the duplication is still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function wasn't really a duplicate of Command::getUrEventsBlocking since we were also registering host event dependencies in this function. However, I have now split that part out and re-used Command::getUrEventsBlocking, let me know if that looks better.

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.

4 participants