OpenASIP
2.0
|
#include <SimpleResourceManager.hh>
Public Member Functions | |
virtual bool | canAssign (int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual bool | canTransportImmediate (const MoveNode &node, const TTAMachine::Bus *preAssignedBus=NULL) const |
virtual void | assign (int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, 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=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | earliestCycle (int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | latestCycle (MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override |
virtual int | latestCycle (int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, 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 |
virtual unsigned int | resourceCount () const |
virtual void | print (std::ostream &target) const |
virtual std::string | toString () const |
virtual unsigned | initiationInterval () const |
virtual void | clearOldResources () |
void | setDDG (const DataDependenceGraph *ddg) |
void | setCFG (const ControlFlowGraph *cfg) |
void | setBBN (const BasicBlockNode *bbn) |
void | setMaxCycle (unsigned int maxCycle) |
int | maxCycle () |
unsigned int | instructionIndex (unsigned int) const |
![]() | |
ResourceManager (const TTAMachine::Machine &machine) | |
virtual | ~ResourceManager () |
const TTAMachine::Machine & | machine () const |
Static Public Member Functions | |
static SimpleResourceManager * | createRM (const TTAMachine::Machine &machine, unsigned int ii=0) |
static void | disposeRM (SimpleResourceManager *rm, bool allowReuse=true) |
Private Member Functions | |
SimpleResourceManager (const TTAMachine::Machine &machine, unsigned int ii=0) | |
virtual | ~SimpleResourceManager () |
void | clear () |
Clears all bookkeeping done by this RM. The RM can then be reused for different BB. More... | |
void | buildResourceModel (const TTAMachine::Machine &machine) |
Private Attributes | |
SimpleBrokerDirector * | director_ |
Resource manager's broker director. More... | |
AssignmentPlan | plan_ |
Resource assignment plan. More... | |
ResourceBuildDirector | buildDirector_ |
Resource build director. More... | |
unsigned int | initiationInterval_ |
unsigned int | maxCycle_ |
unsigned int | resources |
Static Private Attributes | |
static std::map< const TTAMachine::Machine *, std::map< int, std::list< SimpleResourceManager * > > > | rmPool_ |
A simple resource manager.
Definition at line 58 of file SimpleResourceManager.hh.
|
private |
Constructor.
machine | Target machine, ii Initiation interval. |
Definition at line 58 of file SimpleResourceManager.cc.
References buildResourceModel(), and ResourceManager::machine().
Referenced by createRM().
|
privatevirtual |
|
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. |
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. |
InvalidData | exception if given node is already placed in a cycle different from given cycle. |
Implements ResourceManager.
Definition at line 221 of file SimpleResourceManager.cc.
References SimpleBrokerDirector::assign(), director_, Application::logStream(), and MoveNode::toString().
Referenced by BFOptimization::assign(), BFOptimization::assignCopyToPrologEpilog(), BFOptimization::canAssign(), BFSchedulePreLoopShared::operator()(), BFAssignToBody::operator()(), BFPostpassLoopDRE::operator()(), BFDRELoop::operator()(), BFUnscheduleFromBody::returnOriginal(), BFOptimization::rmEC(), BFOptimization::rmLC(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleMove(), and BasicBlockScheduler::tryToDelayOperands().
|
private |
Creates brokers and builds resource model.
Definition at line 111 of file SimpleResourceManager.cc.
References ResourceBuildDirector::addBroker(), ResourceBuildDirector::build(), buildDirector_, director_, initiationInterval_, AssignmentPlan::insertBroker(), ResourceManager::machine(), plan_, resources, InputPSocketBroker::setBusBroker(), and OutputPSocketBroker::setBusBroker().
Referenced by SimpleResourceManager().
|
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. |
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 186 of file SimpleResourceManager.cc.
References SimpleBrokerDirector::canAssign(), director_, Application::logStream(), and MoveNode::toString().
Referenced by BFOptimization::canAssign(), BFOptimization::rmEC(), and BFOptimization::rmLC().
|
virtual |
Tests if immediate of MoveNode can be transported by any of buses of present machine.
node | MoveNode that contains immediate that we test |
bus | if non-null, only check immediate from that bus |
Definition at line 411 of file SimpleResourceManager.cc.
References SimpleBrokerDirector::canTransportImmediate(), and director_.
Referenced by RegisterCopyAdder::addConnectionRegisterCopies(), OutputPSocketBroker::isAlreadyAssigned(), OutputPSocketBroker::isApplicable(), IUBroker::isApplicable(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), and BUBasicBlockScheduler::scheduleMove().
|
private |
Clears all bookkeeping done by this RM. The RM can then be reused for different BB.
Clears a resource manager so that it can be reused for different BB.
After this call the state of the RM should be identical to a new RM.
Definition at line 619 of file SimpleResourceManager.cc.
References buildDirector_, ResourceBuildDirector::clear(), SimpleBrokerDirector::clear(), SimpleBrokerDirector::clearOldResources(), director_, setBBN(), setCFG(), and setDDG().
Referenced by disposeRM().
|
virtual |
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 610 of file SimpleResourceManager.cc.
References SimpleBrokerDirector::clearOldResources(), and director_.
Referenced by BBSchedulerController::executeDDGPass().
|
static |
Factory method for creating resource managers.
Checks a RM pool if a recyclable RM is found for same machine with same II, if found gives that. If not found, creates a new RM.
Definition at line 73 of file SimpleResourceManager.cc.
References ResourceManager::machine(), rmPool_, and SimpleResourceManager().
Referenced by BasicBlockPass::executeDDGPass(), BBSchedulerController::executeDDGPass(), and SequentialScheduler::handleBasicBlock().
|
static |
Definition at line 92 of file SimpleResourceManager.cc.
References clear(), ExecutionPipelineResourceTable::finalize(), initiationInterval(), ResourceManager::machine(), and rmPool_.
Referenced by BasicBlockPass::executeDDGPass(), BBSchedulerController::executeDDGPass(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::finishBB(), and SequentialScheduler::handleBasicBlock().
|
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 | 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 313 of file SimpleResourceManager.cc.
References director_, SimpleBrokerDirector::earliestCycle(), Application::logStream(), and MoveNode::toString().
|
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.
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 278 of file SimpleResourceManager.cc.
References director_, SimpleBrokerDirector::earliestCycle(), Application::logStream(), and MoveNode::toString().
Referenced by BFOptimization::rmEC(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleMove(), and BasicBlockScheduler::scheduleOperandWrites().
|
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 426 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::hasGuard().
|
virtual |
Finds the original terminal with value of immediate.
node | node with immediate register source |
Definition at line 509 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::immediateValue().
Referenced by ITemplateBroker::assign().
|
virtual |
Finds cycle in which the immediate that is read by node is written.
node | with source immediate register |
Definition at line 520 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::immediateWriteCycle().
Referenced by ITemplateBroker::assign(), BFShareOperandWithScheduled::operator()(), BFShareOperandLate::operator()(), BFUnscheduleFromBody::unscheduleOriginal(), and BFUnscheduleMove::unscheduleOriginal().
|
inlinevirtual |
Definition at line 135 of file SimpleResourceManager.hh.
References initiationInterval_.
Referenced by LoopPrologAndEpilogBuilder::addPrologFromRM(), LoopPrologAndEpilogBuilder::build(), BasicBlockPass::copyRMToBB(), disposeRM(), BUBasicBlockScheduler::findBypassDestinations(), BUBasicBlockScheduler::handleLoopDDG(), BasicBlockScheduler::handleLoopDDG(), BF2Scheduler::handleLoopDDG(), BFSchedulePreLoopShared::operator()(), BasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleMove(), BasicBlockScheduler::scheduleOperandWrites(), BUBasicBlockScheduler::scheduleOperandWrites(), BasicBlockScheduler::scheduleOperation(), BUBasicBlockScheduler::scheduleOperation(), BUBasicBlockScheduler::tryToSwitchInputs(), and BasicBlockScheduler::tryToSwitchInputs().
|
overridevirtual |
Returns instruction that holds a moves for given cycle and has correct template set.
The instruction ownedship stays in the resource manager until loseInstructionOwnership() is called.
cycle | Cycle for which to get instruction |
Implements ResourceManager.
Definition at line 442 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::instruction().
Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), ResourceConstraintAnalyzer::analyzeMoveNode(), BFOptimization::assignCopyToPrologEpilog(), LoopPrologAndEpilogBuilder::build(), BasicBlockPass::copyRMToBB(), BasicBlockScheduler::handleRemovedResultMoves(), BFShareOperandsLate::operator()(), BFUnscheduleFromBody::returnOriginal(), BFUnscheduleMove::returnOriginal(), and BFShareOperandLate::revert().
unsigned int SimpleResourceManager::instructionIndex | ( | unsigned int | cycle | ) | const |
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 534 of file SimpleResourceManager.cc.
References initiationInterval_.
Referenced by BFShareOperandsLate::operator()().
|
virtual |
Definition at line 543 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::isTemplateAvailable().
Referenced by IUBroker::allAvailableResources(), and IUBroker::assign().
|
overridevirtual |
Returns largest cycle known to be used by any of the resources.
Implements ResourceManager.
Definition at line 463 of file SimpleResourceManager.cc.
References director_, SimpleBrokerDirector::largestCycle(), and Application::logStream().
Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), BFOptimization::assignCopyToPrologEpilog(), BasicBlockPass::copyRMToBB(), DDGPass::handleDDG(), BUBasicBlockScheduler::handleDDG(), BasicBlockScheduler::handleDDG(), BF2Scheduler::handleDDG(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), and BasicBlockScheduler::scheduleOperation().
|
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 384 of file SimpleResourceManager.cc.
References director_, SimpleBrokerDirector::latestCycle(), Application::logStream(), and MoveNode::toString().
|
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 349 of file SimpleResourceManager.cc.
References director_, SimpleBrokerDirector::latestCycle(), Application::logStream(), and MoveNode::toString().
Referenced by BFSchedulePreLoopShared::operator()(), BFRemoveGuardsFromSuccs::operator()(), BFOptimization::rmLC(), BUBasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleOperandWrites(), and BasicBlockScheduler::tryToDelayOperands().
|
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 498 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::loseInstructionOwnership().
Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), and BasicBlockPass::copyRMToBB().
|
inline |
Definition at line 142 of file SimpleResourceManager.hh.
References maxCycle_.
Referenced by setMaxCycle().
|
virtual |
Print the contents of resource manager.
stream | target stream where to print |
Definition at line 566 of file SimpleResourceManager.cc.
References buildDirector_, initiationInterval_, and ResourceBuildDirector::print().
|
virtual |
Return the total number of resources.
Definition at line 556 of file SimpleResourceManager.cc.
References resources.
void SimpleResourceManager::setBBN | ( | const BasicBlockNode * | bbn | ) |
Definition at line 639 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::setBBN().
Referenced by clear(), and BBSchedulerController::executeDDGPass().
void SimpleResourceManager::setCFG | ( | const ControlFlowGraph * | cfg | ) |
Definition at line 634 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::setCFG().
Referenced by clear(), and BBSchedulerController::executeDDGPass().
void SimpleResourceManager::setDDG | ( | const DataDependenceGraph * | ddg | ) |
Definition at line 629 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::setDDG().
Referenced by clear(), BBSchedulerController::executeDDGPass(), and BF2Scheduler::handleLoopDDG().
void SimpleResourceManager::setMaxCycle | ( | unsigned int | maxCycle | ) |
Definition at line 647 of file SimpleResourceManager.cc.
References director_, maxCycle(), maxCycle_, and SimpleBrokerDirector::setMaxCycle().
Referenced by CopyingDelaySlotFiller::addResourceManager(), BUBasicBlockScheduler::handleDDG(), BF2Scheduler::handleLoopDDG(), and BF2Scheduler::scheduleDDG().
|
overridevirtual |
Returns smallest cycle known to be used by any of the resources.
Implements ResourceManager.
Definition at line 480 of file SimpleResourceManager.cc.
References director_, Application::logStream(), and SimpleBrokerDirector::smallestCycle().
Referenced by LoopPrologAndEpilogBuilder::addPrologFromRM(), BFOptimization::assignCopyToPrologEpilog(), LoopPrologAndEpilogBuilder::build(), CopyingDelaySlotFiller::collectMoves(), BasicBlockPass::copyRMToBB(), BasicBlockPass::executeDDGPass(), CopyingDelaySlotFiller::fillDelaySlots(), BUBasicBlockScheduler::handleDDG(), BF2Scheduler::handleDDG(), BUBasicBlockScheduler::handleLoopDDG(), BF2Scheduler::handleLoopDDG(), BF2ScheduleFront::scheduleFrontFromMove(), BUBasicBlockScheduler::scheduleOperation(), and CopyingDelaySlotFiller::tryToFillSlots().
|
overridevirtual |
Defines if Resource Manager implementation supports node with resources pre assigned by clients.
Implements ResourceManager.
Definition at line 453 of file SimpleResourceManager.cc.
References director_, and SimpleBrokerDirector::supportsExternalAssignments().
|
virtual |
Print the contents of resource manager.
Definition at line 582 of file SimpleResourceManager.cc.
References buildDirector_, initiationInterval_, and ResourceBuildDirector::print().
|
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 252 of file SimpleResourceManager.cc.
References director_, Application::logStream(), MoveNode::toString(), and SimpleBrokerDirector::unassign().
Referenced by BFOptimization::canAssign(), BFOptimization::rmEC(), BFOptimization::rmLC(), BUBasicBlockScheduler::scheduleMove(), BasicBlockScheduler::tryToDelayOperands(), BFOptimization::unassign(), BFOptimization::unassignCopyFromPrologEpilog(), CopyingDelaySlotFiller::unassignTempAssigns(), BFSchedulePreLoopShared::undoOnlyMe(), BFAssignToBody::undoOnlyMe(), BFPostpassLoopDRE::undoOnlyMe(), BFDRELoop::undoOnlyMe(), BasicBlockScheduler::unschedule(), SequentialScheduler::unschedule(), and BFUnscheduleFromBody::unscheduleOriginal().
|
private |
Resource build director.
Definition at line 160 of file SimpleResourceManager.hh.
Referenced by buildResourceModel(), clear(), print(), and toString().
|
private |
Resource manager's broker director.
Definition at line 156 of file SimpleResourceManager.hh.
Referenced by assign(), buildResourceModel(), canAssign(), canTransportImmediate(), clear(), clearOldResources(), earliestCycle(), hasGuard(), immediateValue(), immediateWriteCycle(), instruction(), isTemplateAvailable(), largestCycle(), latestCycle(), loseInstructionOwnership(), setBBN(), setCFG(), setDDG(), setMaxCycle(), smallestCycle(), supportsExternalAssignments(), unassign(), and ~SimpleResourceManager().
|
private |
Definition at line 162 of file SimpleResourceManager.hh.
Referenced by buildResourceModel(), initiationInterval(), instructionIndex(), print(), and toString().
|
private |
Definition at line 163 of file SimpleResourceManager.hh.
Referenced by maxCycle(), and setMaxCycle().
|
private |
Resource assignment plan.
Definition at line 158 of file SimpleResourceManager.hh.
Referenced by buildResourceModel().
|
private |
Definition at line 165 of file SimpleResourceManager.hh.
Referenced by buildResourceModel(), and resourceCount().
|
staticprivate |
Definition at line 169 of file SimpleResourceManager.hh.
Referenced by createRM(), and disposeRM().