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, sycl::detail::pi::PiExtCommandBuffer CommandBuffer=nullptr, const std::vector< sycl::detail::pi::PiExtSyncPoint > &Dependencies={}) |
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 | cleanUpCmdFusion (sycl::detail::queue_impl *Queue) |
Clean up the internal fusion commands held for the given queue. More... | |
void | cancelFusion (QueueImplPtr Queue, std::vector< Command * > &ToEnqueue) |
EventImplPtr | completeFusion (QueueImplPtr Queue, std::vector< Command * > &ToEnqueue, const property_list &) |
bool | isInFusionMode (QueueIdT queue) |
Command * | addCommandGraphUpdate (ext::oneapi::experimental::detail::exec_graph_impl *Graph, std::vector< std::shared_ptr< ext::oneapi::experimental::detail::node_impl >> Nodes, const QueueImplPtr &Queue, std::vector< Requirement * > Requirements, std::vector< detail::EventImplPtr > &Events, std::vector< Command * > &ToEnqueue) |
Adds a command buffer update operation to the execution graph. More... | |
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 588 of file scheduler.hpp.
sycl::_V1::detail::Scheduler::GraphBuilder::GraphBuilder | ( | ) |
Definition at line 97 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, | ||
sycl::detail::pi::PiExtCommandBuffer | CommandBuffer = nullptr , |
||
const std::vector< sycl::detail::pi::PiExtSyncPoint > & | Dependencies = {} |
||
) |
Registers command group and adds it to the dependency graph.
CommandBuffer | Optional command buffer to enqueue to instead of directly to the queue. |
Dependencies | Optional list of dependency sync points when enqueuing to a command buffer. |
Definition at line 940 of file graph_builder.cpp.
References sycl::_V1::detail::Scheduler::cancelFusion(), sycl::_V1::detail::Scheduler::isInFusionMode(), and sycl::_V1::detail::isInteropHostTask().
Referenced by sycl::_V1::detail::Scheduler::addCG().
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 570 of file graph_builder.cpp.
Referenced by sycl::_V1::detail::Scheduler::addCG().
Command * sycl::_V1::detail::Scheduler::GraphBuilder::addCommandGraphUpdate | ( | ext::oneapi::experimental::detail::exec_graph_impl * | Graph, |
std::vector< std::shared_ptr< ext::oneapi::experimental::detail::node_impl >> | Nodes, | ||
const QueueImplPtr & | Queue, | ||
std::vector< Requirement * > | Requirements, | ||
std::vector< detail::EventImplPtr > & | Events, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Adds a command buffer update operation to the execution graph.
This is required when buffers/accessors are updated to ensure that the memory has been allocated when updating.
Graph | The executable graph to be updated. |
Nodes | The list of Nodes which are to be updated in the graph. |
Requirements | List of accessor requirements for this update. |
Events | List of events that this operation depends on. |
ToEnqueue | List of commands which need to be enqueued. |
Definition at line 1683 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::combineAccessModesOfReqs(), sycl::_V1::detail::AccessorImplHost::MAccessMode, sycl::_V1::detail::MemObjRecord::MCurContext, sycl::_V1::detail::Command::MDeps, sycl::_V1::detail::AccessorImplHost::MSYCLMemObj, and sycl::_V1::detail::sameCtx().
Referenced by sycl::_V1::detail::Scheduler::addCommandGraphUpdate().
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 477 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::Scheduler::getDefaultHostQueue(), sycl::_V1::detail::Scheduler::getInstance(), sycl::_V1::detail::Scheduler::getMemObjRecord(), 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.
Referenced by sycl::_V1::detail::Scheduler::addCopyBack().
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 523 of file graph_builder.cpp.
References sycl::_V1::detail::Scheduler::getDefaultHostQueue(), sycl::_V1::detail::Scheduler::getInstance(), sycl::_V1::detail::Command::getQueue(), sycl::_V1::detail::SYCLMemObjT::handleWriteAccessorCreation(), sycl::_V1::detail::Command::HostAccessor, sycl::_V1::detail::isAccessModeAllowed(), sycl::_V1::detail::AccessorImplHost::MAccessMode, sycl::_V1::detail::AccessorImplHost::MBlockedCmd, sycl::_V1::detail::MemObjRecord::MCurContext, sycl::_V1::detail::MemObjRecord::MHostAccess, sycl::_V1::detail::AccessorImplHost::MIsSubBuffer, sycl::_V1::detail::AccessorImplHost::MSYCLMemObj, and sycl::_V1::detail::sameCtx().
Referenced by sycl::_V1::detail::Scheduler::addHostAccessor().
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 274 of file graph_builder.cpp.
References sycl::_V1::AccessMode, sycl::_V1::detail::Command::MLeafCounter, sycl::_V1::detail::MemObjRecord::MReadLeaves, sycl::_V1::detail::MemObjRecord::MWriteLeaves, and sycl::_V1::access::read.
void sycl::_V1::detail::Scheduler::GraphBuilder::cancelFusion | ( | QueueImplPtr | Queue, |
std::vector< Command * > & | ToEnqueue | ||
) |
Definition at line 1445 of file graph_builder.cpp.
References sycl::_V1::detail::KernelFusionCommand::CANCELLED, and sycl::_V1::detail::Scheduler::isInFusionMode().
Referenced by sycl::_V1::detail::Scheduler::cancelFusion().
void sycl::_V1::detail::Scheduler::GraphBuilder::cleanUpCmdFusion | ( | sycl::detail::queue_impl * | Queue | ) |
Clean up the internal fusion commands held for the given queue.
Queue | the queue for which to remove the fusion commands. |
Definition at line 1391 of file graph_builder.cpp.
References sycl::_V1::detail::KernelFusionCommand::DELETED, and sycl::_V1::detail::Scheduler::isInFusionMode().
Referenced by sycl::_V1::detail::Scheduler::cleanUpCmdFusion().
void sycl::_V1::detail::Scheduler::GraphBuilder::cleanupCommand | ( | Command * | Cmd, |
bool | AllowUnsubmitted = false |
||
) |
Definition at line 1252 of file graph_builder.cpp.
References sycl::_V1::detail::Command::ALLOCA, sycl::_V1::detail::Command::ALLOCA_SUB_BUF, std::cerr, sycl::_V1::detail::Command::FUSION, 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, sycl::_V1::detail::Command::MUsers, and sycl::_V1::detail::Command::RELEASE.
Referenced by sycl::_V1::detail::Scheduler::cleanupCommands().
void sycl::_V1::detail::Scheduler::GraphBuilder::cleanupCommandsForRecord | ( | MemObjRecord * | Record | ) |
Removes commands that use the given MemObjRecord from the graph.
Definition at line 1163 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.
Referenced by sycl::_V1::detail::Scheduler::removeMemoryObject().
EventImplPtr sycl::_V1::detail::Scheduler::GraphBuilder::completeFusion | ( | QueueImplPtr | Queue, |
std::vector< Command * > & | ToEnqueue, | ||
const property_list & | PropList | ||
) |
Definition at line 1532 of file graph_builder.cpp.
References any_of(), sycl::_V1::detail::Scheduler::cancelFusion(), sycl::_V1::detail::jit_compiler::fuseKernels(), sycl::_V1::detail::jit_compiler::get_instance(), sycl::_V1::detail::Command::getPreparedDepsEvents(), sycl::_V1::detail::Command::getPreparedHostDepsEvents(), sycl::_V1::detail::Command::getType(), sycl::_V1::if(), sycl::_V1::detail::Scheduler::isInFusionMode(), and sycl::_V1::detail::Command::RUN_CG.
Referenced by sycl::_V1::detail::Scheduler::completeFusion().
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 1329 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::Command::addUser(), sycl::_V1::detail::CG::CodeplayHostTask, sycl::_V1::detail::Scheduler::getDefaultHostQueue(), sycl::_V1::detail::Command::getEvent(), sycl::_V1::detail::Scheduler::getInstance(), 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 1149 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().
Referenced by sycl::_V1::detail::Scheduler::removeMemoryObject().
|
protected |
Searches for suitable alloca in memory record.
Definition at line 660 of file graph_builder.cpp.
References sycl::_V1::detail::Command::getQueue(), sycl::_V1::detail::AllocaCommandBase::getRequirement(), sycl::_V1::detail::Command::getType(), sycl::_V1::detail::IsSuitableSubReq(), sycl::_V1::detail::AccessorImplHost::MAccessRange, sycl::_V1::detail::MemObjRecord::MAllocaCommands, sycl::_V1::detail::AllocaCommandBase::MIsConst, sycl::_V1::detail::AccessorImplHost::MOffsetInBytes, and sycl::_V1::detail::sameCtx().
|
protected |
Finds a command dependency corresponding to the record.
Definition at line 647 of file graph_builder.cpp.
References sycl::_V1::detail::Scheduler::getMemObjRecord(), 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 193 of file graph_builder.cpp.
References sycl::_V1::detail::SYCLMemObjI::MRecord.
Referenced by sycl::_V1::detail::Scheduler::cleanupDeferredMemObjects(), and sycl::_V1::detail::Scheduler::removeMemoryObject().
MemObjRecord * sycl::_V1::detail::Scheduler::GraphBuilder::getOrInsertMemObjRecord | ( | const QueueImplPtr & | Queue, |
const Requirement * | Req, | ||
std::vector< Command * > & | ToEnqueue | ||
) |
Definition at line 197 of file graph_builder.cpp.
References sycl::_V1::detail::Command::addDep(), sycl::_V1::detail::SYCLMemObjI::getInteropContext(), sycl::_V1::detail::Scheduler::getMemObjRecord(), 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 1675 of file graph_builder.cpp.
Referenced by sycl::_V1::detail::Scheduler::isInFusionMode().
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 1307 of file graph_builder.cpp.
References sycl::_V1::detail::SYCLMemObjI::MRecord.
Referenced by sycl::_V1::detail::Scheduler::removeMemoryObject().
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 1385 of file graph_builder.cpp.
References sycl::_V1::detail::Scheduler::cleanUpCmdFusion().
Referenced by sycl::_V1::detail::Scheduler::startFusion().
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 255 of file graph_builder.cpp.
References sycl::_V1::AccessMode, sycl::_V1::detail::MemObjRecord::MReadLeaves, sycl::_V1::detail::MemObjRecord::MWriteLeaves, sycl::_V1::access::read, and sycl::_V1::detail::LeavesCollection::remove().
|
friend |
Definition at line 776 of file scheduler.hpp.
|
friend |
Definition at line 773 of file scheduler.hpp.
std::vector<SYCLMemObjI *> sycl::_V1::detail::Scheduler::GraphBuilder::MMemObjs |
Definition at line 718 of file scheduler.hpp.