Skip to content

Commit

Permalink
refactoring of the code moving graph shortcut management in submitMem…
Browse files Browse the repository at this point in the history
…OpHelper
  • Loading branch information
mfrancepillois committed Feb 7, 2024
1 parent 1945d8c commit d8d8db5
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ event queue_impl::memset(const std::shared_ptr<detail::queue_impl> &Self,
// Emit a begin/end scope for this call
PrepareNotify.scopedNotify((uint16_t)xpti::trace_point_type_t::task_begin);
#endif
// If we have a command graph set we need to capture the memset through normal
// queue submission rather than execute the memset directly.
if (MGraph.lock()) {
return submit(
[&](handler &CGH) {
CGH.depends_on(DepEvents);
CGH.memset(Ptr, Value, Count);
},
Self, {});
}

return submitMemOpHelper(
Self, DepEvents, [&](handler &CGH) { CGH.memset(Ptr, Value, Count); },
Expand Down Expand Up @@ -174,19 +164,14 @@ event queue_impl::memcpy(const std::shared_ptr<detail::queue_impl> &Self,
// Emit a begin/end scope for this call
PrepareNotify.scopedNotify((uint16_t)xpti::trace_point_type_t::task_begin);
#endif
// If we have a command graph set we need to capture the copy through normal
// queue submission rather than execute the copy directly.
auto HandlerFunc = [&](handler &CGH) { CGH.memcpy(Dest, Src, Count); };
if (MGraph.lock())
return submitWithHandler(Self, DepEvents, HandlerFunc);

if ((!Src || !Dest) && Count != 0) {
report(CodeLoc);
throw runtime_error("NULL pointer argument in memory copy operation.",
PI_ERROR_INVALID_VALUE);
}
return submitMemOpHelper(
Self, DepEvents, HandlerFunc,
Self, DepEvents, [&](handler &CGH) { CGH.memcpy(Dest, Src, Count); },
[](const auto &...Args) { MemoryManager::copy_usm(Args...); }, Src, Self,
Count, Dest);
}
Expand All @@ -195,14 +180,9 @@ event queue_impl::mem_advise(const std::shared_ptr<detail::queue_impl> &Self,
const void *Ptr, size_t Length,
pi_mem_advice Advice,
const std::vector<event> &DepEvents) {
// If we have a command graph set we need to capture the advise through normal
// queue submission.
auto HandlerFunc = [&](handler &CGH) { CGH.mem_advise(Ptr, Length, Advice); };
if (MGraph.lock())
return submitWithHandler(Self, DepEvents, HandlerFunc);

return submitMemOpHelper(
Self, DepEvents, HandlerFunc,
Self, DepEvents,
[&](handler &CGH) { CGH.mem_advise(Ptr, Length, Advice); },
[](const auto &...Args) { MemoryManager::advise_usm(Args...); }, Ptr,
Self, Length, Advice);
}
Expand Down Expand Up @@ -358,7 +338,10 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
const std::vector<event> &ExpandedDepEvents =
getExtendDependencyList(DepEvents, MutableDepEvents, Lock);

if (areEventsSafeForSchedulerBypass(ExpandedDepEvents, MContext)) {
// If we have a command graph set we need to capture the op through the
// handler rather than by-passing the scheduler.
if (areEventsSafeForSchedulerBypass(ExpandedDepEvents, MContext) &&
!MGraph.lock()) {
if (MHasDiscardEventsSupport) {
MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents),
/*PiEvent*/ nullptr, /*EventImplPtr*/ nullptr);
Expand Down

0 comments on commit d8d8db5

Please sign in to comment.