CIRCT
20.0.0git
|
This class models the most basic scheduling problem. More...
#include <Problems.h>
Public Types | |
using | Dependence = detail::Dependence |
A thin wrapper to allow a uniform handling of def-use and auxiliary dependences. More... | |
using | OperatorType = mlir::StringAttr |
Operator types are distinguished by name (chosen by the client). More... | |
using | OperationSet = llvm::SetVector< Operation * > |
using | DependenceRange = llvm::iterator_range< detail::DependenceIterator > |
using | OperatorTypeSet = llvm::SetVector< OperatorType > |
using | PropertyStringVector = llvm::SmallVector< std::pair< std::string, std::string >, 2 > |
Public Member Functions | |
Problem (Operation *containingOp) | |
Construct an empty scheduling problem. More... | |
virtual | ~Problem ()=default |
void | insertOperation (Operation *op) |
Include op in this scheduling problem. More... | |
LogicalResult | insertDependence (Dependence dep) |
Include dep in the scheduling problem. More... | |
void | insertOperatorType (OperatorType opr) |
Include opr in this scheduling problem. More... | |
OperatorType | getOrInsertOperatorType (StringRef name) |
Retrieves the operator type identified by the client-specific name . More... | |
Operation * | getContainingOp () |
Return the operation containing this problem, e.g. to emit diagnostics. More... | |
void | setContainingOp (Operation *op) |
Set the operation containing this problem, e.g. to emit diagnostics. More... | |
bool | hasOperation (Operation *op) |
Return true if op is part of this problem. More... | |
const OperationSet & | getOperations () |
Return the set of operations. More... | |
DependenceRange | getDependences (Operation *op) |
Return a range object to transparently iterate over op's incoming 1) implicit def-use dependences (backed by the SSA graph), and then 2) explictly added auxiliary dependences. More... | |
bool | hasOperatorType (OperatorType opr) |
Return true if opr is part of this problem. More... | |
const OperatorTypeSet & | getOperatorTypes () |
Return the set of operator types. More... | |
std::optional< OperatorType > | getLinkedOperatorType (Operation *op) |
The linked operator type provides the runtime characteristics for op . More... | |
void | setLinkedOperatorType (Operation *op, OperatorType opr) |
std::optional< unsigned > | getLatency (OperatorType opr) |
The latency is the number of cycles opr needs to compute its result. More... | |
void | setLatency (OperatorType opr, unsigned val) |
std::optional< unsigned > | getStartTime (Operation *op) |
Return the start time for op , as computed by the scheduler. More... | |
void | setStartTime (Operation *op, unsigned val) |
std::optional< unsigned > | getEndTime (Operation *op) |
Returns the end time for op , as computed by the scheduler. More... | |
StringAttr | getInstanceName () |
void | setInstanceName (StringAttr name) |
StringAttr | getLibraryName () |
void | setLibraryName (StringAttr name) |
StringAttr | getOperationName (Operation *op) |
void | setOperationName (Operation *op, StringAttr name) |
virtual PropertyStringVector | getProperties (Operation *op) |
virtual PropertyStringVector | getProperties (Dependence dep) |
virtual PropertyStringVector | getProperties (OperatorType opr) |
virtual PropertyStringVector | getProperties () |
virtual LogicalResult | check () |
Return success if the constructed scheduling problem is valid. More... | |
virtual LogicalResult | verify () |
Return success if the computed solution is valid. More... | |
Static Public Attributes | |
static constexpr auto | name = "Problem" |
Protected Types | |
using | AuxDependenceMap = llvm::DenseMap< Operation *, llvm::SmallSetVector< Operation *, 4 > > |
template<typename T > | |
using | OperationProperty = llvm::DenseMap< Operation *, std::optional< T > > |
template<typename T > | |
using | DependenceProperty = llvm::DenseMap< Dependence, std::optional< T > > |
template<typename T > | |
using | OperatorTypeProperty = llvm::DenseMap< OperatorType, std::optional< T > > |
template<typename T > | |
using | InstanceProperty = std::optional< T > |
Protected Member Functions | |
Problem ()=default | |
virtual LogicalResult | checkLinkedOperatorType (Operation *op) |
op is linked to a registered operator type. More... | |
virtual LogicalResult | checkLatency (OperatorType opr) |
opr has a latency. More... | |
virtual LogicalResult | verifyStartTime (Operation *op) |
op has a start time. More... | |
virtual LogicalResult | verifyPrecedence (Dependence dep) |
dep's source operation is available before dep's destination operation starts. More... | |
Private Attributes | |
Operation * | containingOp |
OperationSet | operations |
AuxDependenceMap | auxDependences |
OperatorTypeSet | operatorTypes |
OperationProperty< OperatorType > | linkedOperatorType |
OperationProperty< unsigned > | startTime |
OperatorTypeProperty< unsigned > | latency |
StringAttr | instanceName |
StringAttr | libraryName |
SmallDenseMap< Operation *, StringAttr > | operationNames |
This class models the most basic scheduling problem.
A problem instance is comprised of:
Operations and operator types are stored explicitly. The registered operations induce a subgraph of the SSA graph. We implicitly include the dependences corresponding to its def-use relationships in the problem, e.g. if operation y's second operand uses the first result produced by x, we'd have a dependence x:0 --> y:1
. Clients can additionally register explicit, auxiliary dependence between operations, e.g. to encode memory dependencies or other ordering constraints. Auxiliary dependences do not distinguish specific operands/results. The differences between the flavors are transparent to concrete algorithms.
All components of the problem (operations, dependences, operator types, as well as the instance itself) can be annotated with properties. In this basic problem, we model
linkedOperatorType
maps operations to their operator types.latency
, an operator type-property denoting the number of time steps after which the operator's result is available.startTime
, an operation-property for the time step in which an operation is started. Together, the start times for all operations represent the problem's solution, i.e. the schedule.Subclasses, i.e. corresponding to more complex scheduling problems, can declare additional properties as needed. The check...
methods perform validity checks before scheduling, e.g. that all operations have an associated operator type, etc.
The verify...
methods check the correctness of the solution determined by a concrete scheduling algorithm, e.g. that there are start times available for each registered operation, and the precedence constraints as modeled by the dependences are satisfied.
Definition at line 75 of file Problems.h.
|
protected |
Definition at line 109 of file Problems.h.
A thin wrapper to allow a uniform handling of def-use and auxiliary dependences.
Definition at line 95 of file Problems.h.
|
protected |
Definition at line 115 of file Problems.h.
using circt::scheduling::Problem::DependenceRange = llvm::iterator_range<detail::DependenceIterator> |
Definition at line 105 of file Problems.h.
|
protected |
Definition at line 119 of file Problems.h.
|
protected |
Definition at line 113 of file Problems.h.
using circt::scheduling::Problem::OperationSet = llvm::SetVector<Operation *> |
Definition at line 104 of file Problems.h.
using circt::scheduling::Problem::OperatorType = mlir::StringAttr |
Operator types are distinguished by name (chosen by the client).
Definition at line 98 of file Problems.h.
|
protected |
Definition at line 117 of file Problems.h.
using circt::scheduling::Problem::OperatorTypeSet = llvm::SetVector<OperatorType> |
Definition at line 106 of file Problems.h.
using circt::scheduling::Problem::PropertyStringVector = llvm::SmallVector<std::pair<std::string, std::string>, 2> |
Definition at line 251 of file Problems.h.
|
inlineexplicit |
Construct an empty scheduling problem.
containingOp
is used for its MLIRContext and to emit diagnostics.
Definition at line 81 of file Problems.h.
|
virtualdefault |
|
protecteddefault |
|
virtual |
Return success if the constructed scheduling problem is valid.
Reimplemented in circt::scheduling::ChainingCyclicProblem, and circt::scheduling::ChainingProblem.
Definition at line 96 of file Problems.cpp.
Referenced by circt::scheduling::ChainingProblem::check(), and circt::scheduling::ChainingCyclicProblem::check().
|
protectedvirtual |
opr
has a latency.
Reimplemented in circt::scheduling::SharedOperatorsProblem.
Definition at line 88 of file Problems.cpp.
Referenced by circt::scheduling::SharedOperatorsProblem::checkLatency().
|
protectedvirtual |
op
is linked to a registered operator type.
Definition at line 80 of file Problems.cpp.
|
inline |
Return the operation containing this problem, e.g. to emit diagnostics.
Definition at line 165 of file Problems.h.
References containingOp.
Referenced by circt::scheduling::handleOperationsInTopologicalOrder(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
Problem::DependenceRange Problem::getDependences | ( | Operation * | op | ) |
Return a range object to transparently iterate over op's
incoming 1) implicit def-use dependences (backed by the SSA graph), and then 2) explictly added auxiliary dependences.
In other words, this yields dependences whose destination operation is op
, and whose source operations are op's
predecessors in the problem graph.
To iterate over all of the scheduling problem's dependences, simply process the ranges for all registered operations.
Definition at line 53 of file Problems.cpp.
Referenced by circt::scheduling::computeStartTimesInCycle(), circt::scheduling::dumpAsDOT(), circt::scheduling::scheduleASAP(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
std::optional< unsigned > Problem::getEndTime | ( | Operation * | op | ) |
Returns the end time for op
, as computed by the scheduler.
This end time is derived from the start time and the operator type's latency.
Definition at line 145 of file Problems.cpp.
|
inline |
Definition at line 234 of file Problems.h.
References instanceName.
|
inline |
The latency is the number of cycles opr
needs to compute its result.
Definition at line 204 of file Problems.h.
References latency.
Referenced by circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
|
inline |
Definition at line 237 of file Problems.h.
References libraryName.
|
inline |
The linked operator type provides the runtime characteristics for op
.
Definition at line 196 of file Problems.h.
References linkedOperatorType.
Referenced by isLimited(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
|
inline |
Definition at line 240 of file Problems.h.
References operationNames.
|
inline |
Return the set of operations.
Definition at line 172 of file Problems.h.
References operations.
Referenced by circt::scheduling::dumpAsDOT(), circt::scheduling::handleOperationsInTopologicalOrder(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
|
inline |
Return the set of operator types.
Definition at line 189 of file Problems.h.
References operatorTypes.
Referenced by circt::scheduling::dumpAsDOT().
Problem::OperatorType Problem::getOrInsertOperatorType | ( | StringRef | name | ) |
Retrieves the operator type identified by the client-specific name
.
The operator type is automatically registered in the scheduling problem.
Definition at line 47 of file Problems.cpp.
References circt::calyx::direction::get().
|
virtual |
Reimplemented in circt::scheduling::CyclicProblem.
Definition at line 78 of file Problems.cpp.
Referenced by circt::scheduling::CyclicProblem::getProperties(), circt::scheduling::ChainingProblem::getProperties(), and circt::scheduling::SharedOperatorsProblem::getProperties().
|
virtual |
Reimplemented in circt::scheduling::CyclicProblem.
Definition at line 67 of file Problems.cpp.
|
virtual |
Reimplemented in circt::scheduling::ChainingProblem.
Definition at line 58 of file Problems.cpp.
Referenced by circt::scheduling::dumpAsDOT().
|
virtual |
Reimplemented in circt::scheduling::SharedOperatorsProblem, and circt::scheduling::ChainingProblem.
Definition at line 71 of file Problems.cpp.
|
inline |
Return the start time for op
, as computed by the scheduler.
These start times comprise the basic problem's solution, i.e. the schedule.
Definition at line 212 of file Problems.h.
References startTime.
Referenced by circt::scheduling::computeStartTimesInCycle().
|
inline |
Return true if op
is part of this problem.
Definition at line 170 of file Problems.h.
References operations.
Referenced by circt::scheduling::detail::DependenceIterator::findNextDependence(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
|
inline |
Return true if opr
is part of this problem.
Definition at line 187 of file Problems.h.
References operatorTypes.
LogicalResult Problem::insertDependence | ( | Dependence | dep | ) |
Include dep
in the scheduling problem.
Return failure if dep
does not represent a valid def-use or auxiliary dependence between operations. The endpoints become registered operations w.r.t. the problem.
Definition at line 26 of file Problems.cpp.
References circt::scheduling::detail::Dependence::getDestination(), circt::scheduling::detail::Dependence::getSource(), and circt::scheduling::detail::Dependence::isAuxiliary().
Referenced by circt::analysis::CyclicSchedulingAnalysis::analyzeForOp().
|
inline |
Include op
in this scheduling problem.
Definition at line 146 of file Problems.h.
References operations.
Referenced by circt::analysis::CyclicSchedulingAnalysis::analyzeForOp().
|
inline |
Include opr
in this scheduling problem.
Definition at line 154 of file Problems.h.
References operatorTypes.
|
inline |
Set the operation containing this problem, e.g. to emit diagnostics.
Definition at line 167 of file Problems.h.
References containingOp.
|
inline |
Definition at line 235 of file Problems.h.
References instanceName, and name.
|
inline |
Definition at line 207 of file Problems.h.
References latency.
|
inline |
Definition at line 238 of file Problems.h.
References libraryName, and name.
|
inline |
Definition at line 199 of file Problems.h.
References linkedOperatorType.
|
inline |
Definition at line 243 of file Problems.h.
References name, and operationNames.
|
inline |
Definition at line 215 of file Problems.h.
References startTime.
Referenced by circt::scheduling::scheduleASAP(), circt::scheduling::scheduleCPSAT(), and circt::scheduling::scheduleLP().
|
virtual |
Return success if the computed solution is valid.
Reimplemented in circt::scheduling::ChainingCyclicProblem, circt::scheduling::ModuloProblem, circt::scheduling::SharedOperatorsProblem, circt::scheduling::ChainingProblem, and circt::scheduling::CyclicProblem.
Definition at line 132 of file Problems.cpp.
Referenced by circt::scheduling::CyclicProblem::verify(), circt::scheduling::ChainingProblem::verify(), and circt::scheduling::SharedOperatorsProblem::verify().
|
protectedvirtual |
dep's
source operation is available before dep's
destination operation starts.
Reimplemented in circt::scheduling::CyclicProblem.
Definition at line 114 of file Problems.cpp.
References circt::scheduling::detail::Dependence::getDestination(), and circt::scheduling::detail::Dependence::getSource().
|
protectedvirtual |
op
has a start time.
Definition at line 108 of file Problems.cpp.
|
private |
Definition at line 131 of file Problems.h.
Referenced by circt::scheduling::detail::DependenceIterator::DependenceIterator().
|
private |
Definition at line 127 of file Problems.h.
Referenced by getContainingOp(), and setContainingOp().
|
private |
Definition at line 230 of file Problems.h.
Referenced by getInstanceName(), and setInstanceName().
|
private |
Definition at line 139 of file Problems.h.
Referenced by getLatency(), and setLatency().
|
private |
Definition at line 230 of file Problems.h.
Referenced by getLibraryName(), and setLibraryName().
|
private |
Definition at line 135 of file Problems.h.
Referenced by getLinkedOperatorType(), and setLinkedOperatorType().
|
staticconstexpr |
Definition at line 77 of file Problems.h.
Referenced by setInstanceName(), setLibraryName(), and setOperationName().
|
private |
Definition at line 231 of file Problems.h.
Referenced by getOperationName(), and setOperationName().
|
private |
Definition at line 130 of file Problems.h.
Referenced by getOperations(), hasOperation(), and insertOperation().
|
private |
Definition at line 132 of file Problems.h.
Referenced by getOperatorTypes(), hasOperatorType(), and insertOperatorType().
|
private |
Definition at line 136 of file Problems.h.
Referenced by getStartTime(), and setStartTime().