OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SimpleResourceManager Class Reference

#include <SimpleResourceManager.hh>

Inheritance diagram for SimpleResourceManager:
Inheritance graph
Collaboration diagram for SimpleResourceManager:
Collaboration graph

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::Instructioninstruction (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::TerminalImmediateimmediateValue (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
 
- Public Member Functions inherited from ResourceManager
 ResourceManager (const TTAMachine::Machine &machine)
 
virtual ~ResourceManager ()
 
const TTAMachine::Machinemachine () const
 

Static Public Member Functions

static SimpleResourceManagercreateRM (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

SimpleBrokerDirectordirector_
 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_
 

Detailed Description

A simple resource manager.

Definition at line 58 of file SimpleResourceManager.hh.

Constructor & Destructor Documentation

◆ SimpleResourceManager()

SimpleResourceManager::SimpleResourceManager ( const TTAMachine::Machine machine,
unsigned int  ii = 0 
)
private

Constructor.

Parameters
machineTarget machine, ii Initiation interval.

Definition at line 58 of file SimpleResourceManager.cc.

59  :
61  maxCycle_(INT_MAX-1) {
62 
64 }

References buildResourceModel(), and ResourceManager::machine().

Referenced by createRM().

Here is the call graph for this function:

◆ ~SimpleResourceManager()

SimpleResourceManager::~SimpleResourceManager ( )
privatevirtual

Destructor.

Definition at line 162 of file SimpleResourceManager.cc.

162  {
163  delete director_;
164 }

References director_.

Member Function Documentation

◆ assign()

void SimpleResourceManager::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 
)
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.

Parameters
cycleCycle.
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Exceptions
InvalidDataexception if given node is already placed in a cycle different from given cycle.

Implements ResourceManager.

Definition at line 221 of file SimpleResourceManager.cc.

227  {
228 #ifdef DEBUG_RM
229  Application::logStream() << "\tAssign: " << cycle << " " <<
230  node.toString() << std::endl;
231 #endif
232  director_->assign(
233  cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
234 #ifdef DEBUG_RM
235  Application::logStream() << "\tAssign: " << cycle << " " <<
236  node.toString() << " OK!" << std::endl;
237 #endif
238 }

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().

Here is the call graph for this function:

◆ buildResourceModel()

void SimpleResourceManager::buildResourceModel ( const TTAMachine::Machine machine)
private

Creates brokers and builds resource model.

Definition at line 111 of file SimpleResourceManager.cc.

112  {
113 
114  // instantiate brokers
115 
116  std::vector<ResourceBroker*> brokers;
117 
118  InputFUBroker* ifb =
119  new InputFUBroker("InputFUBroker", initiationInterval_);
120  OutputFUBroker* ofb =
121  new OutputFUBroker("OutputFUBroker", initiationInterval_);
122  brokers.push_back(ifb);
123  brokers.push_back(ofb);
124  brokers.push_back(new ExecutionPipelineBroker(
125  "ExecutionPipelineBroker", initiationInterval_));
127  "InputPSocketBroker", *ifb, initiationInterval_);
128  brokers.push_back(ipsb);
129  brokers.push_back(new IUBroker("IUBroker", this, initiationInterval_));
131  "OutputPSocketBroker", *ofb, this, initiationInterval_);
132  brokers.push_back(opsb);
133  BusBroker* bb = new BusBroker(
134  "BusBroker", *ipsb, *opsb, machine,
136  brokers.push_back(bb);
137  brokers.push_back(
138  new ITemplateBroker(
139  "ITemplateBroker", *bb, this, initiationInterval_));
140 
141  ipsb->setBusBroker(*bb);
142  opsb->setBusBroker(*bb);
143 
144  // build resource model and assignment plan
145 
146  for (unsigned int i = 0; i < brokers.size(); i++) {
147  brokers[i]->setInitiationInterval(initiationInterval_);
148  buildDirector_.addBroker(*brokers[i]);
149  plan_.insertBroker(*brokers[i]);
150  }
151 
152  resources = brokers.size();
153 
155 
157 }

References ResourceBuildDirector::addBroker(), ResourceBuildDirector::build(), buildDirector_, director_, initiationInterval_, AssignmentPlan::insertBroker(), ResourceManager::machine(), plan_, resources, InputPSocketBroker::setBusBroker(), and OutputPSocketBroker::setBusBroker().

Referenced by SimpleResourceManager().

Here is the call graph for this function:

◆ canAssign()

bool SimpleResourceManager::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
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.

Parameters
cycleCycle.
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Returns
True if given node can be assigned without resource conflicts in given cycle, false otherwise.

Implements ResourceManager.

Definition at line 186 of file SimpleResourceManager.cc.

192  {
193 #ifdef DEBUG_RM
194  Application::logStream() << "\tCanAssign: " << cycle << " " <<
195  node.toString() << std::endl;
196 #endif
197  return director_->canAssign(
198  cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
199 }

References SimpleBrokerDirector::canAssign(), director_, Application::logStream(), and MoveNode::toString().

Referenced by BFOptimization::canAssign(), BFOptimization::rmEC(), and BFOptimization::rmLC().

Here is the call graph for this function:

◆ canTransportImmediate()

bool SimpleResourceManager::canTransportImmediate ( const MoveNode node,
const TTAMachine::Bus preassignedBus = NULL 
) const
virtual

Tests if immediate of MoveNode can be transported by any of buses of present machine.

Parameters
nodeMoveNode that contains immediate that we test
busif non-null, only check immediate from that bus
Returns
true if the immediate in node can be transported by some bus

Definition at line 411 of file SimpleResourceManager.cc.

412  {
413  return director_->canTransportImmediate(node, preassignedBus);
414 }

References SimpleBrokerDirector::canTransportImmediate(), and director_.

Referenced by RegisterCopyAdder::addConnectionRegisterCopies(), OutputPSocketBroker::isAlreadyAssigned(), OutputPSocketBroker::isApplicable(), IUBroker::isApplicable(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), and BUBasicBlockScheduler::scheduleMove().

Here is the call graph for this function:

◆ clear()

void SimpleResourceManager::clear ( )
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.

619  {
622  director_->clear();
623  setDDG(NULL);
624  setCFG(NULL);
625  setBBN(NULL);
626 }

References buildDirector_, ResourceBuildDirector::clear(), SimpleBrokerDirector::clear(), SimpleBrokerDirector::clearOldResources(), director_, setBBN(), setCFG(), and setDDG().

Referenced by disposeRM().

Here is the call graph for this function:

◆ clearOldResources()

void SimpleResourceManager::clearOldResources ( )
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.

610  {
612 }

References SimpleBrokerDirector::clearOldResources(), and director_.

Referenced by BBSchedulerController::executeDDGPass().

Here is the call graph for this function:

◆ createRM()

SimpleResourceManager * SimpleResourceManager::createRM ( const TTAMachine::Machine machine,
unsigned int  ii = 0 
)
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.

74  {
75  std::map<int, std::list< SimpleResourceManager*> >& pool =
76  rmPool_[&machine];
77  std::list<SimpleResourceManager*>& iipool = pool[ii];
78  if (iipool.empty()) {
79  return new SimpleResourceManager(machine,ii);
80  } else {
81  SimpleResourceManager* rm = iipool.back();
82  iipool.pop_back();
83  return rm;
84  }
85 }

References ResourceManager::machine(), rmPool_, and SimpleResourceManager().

Referenced by BasicBlockPass::executeDDGPass(), BBSchedulerController::executeDDGPass(), and SequentialScheduler::handleBasicBlock().

Here is the call graph for this function:

◆ disposeRM()

void SimpleResourceManager::disposeRM ( SimpleResourceManager rm,
bool  allowReuse = true 
)
static

Definition at line 92 of file SimpleResourceManager.cc.

93  {
94  if (rm == NULL) return;
95  if (allowReuse) {
96  std::map<int, std::list< SimpleResourceManager*> >& pool =
97  rmPool_[&rm->machine()];
98  pool[rm->initiationInterval()].push_back(rm);
99  rm->clear();
100  } else {
101  delete rm;
103  }
104 }

References clear(), ExecutionPipelineResourceTable::finalize(), initiationInterval(), ResourceManager::machine(), and rmPool_.

Referenced by BasicBlockPass::executeDDGPass(), BBSchedulerController::executeDDGPass(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::finishBB(), and SequentialScheduler::handleBasicBlock().

Here is the call graph for this function:

◆ earliestCycle() [1/2]

int SimpleResourceManager::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
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.

Parameters
cycleCycle to start from.
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Returns
The earliest cycle starting from the given cycle in which required resources can be assigned to given node. Returns -1 if assignment is not possible.

Implements ResourceManager.

Definition at line 313 of file SimpleResourceManager.cc.

319  {
320 
321  int ec = director_->earliestCycle(
322  cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
323 #ifdef DEBUG_RM
324  Application::logStream() << "\tEC: " << cycle << " " << node.toString()
325  << std::endl;
326  Application::logStream() << "\t\tEC result is: " << ec << std::endl;
327 #endif
328  return ec;
329 }

References director_, SimpleBrokerDirector::earliestCycle(), Application::logStream(), and MoveNode::toString().

Here is the call graph for this function:

◆ earliestCycle() [2/2]

int SimpleResourceManager::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
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.

Parameters
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Returns
The earliest cycle in the scope where all required resources can be assigned to the given node. -1 if assignment is not possible

Implements ResourceManager.

Definition at line 278 of file SimpleResourceManager.cc.

284  {
285  int ec = director_->earliestCycle(
286  node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
287 #ifdef DEBUG_RM
288  Application::logStream() << "\tEC:" << node.toString() << std::endl;
289  Application::logStream() << "\t\tEC result is: " << ec << std::endl;
290 #endif
291  return ec;
292 }

References director_, SimpleBrokerDirector::earliestCycle(), Application::logStream(), and MoveNode::toString().

Referenced by BFOptimization::rmEC(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleMove(), and BasicBlockScheduler::scheduleOperandWrites().

Here is the call graph for this function:

◆ hasGuard()

bool SimpleResourceManager::hasGuard ( const MoveNode node) const
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.

Parameters
nodeMoveNode to test
Returns
true if any of buses supports guard needed by node, or if move is not conditional.

Definition at line 426 of file SimpleResourceManager.cc.

426  {
427  return director_->hasGuard(node);
428 }

References director_, and SimpleBrokerDirector::hasGuard().

Here is the call graph for this function:

◆ immediateValue()

std::shared_ptr< TTAProgram::TerminalImmediate > SimpleResourceManager::immediateValue ( const MoveNode node)
virtual

Finds the original terminal with value of immediate.

Parameters
nodenode with immediate register source
Returns
terminal with immediate value

Definition at line 509 of file SimpleResourceManager.cc.

509  {
510  return director_->immediateValue(node);
511 }

References director_, and SimpleBrokerDirector::immediateValue().

Referenced by ITemplateBroker::assign().

Here is the call graph for this function:

◆ immediateWriteCycle()

int SimpleResourceManager::immediateWriteCycle ( const MoveNode node) const
virtual

Finds cycle in which the immediate that is read by node is written.

Parameters
nodewith source immediate register
Returns
cycle in which immediate is written to register

Definition at line 520 of file SimpleResourceManager.cc.

520  {
521  return director_->immediateWriteCycle(node);
522 }

References director_, and SimpleBrokerDirector::immediateWriteCycle().

Referenced by ITemplateBroker::assign(), BFShareOperandWithScheduled::operator()(), BFShareOperandLate::operator()(), BFUnscheduleFromBody::unscheduleOriginal(), and BFUnscheduleMove::unscheduleOriginal().

Here is the call graph for this function:

◆ initiationInterval()

virtual unsigned SimpleResourceManager::initiationInterval ( ) const
inlinevirtual

◆ instruction()

TTAProgram::Instruction * SimpleResourceManager::instruction ( int  cycle) const
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.

Parameters
cycleCycle for which to get instruction
Returns
the Instruction with moves and template assigned
Note
This method should be called when whole scope is scheduled

Implements ResourceManager.

Definition at line 442 of file SimpleResourceManager.cc.

442  {
443  return director_->instruction(cycle);
444 }

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().

Here is the call graph for this function:

◆ instructionIndex()

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.

Parameters
cycleCycle to get instruction index.
Returns
Return the instruction index for cycle.

Definition at line 534 of file SimpleResourceManager.cc.

534  {
535  if (initiationInterval_ != 0) {
536  return cycle % initiationInterval_;
537  } else {
538  return cycle;
539  }
540 }

References initiationInterval_.

Referenced by BFShareOperandsLate::operator()().

◆ isTemplateAvailable()

bool SimpleResourceManager::isTemplateAvailable ( int  defCycle,
std::shared_ptr< TTAProgram::Immediate immediate 
) const
virtual

Definition at line 543 of file SimpleResourceManager.cc.

545  {
546 
547  return director_->isTemplateAvailable(defCycle, immediate);
548 }

References director_, and SimpleBrokerDirector::isTemplateAvailable().

Referenced by IUBroker::allAvailableResources(), and IUBroker::assign().

Here is the call graph for this function:

◆ largestCycle()

int SimpleResourceManager::largestCycle ( ) const
overridevirtual

Returns largest cycle known to be used by any of the resources.

Returns
Largest cycle resource manager assigned any resource to.

Implements ResourceManager.

Definition at line 463 of file SimpleResourceManager.cc.

463  {
464 #ifdef DEBUG_RM
465  Application::logStream() << "\tLargestC." << std::endl;
466  int lc = director_->largestCycle();
467  Application::logStream() << "\tLargestC got: " << lc << std::endl;
468  return lc;
469 #else
470  return director_->largestCycle();
471 #endif
472 }

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().

Here is the call graph for this function:

◆ latestCycle() [1/2]

int SimpleResourceManager::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
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.

Parameters
cycleCycle to start from.
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Returns
The latest cycle starting from the given cycle in which required resources can be assigned to given node. -1 if assignment is not possible.

Implements ResourceManager.

Definition at line 384 of file SimpleResourceManager.cc.

390  {
391  int lc = director_->latestCycle(
392  cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
393 #ifdef DEBUG_RM
394  Application::logStream() << "\tLC: " << cycle << " " << node.toString()
395  << std::endl;
396  Application::logStream() << "\t\tLC result is: " << lc << std::endl;
397 #endif
398  return lc;
399 }

References director_, SimpleBrokerDirector::latestCycle(), Application::logStream(), and MoveNode::toString().

Here is the call graph for this function:

◆ latestCycle() [2/2]

int SimpleResourceManager::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
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.

Parameters
nodeNode.
busif not null, bus that has to be used.
srcFUif not null, srcFu that has to be used.
dstFUif not null, dstFU that has to be used.
immWriteCycleif not -1 and src is imm, write cycle of limm.
Returns
The latest cycle in the scope where all required resources can be assigned to the given node. -1 if assignment is not possible. INT_MAX if there is no upper boundary for assignment.

Implements ResourceManager.

Definition at line 349 of file SimpleResourceManager.cc.

355  {
356  int lc = director_->latestCycle(
357  node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex);
358 #ifdef DEBUG_RM
359  Application::logStream() << "\tLC: " << node.toString() << std::endl;
360  Application::logStream() << "\t\tLC result is: " << lc << std::endl;
361 #endif
362  return lc;
363 }

References director_, SimpleBrokerDirector::latestCycle(), Application::logStream(), and MoveNode::toString().

Referenced by BFSchedulePreLoopShared::operator()(), BFRemoveGuardsFromSuccs::operator()(), BFOptimization::rmLC(), BUBasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleOperandWrites(), and BasicBlockScheduler::tryToDelayOperands().

Here is the call graph for this function:

◆ loseInstructionOwnership()

void SimpleResourceManager::loseInstructionOwnership ( int  cycle)
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.

498  {
500 }

References director_, and SimpleBrokerDirector::loseInstructionOwnership().

Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), and BasicBlockPass::copyRMToBB().

Here is the call graph for this function:

◆ maxCycle()

int SimpleResourceManager::maxCycle ( )
inline

Definition at line 142 of file SimpleResourceManager.hh.

142 { return maxCycle_; }

References maxCycle_.

Referenced by setMaxCycle().

◆ print()

void SimpleResourceManager::print ( std::ostream &  target) const
virtual

Print the contents of resource manager.

Parameters
streamtarget stream where to print

Definition at line 566 of file SimpleResourceManager.cc.

566  {
567  if (initiationInterval_ == 0) {
568  buildDirector_.print(target, 10);
569  } else {
571  }
572 
573 }

References buildDirector_, initiationInterval_, and ResourceBuildDirector::print().

Here is the call graph for this function:

◆ resourceCount()

unsigned int SimpleResourceManager::resourceCount ( ) const
virtual

Return the total number of resources.

Returns
Return the total number of resources.

Definition at line 556 of file SimpleResourceManager.cc.

556  {
557  return resources;
558 }

References resources.

◆ setBBN()

void SimpleResourceManager::setBBN ( const BasicBlockNode bbn)

Definition at line 639 of file SimpleResourceManager.cc.

639  {
640  director_->setBBN(bbn);
641 }

References director_, and SimpleBrokerDirector::setBBN().

Referenced by clear(), and BBSchedulerController::executeDDGPass().

Here is the call graph for this function:

◆ setCFG()

void SimpleResourceManager::setCFG ( const ControlFlowGraph cfg)

Definition at line 634 of file SimpleResourceManager.cc.

634  {
635  director_->setCFG(cfg);
636 }

References director_, and SimpleBrokerDirector::setCFG().

Referenced by clear(), and BBSchedulerController::executeDDGPass().

Here is the call graph for this function:

◆ setDDG()

void SimpleResourceManager::setDDG ( const DataDependenceGraph ddg)

Definition at line 629 of file SimpleResourceManager.cc.

629  {
630  director_->setDDG(ddg);
631 }

References director_, and SimpleBrokerDirector::setDDG().

Referenced by clear(), BBSchedulerController::executeDDGPass(), and BF2Scheduler::handleLoopDDG().

Here is the call graph for this function:

◆ setMaxCycle()

void SimpleResourceManager::setMaxCycle ( unsigned int  maxCycle)

◆ smallestCycle()

int SimpleResourceManager::smallestCycle ( ) const
overridevirtual

Returns smallest cycle known to be used by any of the resources.

Returns
Smallest cycle resource manager assigned any resource to.

Implements ResourceManager.

Definition at line 480 of file SimpleResourceManager.cc.

480  {
481 #ifdef DEBUG_RM
482  Application::logStream() << "\tSC." << std::endl;
483  int sc = director_->smallestCycle();
484  Application::logStream() << "\tSC got: " << sc << std::endl;
485  return sc;
486 #else
487  return director_->smallestCycle();
488 #endif
489 }

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().

Here is the call graph for this function:

◆ supportsExternalAssignments()

bool SimpleResourceManager::supportsExternalAssignments ( ) const
overridevirtual

Defines if Resource Manager implementation supports node with resources pre assigned by clients.

Returns
For SimpleResourceManager allways false.

Implements ResourceManager.

Definition at line 453 of file SimpleResourceManager.cc.

453  {
455 }

References director_, and SimpleBrokerDirector::supportsExternalAssignments().

Here is the call graph for this function:

◆ toString()

std::string SimpleResourceManager::toString ( ) const
virtual

Print the contents of resource manager.

Returns
Return string containing the resource table.

Definition at line 582 of file SimpleResourceManager.cc.

582  {
583 
584  std::stringstream temp;
585 
586  if (initiationInterval_ == 0) {
587  buildDirector_.print(temp, 10);
588  } else {
590  }
591 
592  std::string target = "";
593  std::string result = "";
594 
595  while (getline(temp, target)) {
596  // read temp to target
597  target += "\n";
598  result += target;
599  };
600 
601  return result;
602 }

References buildDirector_, initiationInterval_, and ResourceBuildDirector::print().

Here is the call graph for this function:

◆ unassign()

void SimpleResourceManager::unassign ( MoveNode node)
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.

Parameters
nodeNode to unassign.
Exceptions
InvalidDataIf 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.

253 {
254 #ifdef DEBUG_RM
255  Application::logStream() << "\tUnAssign: " << node.toString() << std::endl;
256 #endif
257  director_->unassign(node);
258 }

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().

Here is the call graph for this function:

Member Data Documentation

◆ buildDirector_

ResourceBuildDirector SimpleResourceManager::buildDirector_
private

Resource build director.

Definition at line 160 of file SimpleResourceManager.hh.

Referenced by buildResourceModel(), clear(), print(), and toString().

◆ director_

SimpleBrokerDirector* SimpleResourceManager::director_
private

◆ initiationInterval_

unsigned int SimpleResourceManager::initiationInterval_
private

◆ maxCycle_

unsigned int SimpleResourceManager::maxCycle_
private

Definition at line 163 of file SimpleResourceManager.hh.

Referenced by maxCycle(), and setMaxCycle().

◆ plan_

AssignmentPlan SimpleResourceManager::plan_
private

Resource assignment plan.

Definition at line 158 of file SimpleResourceManager.hh.

Referenced by buildResourceModel().

◆ resources

unsigned int SimpleResourceManager::resources
private

Definition at line 165 of file SimpleResourceManager.hh.

Referenced by buildResourceModel(), and resourceCount().

◆ rmPool_

std::map< const TTAMachine::Machine *, std::map< int, std::list< SimpleResourceManager * > > > SimpleResourceManager::rmPool_
staticprivate

Definition at line 169 of file SimpleResourceManager.hh.

Referenced by createRM(), and disposeRM().


The documentation for this class was generated from the following files:
SimpleResourceManager::rmPool_
static std::map< const TTAMachine::Machine *, std::map< int, std::list< SimpleResourceManager * > > > rmPool_
Definition: SimpleResourceManager.hh:169
SimpleResourceManager::buildResourceModel
void buildResourceModel(const TTAMachine::Machine &machine)
Definition: SimpleResourceManager.cc:111
ResourceManager::ResourceManager
ResourceManager(const TTAMachine::Machine &machine)
Definition: ResourceManager.cc:40
SimpleBrokerDirector::latestCycle
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
Definition: SimpleBrokerDirector.cc:560
SimpleBrokerDirector::clear
void clear()
Definition: SimpleBrokerDirector.cc:944
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
ExecutionPipelineResourceTable::finalize
static void finalize()
Definition: ExecutionPipelineResourceTable.cc:185
SimpleBrokerDirector::unassign
virtual void unassign(MoveNode &node) override
Definition: SimpleBrokerDirector.cc:340
ResourceBuildDirector::clear
void clear()
Definition: ResourceBuildDirector.cc:178
SimpleBrokerDirector::smallestCycle
virtual int smallestCycle() const override
Definition: SimpleBrokerDirector.cc:859
SimpleBrokerDirector::isTemplateAvailable
virtual bool isTemplateAvailable(int, std::shared_ptr< TTAProgram::Immediate >) const
Definition: SimpleBrokerDirector.cc:899
SimpleBrokerDirector::clearOldResources
void clearOldResources()
Definition: SimpleBrokerDirector.cc:913
SimpleBrokerDirector::hasGuard
virtual bool hasGuard(const MoveNode &node) const
Definition: SimpleBrokerDirector.cc:811
SimpleBrokerDirector::canAssign
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
Definition: SimpleBrokerDirector.cc:120
SimpleBrokerDirector::assign
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
Definition: SimpleBrokerDirector.cc:236
SimpleResourceManager::setCFG
void setCFG(const ControlFlowGraph *cfg)
Definition: SimpleResourceManager.cc:634
InputPSocketBroker
Definition: InputPSocketBroker.hh:51
SimpleBrokerDirector::canTransportImmediate
virtual bool canTransportImmediate(const MoveNode &node, const TTAMachine::Bus *preAssignedBus) const
Definition: SimpleBrokerDirector.cc:680
SimpleBrokerDirector::loseInstructionOwnership
virtual void loseInstructionOwnership(int cycle)
Definition: SimpleBrokerDirector.cc:872
ITemplateBroker
Definition: ITemplateBroker.hh:65
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
SimpleResourceManager::initiationInterval
virtual unsigned initiationInterval() const
Definition: SimpleResourceManager.hh:135
OutputPSocketBroker::setBusBroker
void setBusBroker(ResourceBroker &sb)
Definition: OutputPSocketBroker.cc:511
OutputFUBroker
Definition: OutputFUBroker.hh:50
AssignmentPlan::insertBroker
void insertBroker(ResourceBroker &broker)
Definition: AssignmentPlan.cc:68
BusBroker
Definition: BusBroker.hh:60
SimpleResourceManager::clear
void clear()
Clears all bookkeeping done by this RM. The RM can then be reused for different BB.
Definition: SimpleResourceManager.cc:619
SimpleBrokerDirector::earliestCycle
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
Definition: SimpleBrokerDirector.cc:457
SimpleBrokerDirector::setBBN
void setBBN(const BasicBlockNode *bbn)
Definition: SimpleBrokerDirector.cc:962
SimpleBrokerDirector::largestCycle
virtual int largestCycle() const override
Definition: SimpleBrokerDirector.cc:848
SimpleBrokerDirector::setCFG
void setCFG(const ControlFlowGraph *cfg)
Definition: SimpleBrokerDirector.cc:957
SimpleBrokerDirector::setDDG
void setDDG(const DataDependenceGraph *ddg)
Definition: SimpleBrokerDirector.cc:952
SimpleBrokerDirector::immediateValue
virtual std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &)
Definition: SimpleBrokerDirector.cc:883
ResourceBuildDirector::build
void build(const TTAMachine::Machine &machine)
Definition: ResourceBuildDirector.cc:75
OutputPSocketBroker
Definition: OutputPSocketBroker.hh:51
SimpleResourceManager::SimpleResourceManager
SimpleResourceManager(const TTAMachine::Machine &machine, unsigned int ii=0)
Definition: SimpleResourceManager.cc:58
InputPSocketBroker::setBusBroker
void setBusBroker(ResourceBroker &sb)
Definition: InputPSocketBroker.cc:391
SimpleBrokerDirector
Definition: SimpleBrokerDirector.hh:67
SimpleBrokerDirector::immediateWriteCycle
virtual int immediateWriteCycle(const MoveNode &) const
Definition: SimpleBrokerDirector.cc:894
SimpleResourceManager::maxCycle_
unsigned int maxCycle_
Definition: SimpleResourceManager.hh:163
SimpleResourceManager::director_
SimpleBrokerDirector * director_
Resource manager's broker director.
Definition: SimpleResourceManager.hh:156
ResourceBuildDirector::addBroker
void addBroker(ResourceBroker &broker)
Definition: ResourceBuildDirector.cc:61
ResourceManager::machine
const TTAMachine::Machine & machine() const
Definition: ResourceManager.cc:56
SimpleResourceManager::setDDG
void setDDG(const DataDependenceGraph *ddg)
Definition: SimpleResourceManager.cc:629
SimpleBrokerDirector::instruction
virtual TTAProgram::Instruction * instruction(int cycle) const override
Definition: SimpleBrokerDirector.cc:827
SimpleResourceManager::plan_
AssignmentPlan plan_
Resource assignment plan.
Definition: SimpleResourceManager.hh:158
SimpleResourceManager::buildDirector_
ResourceBuildDirector buildDirector_
Resource build director.
Definition: SimpleResourceManager.hh:160
SimpleResourceManager::setBBN
void setBBN(const BasicBlockNode *bbn)
Definition: SimpleResourceManager.cc:639
SimpleResourceManager::maxCycle
int maxCycle()
Definition: SimpleResourceManager.hh:142
SimpleResourceManager::initiationInterval_
unsigned int initiationInterval_
Definition: SimpleResourceManager.hh:162
SimpleBrokerDirector::supportsExternalAssignments
virtual bool supportsExternalAssignments() const override
Definition: SimpleBrokerDirector.cc:838
SimpleResourceManager
Definition: SimpleResourceManager.hh:58
InputFUBroker
Definition: InputFUBroker.hh:55
ResourceBuildDirector::print
void print(std::ostream &target_, unsigned int cycles) const
Definition: ResourceBuildDirector.cc:102
ExecutionPipelineBroker
Definition: ExecutionPipelineBroker.hh:53
IUBroker
Definition: IUBroker.hh:57
SimpleResourceManager::resources
unsigned int resources
Definition: SimpleResourceManager.hh:165
SimpleBrokerDirector::setMaxCycle
void setMaxCycle(unsigned int cycle)
Definition: SimpleBrokerDirector.cc:967