Graph builder class. More...
#include <detail/scheduler/scheduler.hpp>
Public Member Functions | |
GraphBuilder () | |
GraphBuildResult | addCG (std::unique_ptr< detail::CG > CommandGroup, const QueueImplPtr &Queue, std::vector< Command * > &ToEnqueue) |
Registers command group and adds it to the dependency graph. More... | |
Command * | addCGUpdateHost (std::unique_ptr< detail::CG > CommandGroup, const QueueImplPtr &HostQueue, std::vector< Command * > &ToEnqueue) |
Registers a command group that updates host memory to the latest state. More... | |
Command * | addCopyBack (Requirement *Req, std::vector< Command * > &ToEnqueue) |
Enqueues a command to update memory to the latest state. More... | |
Command * | addHostAccessor (Requirement *Req, std::vector< Command * > &ToEnqueue) |
Enqueues a command to create a host accessor. More... | |
void | optimize () |
[Provisional] Optimizes the whole graph. More... | |
void | optimize (const EventImplPtr &Event) |
[Provisional] Optimizes subgraph that consists of command associated with Event passed and its dependencies. More... | |
void | cleanupCommand (Command *Cmd, bool AllowUnsubmitted=false) |
void | rescheduleCommand (Command *Cmd, const QueueImplPtr &Queue) |
Reschedules the command passed using Queue provided. More... | |
MemObjRecord * | getMemObjRecord (SYCLMemObjI *MemObject) |
MemObjRecord * | getOrInsertMemObjRecord (const QueueImplPtr &Queue, const Requirement *Req, std::vector< Command * > &ToEnqueue) |
void | decrementLeafCountersForRecord (MemObjRecord *Record) |
Decrements leaf counters for all leaves of the record. More... | |
void | cleanupCommandsForRecord (MemObjRecord *Record) |
Removes commands that use the given MemObjRecord from the graph. More... | |
void | removeRecordForMemObj (SYCLMemObjI *MemObject) |
Removes the MemObjRecord for the memory object passed. More... | |
void | addNodeToLeaves (MemObjRecord *Record, Command *Cmd, access::mode AccessMode, std::vector< Command * > &ToEnqueue) |
Adds new command to leaves if needed. More... | |
void | updateLeaves (const std::set< Command * > &Cmds, MemObjRecord *Record, access::mode AccessMode, std::vector< Command * > &ToCleanUp) |
Removes commands from leaves. More... | |
Command * | connectDepEvent (Command *const Cmd, const EventImplPtr &DepEvent, const DepDesc &Dep, std::vector< Command * > &ToCleanUp) |
Perform connection of events in multiple contexts. More... | |
void | startFusion (QueueImplPtr Queue) |
void | cancelFusion (QueueImplPtr Queue, std::vector< Command * > &ToEnqueue) |
EventImplPtr | completeFusion (QueueImplPtr Queue, std::vector< Command * > &ToEnqueue, const property_list &) |
bool | isInFusionMode (QueueIdT queue) |
Public Attributes | |
std::vector< SYCLMemObjI * > | MMemObjs |
Protected Member Functions | |
DepDesc | findDepForRecord (Command *Cmd, MemObjRecord *Record) |
Finds a command dependency corresponding to the record. More... | |
AllocaCommandBase * | findAllocaForReq (MemObjRecord *Record, const Requirement *Req, const ContextImplPtr &Context, bool AllowConst=true) |
Searches for suitable alloca in memory record. More... | |
Friends | |
class | Command |
class | ::MockScheduler |
Graph builder class.
The graph builder provides means to change an existing graph (e.g. add or remove edges/nodes).
Definition at line 522 of file scheduler.hpp.
sycl::_V1::detail::Scheduler::GraphBuilder::GraphBuilder | ( | ) |
Definition at line 95 of file graph_builder.cpp.
Scheduler::GraphBuildResult sycl::_V1::detail::Scheduler::GraphBuilder::addCG | ( | std::unique_ptr< detail::CG > | CommandGroup, |
const QueueImplPtr & | Queue, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Registers command group and adds it to the dependency graph.
Definition at line 932 of file graph_builder.cpp.
References sycl::_V1::detail::isInteropHostTask().
Command * sycl::_V1::detail::Scheduler::GraphBuilder::addCGUpdateHost | ( | std::unique_ptr< detail::CG > | CommandGroup, |
const QueueImplPtr & | HostQueue, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Registers a command group that updates host memory to the latest state.
Definition at line 557 of file graph_builder.cpp.
Command * sycl::_V1::detail::Scheduler::GraphBuilder::addCopyBack | ( | Requirement * | Req, |
std::vector< Command * > & | ToEnqueue | ||
) |
Enqueues a command to update memory to the latest state.
Req | is a requirement, that describes memory object. |
Definition at line 475 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::Command::getQueue(), sycl::_V1::detail::AllocaCommandBase::getRequirement(), sycl::_V1::detail::MemCpyCommandHost::getRequirement(), sycl::_V1::detail::AccessorImplHost::MAccessMode, sycl::_V1::detail::MemObjRecord::MCurContext, sycl::_V1::detail::AccessorImplHost::MData, sycl::_V1::detail::MemObjRecord::MMemModified, and sycl::_V1::detail::AccessorImplHost::MSYCLMemObj.
Command * sycl::_V1::detail::Scheduler::GraphBuilder::addHostAccessor | ( | Requirement * | Req, |
std::vector< Command * > & | ToEnqueue | ||
) |
Enqueues a command to create a host accessor.
Req | points to memory being accessed. |
Definition at line 521 of file graph_builder.cpp.
References sycl::_V1::detail::Command::getQueue(), sycl::_V1::detail::isAccessModeAllowed(), sycl::_V1::detail::AccessorImplHost::MAccessMode, sycl::_V1::detail::AccessorImplHost::MBlockedCmd, sycl::_V1::detail::MemObjRecord::MCurContext, sycl::_V1::detail::MemObjRecord::MHostAccess, and sycl::_V1::detail::sameCtx().
void sycl::_V1::detail::Scheduler::GraphBuilder::addNodeToLeaves | ( | MemObjRecord * | Record, |
Command * | Cmd, | ||
access::mode | AccessMode, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Adds new command to leaves if needed.
Definition at line 272 of file graph_builder.cpp.
References sycl::_V1::AccessMode, sycl::_V1::detail::Command::MLeafCounter, sycl::_V1::detail::MemObjRecord::MReadLeaves, and sycl::_V1::detail::MemObjRecord::MWriteLeaves.
void sycl::_V1::detail::Scheduler::GraphBuilder::cancelFusion | ( | QueueImplPtr | Queue, |
std::vector< Command * > & | ToEnqueue | ||
) |
Definition at line 1406 of file graph_builder.cpp.
void sycl::_V1::detail::Scheduler::GraphBuilder::cleanupCommand | ( | Command * | Cmd, |
bool | AllowUnsubmitted = false |
||
) |
Definition at line 1219 of file graph_builder.cpp.
References std::cerr, sycl::_V1::detail::Command::getEvent(), sycl::_V1::detail::Command::getType(), sycl::_V1::detail::Command::isSuccessfullyEnqueued(), sycl::_V1::detail::DepDesc::MAllocaCmd, sycl::_V1::detail::DepDesc::MDepCommand, sycl::_V1::detail::Command::MDeps, sycl::_V1::detail::Command::MLeafCounter, and sycl::_V1::detail::Command::MUsers.
void sycl::_V1::detail::Scheduler::GraphBuilder::cleanupCommandsForRecord | ( | MemObjRecord * | Record | ) |
Removes commands that use the given MemObjRecord from the graph.
Definition at line 1130 of file graph_builder.cpp.
References sycl::_V1::detail::Command::getType(), sycl::_V1::detail::MemObjRecord::MAllocaCommands, sycl::_V1::detail::markNodeAsVisited(), sycl::_V1::detail::DepDesc::MDepCommand, sycl::_V1::detail::Command::MDeps, sycl::_V1::detail::AllocaCommandBase::MLinkedAllocaCmd, sycl::_V1::detail::Command::MMarks, sycl::_V1::detail::Command::Marks::MToBeDeleted, sycl::_V1::detail::Command::MUsers, and sycl::_V1::detail::Command::Marks::MVisited.
EventImplPtr sycl::_V1::detail::Scheduler::GraphBuilder::completeFusion | ( | QueueImplPtr | Queue, |
std::vector< Command * > & | ToEnqueue, | ||
const property_list & | PropList | ||
) |
Definition at line 1493 of file graph_builder.cpp.
References any_of(), sycl::_V1::detail::Command::getPreparedDepsEvents(), sycl::_V1::detail::Command::getPreparedHostDepsEvents(), sycl::_V1::detail::Command::getType(), and sycl::_V1::make_error_code().
Command * sycl::_V1::detail::Scheduler::GraphBuilder::connectDepEvent | ( | Command *const | Cmd, |
const EventImplPtr & | DepEvent, | ||
const DepDesc & | Dep, | ||
std::vector< Command * > & | ToCleanUp | ||
) |
Perform connection of events in multiple contexts.
Cmd | dependant command |
DepEvent | event to depend on |
Dep | optional DepDesc to perform connection properly |
ToCleanUp | container for commands that can be cleaned up due to their removal from leaves |
Optionality of Dep is set by Dep.MDepCommand equal to nullptr.
Definition at line 1296 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::Command::addUser(), sycl::_V1::detail::Command::getEvent(), sycl::_V1::detail::Command::getWorkerContext(), sycl::_V1::detail::DepDesc::MDepCommand, and sycl::_V1::detail::DepDesc::MDepRequirement.
Referenced by sycl::_V1::detail::Command::processDepEvent().
void sycl::_V1::detail::Scheduler::GraphBuilder::decrementLeafCountersForRecord | ( | MemObjRecord * | Record | ) |
Decrements leaf counters for all leaves of the record.
Definition at line 1116 of file graph_builder.cpp.
References sycl::_V1::detail::Command::MLeafCounter, sycl::_V1::detail::MemObjRecord::MReadLeaves, sycl::_V1::detail::MemObjRecord::MWriteLeaves, and sycl::_V1::detail::Command::readyForCleanup().
|
protected |
Searches for suitable alloca in memory record.
Definition at line 647 of file graph_builder.cpp.
References sycl::_V1::detail::Command::getQueue(), sycl::_V1::detail::AllocaCommandBase::getRequirement(), sycl::_V1::detail::SYCLMemObjI::getSizeInBytes(), sycl::_V1::detail::Command::getType(), sycl::_V1::detail::IsSuitableSubReq(), sycl::_V1::detail::MemObjRecord::MAllocaCommands, sycl::_V1::detail::AllocaCommandBase::MIsConst, sycl::_V1::detail::AccessorImplHost::MOffsetInBytes, sycl::_V1::detail::AccessorImplHost::MSYCLMemObj, and sycl::_V1::detail::sameCtx().
|
protected |
Finds a command dependency corresponding to the record.
Definition at line 634 of file graph_builder.cpp.
References sycl::_V1::detail::DepDesc::MDepRequirement, sycl::_V1::detail::Command::MDeps, and sycl::_V1::detail::AccessorImplHost::MSYCLMemObj.
MemObjRecord * sycl::_V1::detail::Scheduler::GraphBuilder::getMemObjRecord | ( | SYCLMemObjI * | MemObject | ) |
Definition at line 191 of file graph_builder.cpp.
References sycl::_V1::detail::SYCLMemObjI::MRecord.
MemObjRecord * sycl::_V1::detail::Scheduler::GraphBuilder::getOrInsertMemObjRecord | ( | const QueueImplPtr & | Queue, |
const Requirement * | Req, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Definition at line 195 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::SYCLMemObjI::getInteropContext(), sycl::_V1::detail::getSyclObjImpl(), sycl::_V1::detail::DepDesc::MDepCommand, sycl::_V1::detail::SYCLMemObjI::MRecord, and sycl::_V1::detail::AccessorImplHost::MSYCLMemObj.
bool sycl::_V1::detail::Scheduler::GraphBuilder::isInFusionMode | ( | QueueIdT | queue | ) |
Definition at line 1626 of file graph_builder.cpp.
void sycl::_V1::detail::Scheduler::GraphBuilder::optimize | ( | ) |
[Provisional] Optimizes the whole graph.
void sycl::_V1::detail::Scheduler::GraphBuilder::optimize | ( | const EventImplPtr & | Event | ) |
[Provisional] Optimizes subgraph that consists of command associated with Event passed and its dependencies.
void sycl::_V1::detail::Scheduler::GraphBuilder::removeRecordForMemObj | ( | SYCLMemObjI * | MemObject | ) |
Removes the MemObjRecord for the memory object passed.
Definition at line 1274 of file graph_builder.cpp.
References sycl::_V1::detail::SYCLMemObjI::MRecord.
void sycl::_V1::detail::Scheduler::GraphBuilder::rescheduleCommand | ( | Command * | Cmd, |
const QueueImplPtr & | Queue | ||
) |
Reschedules the command passed using Queue provided.
This can lead to rescheduling of all dependent commands. This can be used when the user provides a "secondary" queue to the submit method which may be used when the command fails to enqueue/execute in the primary queue.
void sycl::_V1::detail::Scheduler::GraphBuilder::startFusion | ( | QueueImplPtr | Queue | ) |
Definition at line 1352 of file graph_builder.cpp.
References sycl::_V1::make_error_code().
void sycl::_V1::detail::Scheduler::GraphBuilder::updateLeaves | ( | const std::set< Command * > & | Cmds, |
MemObjRecord * | Record, | ||
access::mode | AccessMode, | ||
std::vector< Command * > & | ToCleanUp | ||
) |
Removes commands from leaves.
Definition at line 253 of file graph_builder.cpp.
References sycl::_V1::AccessMode, sycl::_V1::detail::MemObjRecord::MReadLeaves, sycl::_V1::detail::MemObjRecord::MWriteLeaves, and sycl::_V1::detail::LeavesCollection::remove().
|
friend |
Definition at line 683 of file scheduler.hpp.
|
friend |
Definition at line 680 of file scheduler.hpp.
std::vector<SYCLMemObjI *> sycl::_V1::detail::Scheduler::GraphBuilder::MMemObjs |
Definition at line 625 of file scheduler.hpp.