OpenASIP
2.0
|
#include <AssignmentPlan.hh>
Public Member Functions | |
AssignmentPlan () | |
virtual | ~AssignmentPlan () |
void | insertBroker (ResourceBroker &broker) |
void | setRequest (int cycle, MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) |
ResourceBroker & | firstBroker () |
ResourceBroker & | nextBroker (ResourceBroker &pos) |
ResourceBroker & | lastBroker () |
ResourceBroker & | currentBroker () |
void | advance () |
void | backtrack () |
void | tryNextAssignment () |
bool | isTestedAssignmentPossible () |
void | resetAssignments () |
void | resetAssignments (MoveNode &node) |
int | brokerCount () const |
ResourceBroker & | broker (int index) const |
void | clear () |
bool | tryCachedAssignment (MoveNode &node, int cycle, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) |
void | clearCache () |
Private Attributes | |
const TTAMachine::Bus * | bus_ |
const TTAMachine::FunctionUnit * | srcFU_ |
const TTAMachine::FunctionUnit * | dstFU_ |
int | immWriteCycle_ |
const TTAMachine::ImmediateUnit * | immu_ |
int | immRegIndex_ |
std::vector< PendingAssignment * > | assignments_ |
Sequence of pending assignments. More... | |
std::vector< PendingAssignment * > | applicableAssignments_ |
Sequence of applicable pending assignments. More... | |
std::vector< ResourceBroker * > | brokers_ |
Sequence of resource brokers. More... | |
MoveNode * | node_ |
Move of current resource assignment request. More... | |
int | cycle_ |
Cycle in which current node should be placed. More... | |
int | currentBroker_ |
Current broker. More... | |
bool | resourceFound_ |
True if a valid resource of current broker has been assigned. More... | |
std::vector< std::pair< ResourceBroker *, SchedulingResource * > > | lastTestedWorkingAssignment_ |
cache. More... | |
MoveNode * | lastTriedNode_ |
int | lastTriedCycle_ |
Keeps the order in which single resource-specific brokers are invoked to perform their bit of the allocation or assignment. Also records the current state of tentative and potential assignments for each type of resource.
Definition at line 56 of file AssignmentPlan.hh.
AssignmentPlan::AssignmentPlan | ( | ) |
|
virtual |
Destructor.
Definition at line 58 of file AssignmentPlan.cc.
References assignments_, and AssocTools::deleteAllItems().
void AssignmentPlan::advance | ( | ) |
Move to the next resource broker in the sequence.
Definition at line 191 of file AssignmentPlan.cc.
References __func__, applicableAssignments_, currentBroker_, and resourceFound_.
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
void AssignmentPlan::backtrack | ( | ) |
Unassign (if needed) the resource of current broker from the node and then move to previous resource broker in the sequence.
The pending assignments of the current node are forgotten.
Definition at line 211 of file AssignmentPlan.cc.
References __func__, applicableAssignments_, PendingAssignment::broker(), bus_, currentBroker_, cycle_, PendingAssignment::forget(), ResourceBroker::isAlreadyAssigned(), node_, and PendingAssignment::undoAssignment().
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
ResourceBroker & AssignmentPlan::broker | ( | int | index | ) | const |
Return the broker in the given index.
index | Index of broker. |
OutOfRange | if index is out of bounds. |
Definition at line 436 of file AssignmentPlan.cc.
References __func__, and brokers_.
Referenced by SimpleBrokerDirector::busBroker(), SimpleBrokerDirector::executionPipelineBroker(), SimpleBrokerDirector::immediateUnitBroker(), insertBroker(), SimpleBrokerDirector::instructionTemplateBroker(), nextBroker(), setRequest(), and tryCachedAssignment().
int AssignmentPlan::brokerCount | ( | ) | const |
Return the number of brokers in assignment plan.
Definition at line 424 of file AssignmentPlan.cc.
References brokers_.
Referenced by SimpleBrokerDirector::busBroker(), SimpleBrokerDirector::executionPipelineBroker(), SimpleBrokerDirector::immediateUnitBroker(), and SimpleBrokerDirector::instructionTemplateBroker().
void AssignmentPlan::clear | ( | ) |
Definition at line 446 of file AssignmentPlan.cc.
References applicableAssignments_, assignments_, bus_, clearCache(), currentBroker_, cycle_, dstFU_, immRegIndex_, immu_, immWriteCycle_, node_, resourceFound_, and srcFU_.
Referenced by SimpleBrokerDirector::clear().
void AssignmentPlan::clearCache | ( | ) |
Definition at line 464 of file AssignmentPlan.cc.
References lastTestedWorkingAssignment_, lastTriedCycle_, and lastTriedNode_.
Referenced by clear(), tryCachedAssignment(), and SimpleBrokerDirector::unassign().
ResourceBroker & AssignmentPlan::currentBroker | ( | ) |
Return the current broker, that is, the broker whose resources are being evaluated during an assignment process.
Definition at line 179 of file AssignmentPlan.cc.
References __func__, applicableAssignments_, and currentBroker_.
Referenced by SimpleBrokerDirector::assign(), SimpleBrokerDirector::canAssign(), and isTestedAssignmentPossible().
ResourceBroker & AssignmentPlan::firstBroker | ( | ) |
Return the first broker to be evaluated during an assignment process.
Definition at line 130 of file AssignmentPlan.cc.
References __func__, and applicableAssignments_.
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
void AssignmentPlan::insertBroker | ( | ResourceBroker & | broker | ) |
Insert a resource broker in the sequence of brokers.
broker | Resource broker to be inserted. |
Definition at line 68 of file AssignmentPlan.cc.
References assignments_, broker(), and brokers_.
Referenced by SimpleResourceManager::buildResourceModel().
bool AssignmentPlan::isTestedAssignmentPossible | ( | ) |
Return true if at least one tentative assignment is possible with the current broker and the tentative assignments currently applied from the preceding resource brokers.
There are two reasons why no possible assignments are left with the current broker: because all pending assignments have been tried, or because no valid assignment at all is possible.
If the assignment being tested was last of the assignments in the plan (which means move can be assigned completely) stores the information about used resources into the last working assignment cache.
Definition at line 263 of file AssignmentPlan.cc.
References applicableAssignments_, PendingAssignment::broker(), currentBroker(), currentBroker_, cycle_, debugLogRM, lastTestedWorkingAssignment_, PendingAssignment::lastTriedAssignment(), lastTriedCycle_, lastTriedNode_, node_, and PendingAssignment::resource().
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
ResourceBroker & AssignmentPlan::lastBroker | ( | ) |
Return the last broker to be evaluated during an assignment process.
Definition at line 164 of file AssignmentPlan.cc.
References __func__, and applicableAssignments_.
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
ResourceBroker & AssignmentPlan::nextBroker | ( | ResourceBroker & | pos | ) |
Definition at line 139 of file AssignmentPlan.cc.
References __func__, applicableAssignments_, and broker().
void AssignmentPlan::resetAssignments | ( | ) |
Unassign as needed all the resources tentatively assigned by all brokers.
Reset the current broker position to the first one.
Definition at line 384 of file AssignmentPlan.cc.
References applicableAssignments_, bus_, currentBroker_, node_, and MoveNode::unsetCycle().
Referenced by SimpleBrokerDirector::canAssign(), and SimpleBrokerDirector::unassign().
void AssignmentPlan::resetAssignments | ( | MoveNode & | node | ) |
Unassign as needed all the resources tentatively assigned to the given node.
Given node needs to be placed on a cycle.
node | Node to unassign. |
InvalidData | If node is not placed on a cycle. |
Definition at line 403 of file AssignmentPlan.cc.
References __func__, brokers_, TTAProgram::Move::bus(), bus_, MoveNode::isPlaced(), MoveNode::move(), and MoveNode::unsetCycle().
void AssignmentPlan::setRequest | ( | int | cycle, |
MoveNode & | node, | ||
const TTAMachine::Bus * | bus, | ||
const TTAMachine::FunctionUnit * | srcFU, | ||
const TTAMachine::FunctionUnit * | dstFU, | ||
int | immWriteCycle, | ||
const TTAMachine::ImmediateUnit * | immu, | ||
int | immRegIndex | ||
) |
Record the input node to which resources have to be assigned or allocated and the cycle in which the node should be placed.
node | The node of current assignment request. |
cycle | The cycle in which the node should be placed. |
Definition at line 81 of file AssignmentPlan.cc.
References __func__, applicableAssignments_, assignments_, broker(), bus_, currentBroker_, MoveNode::cycle(), cycle_, dstFU_, immRegIndex_, immu_, immWriteCycle_, MoveNode::isPlaced(), node_, MoveNode::setCycle(), srcFU_, and MoveNode::toString().
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
bool AssignmentPlan::tryCachedAssignment | ( | MoveNode & | node, |
int | cycle, | ||
const TTAMachine::Bus * | bus, | ||
const TTAMachine::FunctionUnit * | srcFU, | ||
const TTAMachine::FunctionUnit * | dstFU, | ||
int | immWriteCycle, | ||
const TTAMachine::ImmediateUnit * | immu, | ||
int | immRegIndex | ||
) |
Tries to assign with same resources that which previous canassign succeeded.
If cannot assign with these resources, clear the information of previous successfull canassign and return false. If succeeds, the node is assigned.
Definition at line 310 of file AssignmentPlan.cc.
References broker(), brokers_, clearCache(), dstFU_, immRegIndex_, immu_, immWriteCycle_, ResourceBroker::isApplicable(), lastTestedWorkingAssignment_, lastTriedCycle_, lastTriedNode_, MoveNode::setCycle(), srcFU_, and MoveNode::unsetCycle().
Referenced by SimpleBrokerDirector::assign().
void AssignmentPlan::tryNextAssignment | ( | ) |
Unassign (if needed) the resource of current broker from the node and then assign the next resource from the same list of pending assignments.
Definition at line 237 of file AssignmentPlan.cc.
References applicableAssignments_, PendingAssignment::broker(), bus_, currentBroker_, cycle_, ResourceBroker::isAlreadyAssigned(), node_, resourceFound_, PendingAssignment::tryNext(), and PendingAssignment::undoAssignment().
Referenced by SimpleBrokerDirector::assign(), and SimpleBrokerDirector::canAssign().
|
private |
Sequence of applicable pending assignments.
Definition at line 104 of file AssignmentPlan.hh.
Referenced by advance(), backtrack(), clear(), currentBroker(), firstBroker(), isTestedAssignmentPossible(), lastBroker(), nextBroker(), resetAssignments(), setRequest(), and tryNextAssignment().
|
private |
Sequence of pending assignments.
Definition at line 102 of file AssignmentPlan.hh.
Referenced by clear(), insertBroker(), setRequest(), and ~AssignmentPlan().
|
private |
Sequence of resource brokers.
Definition at line 106 of file AssignmentPlan.hh.
Referenced by broker(), brokerCount(), insertBroker(), resetAssignments(), and tryCachedAssignment().
|
private |
Definition at line 94 of file AssignmentPlan.hh.
Referenced by backtrack(), clear(), resetAssignments(), setRequest(), and tryNextAssignment().
|
private |
Current broker.
Definition at line 112 of file AssignmentPlan.hh.
Referenced by advance(), backtrack(), clear(), currentBroker(), isTestedAssignmentPossible(), resetAssignments(), setRequest(), and tryNextAssignment().
|
private |
Cycle in which current node should be placed.
Definition at line 110 of file AssignmentPlan.hh.
Referenced by backtrack(), clear(), isTestedAssignmentPossible(), setRequest(), and tryNextAssignment().
|
private |
Definition at line 96 of file AssignmentPlan.hh.
Referenced by clear(), setRequest(), and tryCachedAssignment().
|
private |
Definition at line 99 of file AssignmentPlan.hh.
Referenced by clear(), setRequest(), and tryCachedAssignment().
|
private |
Definition at line 98 of file AssignmentPlan.hh.
Referenced by clear(), setRequest(), and tryCachedAssignment().
|
private |
Definition at line 97 of file AssignmentPlan.hh.
Referenced by clear(), setRequest(), and tryCachedAssignment().
|
private |
cache.
Definition at line 118 of file AssignmentPlan.hh.
Referenced by clearCache(), isTestedAssignmentPossible(), and tryCachedAssignment().
|
private |
Definition at line 120 of file AssignmentPlan.hh.
Referenced by clearCache(), isTestedAssignmentPossible(), and tryCachedAssignment().
|
private |
Definition at line 119 of file AssignmentPlan.hh.
Referenced by clearCache(), isTestedAssignmentPossible(), and tryCachedAssignment().
|
private |
Move of current resource assignment request.
Definition at line 108 of file AssignmentPlan.hh.
Referenced by backtrack(), clear(), isTestedAssignmentPossible(), resetAssignments(), setRequest(), and tryNextAssignment().
|
private |
True if a valid resource of current broker has been assigned.
Definition at line 114 of file AssignmentPlan.hh.
Referenced by advance(), clear(), and tryNextAssignment().
|
private |
Definition at line 95 of file AssignmentPlan.hh.
Referenced by clear(), setRequest(), and tryCachedAssignment().