17#ifndef CIRCT_SCHEDULING_PROBLEMS_H
18#define CIRCT_SCHEDULING_PROBLEMS_H
23#include "mlir/IR/BuiltinAttributes.h"
24#include "llvm/ADT/DenseMap.h"
25#include "llvm/ADT/SetVector.h"
77 static constexpr auto name =
"Problem";
110 llvm::DenseMap<Operation *, llvm::SmallSetVector<Operation *, 4>>;
112 template <
typename T>
114 template <
typename T>
116 template <
typename T>
118 template <
typename T>
224 std::optional<unsigned>
getEndTime(Operation *op);
252 llvm::SmallVector<std::pair<std::string, std::string>, 2>;
278 virtual LogicalResult
check();
280 virtual LogicalResult
verify();
288 static constexpr auto name =
"CyclicProblem";
325 virtual LogicalResult
verify()
override;
341 static constexpr auto name =
"ChainingProblem";
398 virtual LogicalResult
check()
override;
399 virtual LogicalResult
verify()
override;
415 static constexpr auto name =
"SharedOperatorsProblem";
428 return limit.lookup(opr);
441 virtual LogicalResult
verify()
override;
458 static constexpr auto name =
"ModuloProblem";
468 virtual LogicalResult
verify()
override;
487 static constexpr auto name =
"ChainingCyclicProblem";
495 LogicalResult
check()
override;
496 LogicalResult
verify()
override;
This class models the accumulation of physical propagation delays on combinational paths along SSA de...
LogicalResult verify() override
Return success if the computed solution is valid.
LogicalResult checkDefUse(Dependence dep)
LogicalResult check() override
Return success if the constructed scheduling problem is valid.
static constexpr auto name
ChainingCyclicProblem()=default
This class models the accumulation of physical propagation delays on combinational paths along SSA de...
ChainingProblem()=default
std::optional< float > getOutgoingDelay(OperatorType opr)
The outgoing delay denotes the propagation time from either the operand inputs (combinational operato...
void setStartTimeInCycle(Operation *op, float time)
void setIncomingDelay(OperatorType opr, float delay)
OperationProperty< float > startTimeInCycle
virtual LogicalResult check() override
Return success if the constructed scheduling problem is valid.
virtual LogicalResult verifyPrecedenceInCycle(Dependence dep)
If dep is an SSA edge and its source operation finishes in the same time step as the destination oper...
std::optional< float > getIncomingDelay(OperatorType opr)
The incoming delay denotes the propagation time from the operand inputs to either the result outputs ...
OperatorTypeProperty< float > incomingDelay
static constexpr auto name
void setOutgoingDelay(OperatorType opr, float delay)
void clearStartTimeInCycle()
virtual LogicalResult verify() override
Return success if the computed solution is valid.
OperatorTypeProperty< float > outgoingDelay
virtual LogicalResult verifyStartTimeInCycle(Operation *op)
op has a non-negative start time in its cycle.
virtual LogicalResult checkDelays(OperatorType opr)
Incoming/outgoing delays are set for opr and non-negative.
std::optional< float > getStartTimeInCycle(Operation *op)
Computed by the scheduler, this start time is relative to the beginning of the cycle that op starts i...
This class models a cyclic scheduling problem.
void setDistance(Dependence dep, unsigned val)
virtual LogicalResult verifyInitiationInterval()
This problem has a non-zero II.
virtual PropertyStringVector getProperties() override
virtual LogicalResult verifyPrecedence(Dependence dep) override
dep's source operation is available before dep's destination operation starts (dep's distance iterati...
std::optional< unsigned > getDistance(Dependence dep)
The distance determines whether a dependence has to be satisfied in the same iteration (distance=0 or...
void setInitiationInterval(unsigned val)
InstanceProperty< unsigned > initiationInterval
static constexpr auto name
virtual LogicalResult verify() override
Return success if the computed solution is valid.
DependenceProperty< unsigned > distance
std::optional< unsigned > getInitiationInterval()
The initiation interval (II) is the number of time steps between subsequent iterations,...
This class models the modulo scheduling problem as the composition of the cyclic problem and the reso...
virtual LogicalResult verify() override
Return success if the computed solution is valid.
static constexpr auto name
virtual LogicalResult verifyUtilization(OperatorType opr) override
opr is not oversubscribed in any congruence class modulo II.
This class models the most basic scheduling problem.
void setLatency(OperatorType opr, unsigned val)
virtual LogicalResult checkLatency(OperatorType opr)
opr has a latency.
llvm::DenseMap< Operation *, llvm::SmallSetVector< Operation *, 4 > > AuxDependenceMap
llvm::SetVector< Operation * > OperationSet
llvm::SetVector< OperatorType > OperatorTypeSet
virtual LogicalResult verify()
Return success if the computed solution is valid.
StringAttr getInstanceName()
virtual LogicalResult check()
Return success if the constructed scheduling problem is valid.
std::optional< unsigned > getLatency(OperatorType opr)
The latency is the number of cycles opr needs to compute its result.
virtual PropertyStringVector getProperties()
void insertOperation(Operation *op)
Include op in this scheduling problem.
llvm::iterator_range< detail::DependenceIterator > DependenceRange
bool hasOperation(Operation *op)
Return true if op is part of this problem.
StringAttr getLibraryName()
LogicalResult insertDependence(Dependence dep)
Include dep in the scheduling problem.
std::optional< unsigned > getEndTime(Operation *op)
Returns the end time for op, as computed by the scheduler.
OperationProperty< OperatorType > linkedOperatorType
OperationProperty< unsigned > startTime
std::optional< T > InstanceProperty
std::optional< OperatorType > getLinkedOperatorType(Operation *op)
The linked operator type provides the runtime characteristics for op.
void setStartTime(Operation *op, unsigned val)
OperatorTypeProperty< unsigned > latency
SmallDenseMap< Operation *, StringAttr > operationNames
llvm::DenseMap< Operation *, std::optional< T > > OperationProperty
static constexpr auto name
virtual ~Problem()=default
void setContainingOp(Operation *op)
Set the operation containing this problem, e.g. to emit diagnostics.
const OperationSet & getOperations()
Return the set of operations.
OperatorType getOrInsertOperatorType(StringRef name)
Retrieves the operator type identified by the client-specific name.
AuxDependenceMap auxDependences
std::optional< unsigned > getStartTime(Operation *op)
Return the start time for op, as computed by the scheduler.
llvm::DenseMap< OperatorType, std::optional< T > > OperatorTypeProperty
void setInstanceName(StringAttr name)
OperatorTypeSet operatorTypes
llvm::SmallVector< std::pair< std::string, std::string >, 2 > PropertyStringVector
virtual LogicalResult verifyStartTime(Operation *op)
op has a start time.
virtual LogicalResult checkLinkedOperatorType(Operation *op)
op is linked to a registered operator type.
llvm::DenseMap< Dependence, std::optional< T > > DependenceProperty
DependenceRange getDependences(Operation *op)
Return a range object to transparently iterate over op's incoming 1) implicit def-use dependences (ba...
bool hasOperatorType(OperatorType opr)
Return true if opr is part of this problem.
virtual LogicalResult verifyPrecedence(Dependence dep)
dep's source operation is available before dep's destination operation starts.
void setLibraryName(StringAttr name)
void setLinkedOperatorType(Operation *op, OperatorType opr)
Operation * getContainingOp()
Return the operation containing this problem, e.g. to emit diagnostics.
mlir::StringAttr OperatorType
Operator types are distinguished by name (chosen by the client).
void insertOperatorType(OperatorType opr)
Include opr in this scheduling problem.
void setOperationName(Operation *op, StringAttr name)
StringAttr getOperationName(Operation *op)
Problem(Operation *containingOp)
Construct an empty scheduling problem.
const OperatorTypeSet & getOperatorTypes()
Return the set of operator types.
This class models a resource-constrained scheduling problem.
std::optional< unsigned > getLimit(OperatorType opr)
The limit is the maximum number of operations using opr that are allowed to start in the same time st...
SharedOperatorsProblem()=default
OperatorTypeProperty< unsigned > limit
virtual LogicalResult verify() override
Return success if the computed solution is valid.
virtual LogicalResult checkLatency(OperatorType opr) override
If opr is limited, it has a non-zero latency.
static constexpr auto name
virtual LogicalResult verifyUtilization(OperatorType opr)
opr is not oversubscribed in any time step.
void setLimit(OperatorType opr, unsigned val)
An iterator to transparently surface an operation's def-use dependences from the SSA subgraph (induce...
A wrapper class to uniformly handle def-use and auxiliary dependence edges.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.