OpenASIP
2.0
|
#include <SimpleBrokerDirector.hh>
Classes | |
struct | OriginalResources |
Public Member Functions | |
SimpleBrokerDirector (const TTAMachine::Machine &machine, AssignmentPlan &plan, unsigned int initiationInterval_) | |
virtual | ~SimpleBrokerDirector () |
virtual bool | canAssign (int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual bool | canTransportImmediate (const MoveNode &node, const TTAMachine::Bus *preAssignedBus) const |
virtual void | assign (int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override |
virtual void | unassign (MoveNode &node) override |
virtual int | earliestCycle (MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | earliestCycle (int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | latestCycle (MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | latestCycle (int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual bool | hasGuard (const MoveNode &node) const |
virtual TTAProgram::Instruction * | instruction (int cycle) const override |
virtual bool | supportsExternalAssignments () const override |
virtual int | largestCycle () const override |
virtual int | smallestCycle () const override |
virtual void | loseInstructionOwnership (int cycle) |
virtual std::shared_ptr< TTAProgram::TerminalImmediate > | immediateValue (const MoveNode &) |
virtual int | immediateWriteCycle (const MoveNode &) const |
virtual bool | isTemplateAvailable (int, std::shared_ptr< TTAProgram::Immediate >) const |
void | setMaxCycle (unsigned int cycle) |
void | clearOldResources () |
void | clear () |
void | setDDG (const DataDependenceGraph *ddg) |
void | setCFG (const ControlFlowGraph *cfg) |
void | setBBN (const BasicBlockNode *bbn) |
Public Member Functions inherited from BrokerDirector | |
BrokerDirector (const TTAMachine::Machine &machine, AssignmentPlan &plan) | |
virtual | ~BrokerDirector () |
Public Member Functions inherited from ResourceManager | |
ResourceManager (const TTAMachine::Machine &machine) | |
virtual | ~ResourceManager () |
const TTAMachine::Machine & | machine () const |
Private Member Functions | |
IUBroker & | immediateUnitBroker () const |
ITemplateBroker & | instructionTemplateBroker () const |
BusBroker & | busBroker () const |
ExecutionPipelineBroker & | executionPipelineBroker () const |
unsigned int | instructionIndex (unsigned int maxCycle) const |
Private Attributes | |
std::map< const MoveNode *, OriginalResources *, MoveNode::Comparator > | origResMap_ |
int | knownMaxCycle_ |
int | knownMinCycle_ |
unsigned int | initiationInterval_ |
int | schedulingWindow_ |
the number of instructions to look back in the schedule for a free slot More... | |
std::map< int, int > | moveCounts_ |
int | busCount_ |
Additional Inherited Members | |
Protected Attributes inherited from BrokerDirector | |
AssignmentPlan * | plan_ |
Assignment plan. More... | |
A simple broker director.
Definition at line 67 of file SimpleBrokerDirector.hh.
SimpleBrokerDirector::SimpleBrokerDirector | ( | const TTAMachine::Machine & | machine, |
AssignmentPlan & | plan, | ||
unsigned int | ii | ||
) |
Constructor.
machine | Target machine. |
plan | Resource assignment plan. |
ii | Initiation interval. |
Definition at line 79 of file SimpleBrokerDirector.cc.
References Application::cmdLineOptions(), knownMaxCycle_, knownMinCycle_, options, and schedulingWindow_.
|
virtual |
Destructor.
Definition at line 100 of file SimpleBrokerDirector.cc.
References MapTools::deleteAllValues(), and origResMap_.
|
overridevirtual |
Assign all resources needed by a given node starting from given cycle, and place the node in that cycle.
The manager keeps any pre-existing assignment and verifies that assigned resource is available. For all unassigned parts of the node, the resource manager looks for and then assigns the necessary resources. If the node is not fully assigned after the invocation of this operation, it means the assignment attempt failed.
cycle | Cycle. |
node | Node. |
InvalidData | exception if given node is already placed in a cycle different from given cycle. |
Implements ResourceManager.
Definition at line 236 of file SimpleBrokerDirector.cc.
References __func__, AssignmentPlan::advance(), assert, AssignmentPlan::backtrack(), TTAProgram::Move::bus(), TTAProgram::MoveGuard::copy(), TTAProgram::Terminal::copy(), AssignmentPlan::currentBroker(), MoveNode::cycle(), TTAProgram::Move::destination(), POMDisassembler::disassemble(), AssignmentPlan::firstBroker(), TTAProgram::Move::guard(), SimpleBrokerDirector::OriginalResources::guard_, MoveNode::guardLatency(), immediateWriteCycle(), instruction(), instructionIndex(), SimpleBrokerDirector::OriginalResources::isGuarded_, MoveNode::isMove(), MoveNode::isPlaced(), MoveNode::isSourceImmediateRegister(), AssignmentPlan::isTestedAssignmentPossible(), TTAProgram::Move::isUnconditional(), knownMaxCycle_, knownMinCycle_, AssignmentPlan::lastBroker(), MoveNode::move(), moveCounts_, origResMap_, BrokerDirector::plan_, AssignmentPlan::setRequest(), TTAProgram::Move::source(), Conversion::toString(), MoveNode::toString(), AssignmentPlan::tryCachedAssignment(), and AssignmentPlan::tryNextAssignment().
Referenced by SimpleResourceManager::assign().
|
private |
Return the bus broker.
InstanceNotFound | If bus broker is not found. |
Definition at line 737 of file SimpleBrokerDirector.cc.
References __func__, AssignmentPlan::broker(), AssignmentPlan::brokerCount(), ResourceBroker::isBusBroker(), and BrokerDirector::plan_.
Referenced by canTransportImmediate(), hasGuard(), setBBN(), and setCFG().
|
overridevirtual |
Return true if given node can be assigned without resource conflicts in given cycle.
For those parts of the node that have been already assigned to a resource, the manager simply keeps the assignment and verifies that the resource is available. For those parts that are not yet assigned, the resource manager looks for any compatible resource that could be assigned.
cycle | Cycle. |
node | Node. |
Implements ResourceManager.
Definition at line 120 of file SimpleBrokerDirector.cc.
References AssignmentPlan::advance(), AssignmentPlan::backtrack(), TTAProgram::Move::bus(), SimpleBrokerDirector::OriginalResources::bus_, busCount_, TTAProgram::MoveGuard::copy(), TTAProgram::Terminal::copy(), AssignmentPlan::currentBroker(), MoveNode::cycle(), debugLogRM, TTAProgram::Move::destination(), SimpleBrokerDirector::OriginalResources::dst_, AssignmentPlan::firstBroker(), TTAProgram::Move::guard(), SimpleBrokerDirector::OriginalResources::guard_, initiationInterval_, SimpleBrokerDirector::OriginalResources::isGuarded_, MoveNode::isMove(), MoveNode::isPlaced(), MoveNode::isScheduled(), AssignmentPlan::isTestedAssignmentPossible(), TTAProgram::Move::isUnconditional(), AssignmentPlan::lastBroker(), Application::logStream(), MoveNode::move(), moveCounts_, BrokerDirector::plan_, AssignmentPlan::resetAssignments(), TTAProgram::Move::setBus(), MoveNode::setCycle(), TTAProgram::Move::setDestination(), TTAProgram::Move::setGuard(), AssignmentPlan::setRequest(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), SimpleBrokerDirector::OriginalResources::src_, MoveNode::toString(), and AssignmentPlan::tryNextAssignment().
Referenced by SimpleResourceManager::canAssign(), earliestCycle(), and latestCycle().
|
virtual |
Return true if immediate in given node can be transported by some bus in the machine.
node | Node that contains immediate read. |
ModuleRunTimeError | If required resource brokers are not found in assignment plan. |
Definition at line 680 of file SimpleBrokerDirector.cc.
References __func__, busBroker(), BusBroker::canTransportImmediate(), and Exception::errorMessage().
Referenced by SimpleResourceManager::canTransportImmediate().
void SimpleBrokerDirector::clear | ( | ) |
Clears the bookkeeping so that the same RM can be reused for different BB.
After this call the state of the RM should be identical to a new RM.
Definition at line 944 of file SimpleBrokerDirector.cc.
References AssignmentPlan::clear(), knownMaxCycle_, knownMinCycle_, moveCounts_, and BrokerDirector::plan_.
Referenced by SimpleResourceManager::clear().
void SimpleBrokerDirector::clearOldResources | ( | ) |
Clears bookkeeping which is needed for unassigning previously assigned moves. After this call these cannot be unassigned, but new moves which are assigned after this call can still be unassigned.
Definition at line 913 of file SimpleBrokerDirector.cc.
References ITemplateBroker::clearOldResources(), IUBroker::clearOldResources(), AssocTools::deleteAllValues(), immediateUnitBroker(), instructionTemplateBroker(), and origResMap_.
Referenced by SimpleResourceManager::clear(), and SimpleResourceManager::clearOldResources().
|
overridevirtual |
Return the earliest cycle starting from the given cycle in which required resources can be assigned to given node.
If the node is partially assigned, the manager keeps existing assignments. This means that a client can apply arbitrary constraints to resource allocation.
cycle | Cycle to start from. |
node | MoveNode. |
bus | if not null, bus that has to be used. |
srcFU | if not null, srcFu that has to be used. |
dstFU | if not null, dstFU that has to be used. |
immWriteCycle | if not -1 and src is imm, write cycle of limm. |
Implements ResourceManager.
Definition at line 487 of file SimpleBrokerDirector.cc.
References canAssign(), debugLogRM, ExecutionPipelineBroker::earliestCycle(), executionPipelineBroker(), initiationInterval_, knownMaxCycle_, largestCycle(), and schedulingWindow_.
|
overridevirtual |
Return the earliest cycle in the scope where all required resources can be assigned to the given node.
If the node is partially assigned, the manager keeps existing assignments. This means that a client can apply arbitrary constraints to resource allocation.
move | The move. |
bus | if not null, bus that has to be used. |
srcFU | if not null, srcFu that has to be used. |
dstFU | if not null, dstFU that has to be used. |
immWriteCycle | if not -1 and src is imm, write cycle of limm. |
Implements ResourceManager.
Definition at line 457 of file SimpleBrokerDirector.cc.
Referenced by SimpleResourceManager::earliestCycle().
|
private |
Return the execution pipeline broker.
InstanceNotFound | If execution pipeline broker is not found. |
Definition at line 756 of file SimpleBrokerDirector.cc.
References __func__, AssignmentPlan::broker(), AssignmentPlan::brokerCount(), ResourceBroker::isExecutionPipelineBroker(), and BrokerDirector::plan_.
Referenced by earliestCycle(), largestCycle(), latestCycle(), setDDG(), and setMaxCycle().
|
virtual |
Tests if any of a buses of machine supports guard needed by a node. Should always return true! Otherwise, scheduler generated code for different machine.
node | MoveNode to test |
Definition at line 811 of file SimpleBrokerDirector.cc.
References busBroker(), BusBroker::hasGuard(), and TTAProgram::Move::isUnconditional().
Referenced by SimpleResourceManager::hasGuard().
|
private |
Return the immediate unit broker.
InstanceNotFound | If immediate unit broker is not found. |
Definition at line 698 of file SimpleBrokerDirector.cc.
References __func__, AssignmentPlan::broker(), AssignmentPlan::brokerCount(), ResourceBroker::isIUBroker(), and BrokerDirector::plan_.
Referenced by clearOldResources(), immediateValue(), and immediateWriteCycle().
|
virtual |
Finds the original terminal with value of immediate.
node | node with immediate register source |
Definition at line 883 of file SimpleBrokerDirector.cc.
References immediateUnitBroker(), and IUBroker::immediateValue().
Referenced by SimpleResourceManager::immediateValue().
|
virtual |
Finds cycle in which the immediate that is read by node is written.
node | with source immediate register |
Definition at line 894 of file SimpleBrokerDirector.cc.
References immediateUnitBroker(), and IUBroker::immediateWriteCycle().
Referenced by assign(), SimpleResourceManager::immediateWriteCycle(), and unassign().
|
overridevirtual |
Returns a copy of instruction that holds a moves for given cycle and has correct template set.
cycle | Cycle for which to get instruction |
Implements ResourceManager.
Definition at line 827 of file SimpleBrokerDirector.cc.
References ITemplateBroker::instruction(), and instructionTemplateBroker().
Referenced by assign(), SimpleResourceManager::instruction(), and unassign().
|
private |
Return the instruction index corresponding to cycle.
If modulo scheduling is not used (ie. initiation interval is 0), then index is equal to cycle.
cycle | Cycle to get instruction index. |
Definition at line 929 of file SimpleBrokerDirector.cc.
References initiationInterval_.
Referenced by assign(), and unassign().
|
private |
Return the instruction template broker.
InstanceNotFound | If instruction template broker is not found. |
Definition at line 717 of file SimpleBrokerDirector.cc.
References __func__, AssignmentPlan::broker(), AssignmentPlan::brokerCount(), ResourceBroker::isITemplateBroker(), and BrokerDirector::plan_.
Referenced by clearOldResources(), instruction(), isTemplateAvailable(), and loseInstructionOwnership().
|
virtual |
Definition at line 899 of file SimpleBrokerDirector.cc.
References instructionTemplateBroker(), and ITemplateBroker::isTemplateAvailable().
Referenced by SimpleResourceManager::isTemplateAvailable().
|
overridevirtual |
Returns largest cycle known to be used by any of the resources.
Implements ResourceManager.
Definition at line 848 of file SimpleBrokerDirector.cc.
References executionPipelineBroker(), and knownMaxCycle_.
Referenced by earliestCycle(), and SimpleResourceManager::largestCycle().
|
overridevirtual |
Return the latest cycle starting from the given cycle in which required resources can be assigned to given node.
If the node is partially assigned, the manager keeps existing assignments. This means that a client can apply arbitrary constraints to resource allocation.
cycle | Cycle to start from. |
node | Node. |
bus | if not null, bus that has to be used. |
srcFU | if not null, srcFu that has to be used. |
dstFU | if not null, dstFU that has to be used. |
immWriteCycle | if not -1 and src is imm, write cycle of limm. |
Implements ResourceManager.
Definition at line 591 of file SimpleBrokerDirector.cc.
References canAssign(), executionPipelineBroker(), knownMaxCycle_, knownMinCycle_, ExecutionPipelineBroker::latestCycle(), and ExecutionPipelineBroker::longestLatency().
|
overridevirtual |
Return the latest cycle in the scope where all required resources can be assigned to the given node.
If the node is partially assigned, the manager keeps existing assignments. This means that a client can apply arbitrary constraints to resource allocation.
node | Node. |
bus | if not null, bus that has to be used. |
srcFU | if not null, srcFu that has to be used. |
dstFU | if not null, dstFU that has to be used. |
immWriteCycle | if not -1 and src is imm, write cycle of limm. |
Implements ResourceManager.
Definition at line 560 of file SimpleBrokerDirector.cc.
Referenced by SimpleResourceManager::latestCycle().
|
virtual |
Transfer the instruction ownership away from this object.
If this method is called, resource manager does not delete it's instructions when it it destroyed.
Definition at line 872 of file SimpleBrokerDirector.cc.
References instructionTemplateBroker(), and ITemplateBroker::loseInstructionOwnership().
Referenced by SimpleResourceManager::loseInstructionOwnership().
void SimpleBrokerDirector::setBBN | ( | const BasicBlockNode * | bbn | ) |
Definition at line 962 of file SimpleBrokerDirector.cc.
References busBroker(), and BusBroker::setBBN().
Referenced by SimpleResourceManager::setBBN().
void SimpleBrokerDirector::setCFG | ( | const ControlFlowGraph * | cfg | ) |
Definition at line 957 of file SimpleBrokerDirector.cc.
References busBroker(), and BusBroker::setCFG().
Referenced by SimpleResourceManager::setCFG().
void SimpleBrokerDirector::setDDG | ( | const DataDependenceGraph * | ddg | ) |
Definition at line 952 of file SimpleBrokerDirector.cc.
References executionPipelineBroker(), and ExecutionPipelineBroker::setDDG().
Referenced by SimpleResourceManager::setDDG().
void SimpleBrokerDirector::setMaxCycle | ( | unsigned int | cycle | ) |
Definition at line 967 of file SimpleBrokerDirector.cc.
References executionPipelineBroker(), and ExecutionPipelineBroker::setMaxCycle().
Referenced by SimpleResourceManager::setMaxCycle().
|
overridevirtual |
Returns smallest cycle known to be used by any of the resources.
Implements ResourceManager.
Definition at line 859 of file SimpleBrokerDirector.cc.
References knownMinCycle_.
Referenced by SimpleResourceManager::smallestCycle().
|
overridevirtual |
Defines if Broker Director implementation supports node with resources pre assigned by clients.
Implements ResourceManager.
Definition at line 838 of file SimpleBrokerDirector.cc.
Referenced by SimpleResourceManager::supportsExternalAssignments().
|
overridevirtual |
Free all resource assignments of the given node.
If the node is only partially assigned, the resource manager ignores those parts of the node that are already unassigned.
node | Node to unassign. |
InvalidData | If the given node is not placed in any cycle. Assigned but not placed nodes are not considered by the resource manager. |
Implements ResourceManager.
Definition at line 340 of file SimpleBrokerDirector.cc.
References __func__, abortWithError, SimpleBrokerDirector::OriginalResources::bus_, AssignmentPlan::clearCache(), MapTools::containsKey(), MoveNode::cycle(), TTAProgram::Move::destination(), SimpleBrokerDirector::OriginalResources::dst_, SimpleBrokerDirector::OriginalResources::guard_, TTAProgram::Move::guardLatency(), MoveNode::guardLatency(), TTAProgram::Instruction::immediateCount(), immediateWriteCycle(), instruction(), instructionIndex(), TTAProgram::Terminal::isGPR(), SimpleBrokerDirector::OriginalResources::isGuarded_, MoveNode::isMove(), MoveNode::isPlaced(), MoveNode::isSourceImmediateRegister(), knownMaxCycle_, knownMinCycle_, TTAProgram::Instruction::move(), MoveNode::move(), TTAProgram::Instruction::moveCount(), moveCounts_, origResMap_, BrokerDirector::plan_, AssignmentPlan::resetAssignments(), TTAProgram::Move::setBus(), TTAProgram::Move::setDestination(), TTAProgram::Move::setGuard(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), SimpleBrokerDirector::OriginalResources::src_, and MoveNode::toString().
Referenced by SimpleResourceManager::unassign().
|
private |
Definition at line 181 of file SimpleBrokerDirector.hh.
Referenced by canAssign().
|
private |
Definition at line 173 of file SimpleBrokerDirector.hh.
Referenced by canAssign(), earliestCycle(), and instructionIndex().
|
private |
Definition at line 171 of file SimpleBrokerDirector.hh.
Referenced by assign(), clear(), earliestCycle(), largestCycle(), latestCycle(), SimpleBrokerDirector(), and unassign().
|
private |
Definition at line 172 of file SimpleBrokerDirector.hh.
Referenced by assign(), clear(), latestCycle(), SimpleBrokerDirector(), smallestCycle(), and unassign().
|
private |
Definition at line 180 of file SimpleBrokerDirector.hh.
Referenced by assign(), canAssign(), clear(), and unassign().
|
private |
Definition at line 170 of file SimpleBrokerDirector.hh.
Referenced by assign(), clearOldResources(), unassign(), and ~SimpleBrokerDirector().
|
private |
the number of instructions to look back in the schedule for a free slot
Definition at line 177 of file SimpleBrokerDirector.hh.
Referenced by earliestCycle(), and SimpleBrokerDirector().