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

Graph builder class. More...

#include <detail/scheduler/scheduler.hpp>

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

Public Member Functions

 GraphBuilder ()
 
CommandaddCG (std::unique_ptr< detail::CG > CommandGroup, QueueImplPtr Queue, std::vector< Command * > &ToEnqueue)
 Registers command group and adds it to the dependency graph. More...
 
CommandaddCGUpdateHost (std::unique_ptr< detail::CG > CommandGroup, 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 (EventImplPtr Event)
 [Provisional] Optimizes subgraph that consists of command associated with Event passed and its dependencies. More...
 
void cleanupCommand (Command *Cmd)
 
void cleanupFinishedCommands (Command *FinishedCmd, std::vector< std::shared_ptr< cl::sycl::detail::stream_impl >> &, std::vector< std::shared_ptr< const void >> &)
 Removes finished non-leaf non-alloca commands from the subgraph (assuming that all its commands have been waited for). More...
 
void rescheduleCommand (Command *Cmd, 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, std::vector< std::shared_ptr< cl::sycl::detail::stream_impl >> &, std::vector< std::shared_ptr< const void >> &)
 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, EventImplPtr DepEvent, const DepDesc &Dep, std::vector< Command * > &ToCleanUp)
 Perform connection of events in multiple contexts. 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)
 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 473 of file scheduler.hpp.

Constructor & Destructor Documentation

◆ GraphBuilder()

cl::sycl::detail::Scheduler::GraphBuilder::GraphBuilder ( )

Definition at line 89 of file graph_builder.cpp.

Member Function Documentation

◆ addCG()

◆ addCGUpdateHost()

Command * cl::sycl::detail::Scheduler::GraphBuilder::addCGUpdateHost ( std::unique_ptr< detail::CG CommandGroup,
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 540 of file graph_builder.cpp.

◆ addCopyBack()

◆ addHostAccessor()

Command * cl::sycl::detail::Scheduler::GraphBuilder::addHostAccessor ( Requirement Req,
std::vector< Command * > &  ToEnqueue 
)

◆ addNodeToLeaves()

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

◆ cleanupCommand()

◆ cleanupCommandsForRecord()

◆ cleanupFinishedCommands()

void cl::sycl::detail::Scheduler::GraphBuilder::cleanupFinishedCommands ( Command FinishedCmd,
std::vector< std::shared_ptr< cl::sycl::detail::stream_impl >> &  ,
std::vector< std::shared_ptr< const void >> &   
)

◆ connectDepEvent()

Command * cl::sycl::detail::Scheduler::GraphBuilder::connectDepEvent ( Command *const  Cmd,
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 1300 of file graph_builder.cpp.

References cl::sycl::detail::Command::addDep(), cl::sycl::detail::Command::addUser(), cl::sycl::detail::Command::getEvent(), cl::sycl::detail::Command::getWorkerContext(), cl::sycl::detail::DepDesc::MDepCommand, cl::sycl::detail::DepDesc::MDepRequirement, and cl::sycl::detail::ExecCGCommand::MEmptyCmd.

Referenced by cl::sycl::detail::Command::processDepEvent().

◆ decrementLeafCountersForRecord()

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

◆ findAllocaForReq()

◆ findDepForRecord()

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

Finds a command dependency corresponding to the record.

Definition at line 617 of file graph_builder.cpp.

References cl::sycl::detail::DepDesc::MDepRequirement, cl::sycl::detail::Command::MDeps, and cl::sycl::detail::AccessorImplHost::MSYCLMemObj.

◆ getMemObjRecord()

MemObjRecord * cl::sycl::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 171 of file graph_builder.cpp.

References cl::sycl::detail::SYCLMemObjI::MRecord.

◆ getOrInsertMemObjRecord()

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

◆ optimize() [1/2]

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

[Provisional] Optimizes the whole graph.

◆ optimize() [2/2]

void cl::sycl::detail::Scheduler::GraphBuilder::optimize ( EventImplPtr  Event)

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

◆ removeRecordForMemObj()

void cl::sycl::detail::Scheduler::GraphBuilder::removeRecordForMemObj ( SYCLMemObjI MemObject)

Removes the MemObjRecord for the memory object passed.

Definition at line 1278 of file graph_builder.cpp.

References cl::sycl::detail::SYCLMemObjI::MRecord.

◆ rescheduleCommand()

void cl::sycl::detail::Scheduler::GraphBuilder::rescheduleCommand ( Command Cmd,
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.

◆ updateLeaves()

void cl::sycl::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 626 of file scheduler.hpp.

◆ Command

friend class Command
friend

Definition at line 623 of file scheduler.hpp.

Member Data Documentation

◆ MMemObjs

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

Definition at line 573 of file scheduler.hpp.


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