DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::detail::Scheduler::GraphBuilder Class Reference

Graph builder class. More...

#include <detail/scheduler/scheduler.hpp>

Collaboration diagram for sycl::_V1::detail::Scheduler::GraphBuilder:

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...
 
CommandaddCGUpdateHost (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...
 
CommandaddCopyBack (Requirement *Req, std::vector< Command * > &ToEnqueue)
 Enqueues a command to update memory to the latest state. More...
 
CommandaddHostAccessor (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...
 
MemObjRecordgetMemObjRecord (SYCLMemObjI *MemObject)
 
MemObjRecordgetOrInsertMemObjRecord (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...
 
CommandconnectDepEvent (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)
 
CommandaddCommandGraphUpdate (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...
 
AllocaCommandBasefindAllocaForReq (MemObjRecord *Record, const Requirement *Req, const ContextImplPtr &Context, bool AllowConst=true)
 Searches for suitable alloca in memory record. More...
 

Friends

class Command
 
class ::MockScheduler
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GraphBuilder()

sycl::_V1::detail::Scheduler::GraphBuilder::GraphBuilder ( )

Definition at line 97 of file graph_builder.cpp.

Member Function Documentation

◆ addCG()

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.

See also
queue::submit, Scheduler::addCG
Parameters
CommandBufferOptional command buffer to enqueue to instead of directly to the queue.
DependenciesOptional list of dependency sync points when enqueuing to a command buffer.
Returns
a command that represents command group execution and a bool indicating whether this command should be enqueued to the graph processor right away or not.

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().

◆ addCGUpdateHost()

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.

Returns
a command that represents command group execution.

Definition at line 570 of file graph_builder.cpp.

Referenced by sycl::_V1::detail::Scheduler::addCG().

◆ addCommandGraphUpdate()

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.

Parameters
GraphThe executable graph to be updated.
NodesThe list of Nodes which are to be updated in the graph.
RequirementsList of accessor requirements for this update.
EventsList of events that this operation depends on.
ToEnqueueList 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().

◆ addCopyBack()

◆ addHostAccessor()

◆ addNodeToLeaves()

void sycl::_V1::detail::Scheduler::GraphBuilder::addNodeToLeaves ( MemObjRecord Record,
Command Cmd,
access::mode  AccessMode,
std::vector< Command * > &  ToEnqueue 
)

◆ cancelFusion()

void sycl::_V1::detail::Scheduler::GraphBuilder::cancelFusion ( QueueImplPtr  Queue,
std::vector< Command * > &  ToEnqueue 
)

◆ cleanUpCmdFusion()

void sycl::_V1::detail::Scheduler::GraphBuilder::cleanUpCmdFusion ( sycl::detail::queue_impl *  Queue)

Clean up the internal fusion commands held for the given queue.

Parameters
Queuethe 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().

◆ cleanupCommand()

◆ cleanupCommandsForRecord()

◆ completeFusion()

◆ connectDepEvent()

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.

Parameters
Cmddependant command
DepEventevent to depend on
Depoptional DepDesc to perform connection properly
ToCleanUpcontainer for commands that can be cleaned up due to their removal from leaves
Returns
the connecting command which is to be enqueued

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().

◆ decrementLeafCountersForRecord()

void sycl::_V1::detail::Scheduler::GraphBuilder::decrementLeafCountersForRecord ( MemObjRecord Record)

◆ findAllocaForReq()

◆ findDepForRecord()

DepDesc sycl::_V1::detail::Scheduler::GraphBuilder::findDepForRecord ( Command Cmd,
MemObjRecord Record 
)
protected

◆ getMemObjRecord()

MemObjRecord * sycl::_V1::detail::Scheduler::GraphBuilder::getMemObjRecord ( SYCLMemObjI MemObject)
Returns
a pointer to the corresponding memory object record for the SYCL memory object provided, or nullptr if it does not exist.

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().

◆ getOrInsertMemObjRecord()

MemObjRecord * sycl::_V1::detail::Scheduler::GraphBuilder::getOrInsertMemObjRecord ( const QueueImplPtr Queue,
const Requirement Req,
std::vector< Command * > &  ToEnqueue 
)

◆ isInFusionMode()

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().

◆ optimize() [1/2]

void sycl::_V1::detail::Scheduler::GraphBuilder::optimize ( )

[Provisional] Optimizes the whole graph.

◆ optimize() [2/2]

void sycl::_V1::detail::Scheduler::GraphBuilder::optimize ( const EventImplPtr Event)

[Provisional] Optimizes subgraph that consists of command associated with Event passed and its dependencies.

◆ removeRecordForMemObj()

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().

◆ rescheduleCommand()

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.

◆ startFusion()

void sycl::_V1::detail::Scheduler::GraphBuilder::startFusion ( QueueImplPtr  Queue)

◆ updateLeaves()

void sycl::_V1::detail::Scheduler::GraphBuilder::updateLeaves ( const std::set< Command * > &  Cmds,
MemObjRecord Record,
access::mode  AccessMode,
std::vector< Command * > &  ToCleanUp 
)

Friends And Related Function Documentation

◆ ::MockScheduler

friend class ::MockScheduler
friend

Definition at line 776 of file scheduler.hpp.

◆ Command

friend class Command
friend

Definition at line 773 of file scheduler.hpp.

Member Data Documentation

◆ MMemObjs

std::vector<SYCLMemObjI *> sycl::_V1::detail::Scheduler::GraphBuilder::MMemObjs

Definition at line 718 of file scheduler.hpp.


The documentation for this class was generated from the following files: