Skip to content

[SYCL] Avoid duplication in submit_impl #18430

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 1 commit into
base: sycl
Choose a base branch
from
Open
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
55 changes: 3 additions & 52 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,63 +370,14 @@ event queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
event queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
const std::shared_ptr<queue_impl> &Self,
const std::shared_ptr<queue_impl> &PrimaryQueue,
const std::shared_ptr<queue_impl> &,
const std::shared_ptr<queue_impl> &SecondaryQueue,
bool CallerNeedsEvent,
const detail::code_location &Loc,
bool IsTopCodeLoc,
const SubmissionInfo &SubmitInfo) {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
detail::handler_impl HandlerImplVal(PrimaryQueue.get(), CallerNeedsEvent);
detail::handler_impl *HandlerImpl = &HandlerImplVal;
handler Handler(HandlerImpl, Self);
#else
handler Handler(Self, CallerNeedsEvent);
auto &HandlerImpl = detail::getSyclObjImpl(Handler);
#endif

#if XPTI_ENABLE_INSTRUMENTATION
if (xptiTraceEnabled()) {
Handler.saveCodeLoc(Loc, IsTopCodeLoc);
}
#endif

{
NestedCallsTracker tracker;
CGF(Handler);
}

// Scheduler will later omit events, that are not required to execute tasks.
// Host and interop tasks, however, are not submitted to low-level runtimes
// and require separate dependency management.
const CGType Type = HandlerImpl->MCGType;
std::vector<StreamImplPtr> Streams;
if (Type == CGType::Kernel)
Streams = std::move(Handler.MStreamStorage);

HandlerImpl->MEventMode = SubmitInfo.EventMode();

auto Event = finalizeHandler(Handler, SubmitInfo.PostProcessorFunc());

addEvent(Event);

const auto &EventImpl = detail::getSyclObjImpl(Event);
for (auto &Stream : Streams) {
// We don't want stream flushing to be blocking operation that is why submit
// a host task to print stream buffer. It will fire up as soon as the kernel
// finishes execution.
auto L = [&](handler &ServiceCGH) {
Stream->generateFlushCommand(ServiceCGH);
};
detail::type_erased_cgfo_ty CGF{L};
event FlushEvent =
submit_impl(CGF, Self, PrimaryQueue, SecondaryQueue,
/*CallerNeedsEvent*/ true, Loc, IsTopCodeLoc, {});
EventImpl->attachEventToCompleteWeak(detail::getSyclObjImpl(FlushEvent));
registerStreamServiceEvent(detail::getSyclObjImpl(FlushEvent));
}

return Event;
return submit_impl(CGF, Self, SecondaryQueue.get(), CallerNeedsEvent, Loc,
IsTopCodeLoc, SubmitInfo);
}
#endif

Expand Down