OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
InputPSocketBroker Class Reference

#include <InputPSocketBroker.hh>

Inheritance diagram for InputPSocketBroker:
Inheritance graph
Collaboration diagram for InputPSocketBroker:
Collaboration graph

Public Member Functions

 InputPSocketBroker (std::string name, ResourceBroker &fub, unsigned int initiationInterval=0)
 
virtual ~InputPSocketBroker ()
 
virtual SchedulingResourceSet allAvailableResources (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override
 
virtual void assign (int cycle, MoveNode &node, SchedulingResource &res, int immWriteCycle, int immRegIndex) override
 
virtual void unassign (MoveNode &node) override
 
virtual int earliestCycle (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override
 
virtual int latestCycle (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override
 
virtual bool isAlreadyAssigned (int cycle, const MoveNode &node, const TTAMachine::Bus *) const override
 
virtual bool isApplicable (const MoveNode &node, const TTAMachine::Bus *preassignedBus=NULL) const override
 
virtual void buildResources (const TTAMachine::Machine &target) override
 
virtual void setupResourceLinks (const ResourceMapper &mapper) override
 
void setBusBroker (ResourceBroker &sb)
 
- Public Member Functions inherited from ResourceBroker
 ResourceBroker (std::string, unsigned int initiationInterval=0)
 
virtual ~ResourceBroker ()
 
virtual bool isAnyResourceAvailable (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const
 
virtual SchedulingResourceavailableResource (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const
 
virtual bool isAvailable (SchedulingResource &des, const MoveNode &node, int cycle, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const
 
SchedulingResourceresourceOf (const TTAMachine::MachinePart &mp) const
 
virtual const TTAMachine::MachinePartmachinePartOf (const SchedulingResource &r) const
 
bool hasResourceOf (const TTAMachine::MachinePart &mp) const
 
bool hasResource (const SchedulingResource &r) const
 
int resourceCount () const
 
virtual bool isBusBroker () const
 
virtual bool isITemplateBroker () const
 
virtual bool isIUBroker () const
 
virtual bool isExecutionPipelineBroker () const
 
void validateResources () const
 
virtual std::string brokerName () const
 
void resources (ResourceSet &contents)
 
virtual void setInitiationInterval (unsigned int cycles)
 
virtual void clear ()
 
virtual void setMaxCycle (unsigned int)
 

Private Attributes

ResourceBrokerinputFUBroker_
 
ResourceBrokerbusBroker_
 

Additional Inherited Members

- Public Types inherited from ResourceBroker
typedef std::set< SchedulingResource * > ResourceSet
 
- Protected Types inherited from ResourceBroker
typedef std::map< const TTAMachine::MachinePart *, SchedulingResource *, TTAMachine::MachinePart::ComparatorResourceMap
 
typedef std::map< const MoveNode *, SchedulingResource *, MoveNode::ComparatorMoveResMap
 
- Protected Member Functions inherited from ResourceBroker
void setResourceMapper (const ResourceMapper &mapper)
 
const ResourceMapperresourceMapper () const
 
unsigned int instructionIndex (unsigned int) const
 
void addResource (const TTAMachine::MachinePart &mp, SchedulingResource *res)
 
- Protected Attributes inherited from ResourceBroker
unsigned int initiationInterval_
 
ResourceMap resMap_
 
const ResourceMapperresourceMapper_
 
MoveResMap assignedResources_
 
std::string brokerName_
 

Detailed Description

Input p-socket broker takes care of assigning input socket and input port (of FU or RF) at once.

Definition at line 51 of file InputPSocketBroker.hh.

Constructor & Destructor Documentation

◆ InputPSocketBroker()

InputPSocketBroker::InputPSocketBroker ( std::string  name,
ResourceBroker fub,
unsigned int  initiationInterval = 0 
)

Constructor.

Definition at line 57 of file InputPSocketBroker.cc.

58 :
59 ResourceBroker(name, initiationInterval),
60 inputFUBroker_(fub), busBroker_(NULL) {
61}
ResourceBroker * busBroker_
ResourceBroker & inputFUBroker_

◆ ~InputPSocketBroker()

InputPSocketBroker::~InputPSocketBroker ( )
virtual

Destructor.

Definition at line 66 of file InputPSocketBroker.cc.

66 {
67}

Member Function Documentation

◆ allAvailableResources()

SchedulingResourceSet InputPSocketBroker::allAvailableResources ( int  cycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return all resources managed by this broker that can be assigned to the given node in the given cycle.

Parameters
cycleCycle.
nodeNode.
Returns
All resources managed by this broker that can be assigned to the given node in the given cycle.

Reimplemented from ResourceBroker.

Definition at line 79 of file InputPSocketBroker.cc.

85 {
86
87 cycle = instructionIndex(cycle);
88 if (!isApplicable(node)) {
89 string msg = "Broker not capable of assigning resources to node!";
90 throw ModuleRunTimeError(__FILE__, __LINE__, __func__, msg);
91 }
92
93 Move& move = const_cast<MoveNode&>(node).move();
94
95 SchedulingResourceSet resourceSet;
96
97 if (move.destination().isFUPort()) {
98 // psocket already implicitly assigned by fubroker
99 Socket& inputSocket = *move.destination().port().inputSocket();
100 SchedulingResource* res = resourceOf(inputSocket);
101 if (res->canAssign(cycle, node)) {
102 resourceSet.insert(*res);
103 }
104 return resourceSet;
105
106 } else {
107 // assign psocket for writing rf
108 // ImmediateUnits can not be writen to this way
109
110 const RegisterFile& rf = move.destination().registerFile();
111
112 for (int i = 0; i < rf.portCount(); i++) {
113 Port& port = *rf.port(i);
114 Socket* inputSocket = port.inputSocket();
115 if (inputSocket != NULL) {
116 SchedulingResource* res = resourceOf(*inputSocket);
117 if (res->canAssign(cycle, node)) {
118 resourceSet.insert(*res);
119 }
120 }
121 }
122 return resourceSet;
123 }
124}
#define __func__
virtual bool isApplicable(const MoveNode &node, const TTAMachine::Bus *preassignedBus=NULL) const override
SchedulingResource * resourceOf(const TTAMachine::MachinePart &mp) const
unsigned int instructionIndex(unsigned int) const
void insert(SchedulingResource &resource)
virtual bool canAssign(const int cycle, const MoveNode &node) const =0
virtual RFPort * port(const std::string &name) const
virtual Socket * inputSocket() const
Definition Port.cc:261
virtual int portCount() const
Definition Unit.cc:135
Terminal & destination() const
Definition Move.cc:323
virtual const TTAMachine::Port & port() const
Definition Terminal.cc:378
virtual const TTAMachine::RegisterFile & registerFile() const
Definition Terminal.cc:225
virtual bool isFUPort() const
Definition Terminal.cc:118

References __func__, SchedulingResource::canAssign(), TTAProgram::Move::destination(), TTAMachine::Port::inputSocket(), SchedulingResourceSet::insert(), ResourceBroker::instructionIndex(), isApplicable(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::port(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), TTAProgram::Terminal::registerFile(), and ResourceBroker::resourceOf().

Here is the call graph for this function:

◆ assign()

void InputPSocketBroker::assign ( int  cycle,
MoveNode node,
SchedulingResource res,
int  immWriteCycle,
int  immRegIndex 
)
overridevirtual

Mark given resource as in use for the given node, and assign the corresponding machine part (if applicable) to the node's move.

If the node is already assigned to given resource, this method does nothing.

Parameters
cycleCycle.
nodeNode to assign.
resResource representing input PSocket
Exceptions
WrongSubclassIf this broker does not recognise the given type of resource.
InvalidParametersIf he given resource cannot be assigned to given node or no corresponding machine part is found.
Todo:
Add caching of assigned resource objects (a MoveNode-Resource mapping).

Implements ResourceBroker.

Definition at line 233 of file InputPSocketBroker.cc.

234 {
235 if (!isApplicable(node)) {
236 string msg = "Broker not capable of assigning resources to node!";
237 throw ModuleRunTimeError(__FILE__, __LINE__, __func__, msg);
238 }
239
240 if (!hasResource(res)) {
241 string msg = "Broker does not contain given resource.";
242 throw InvalidData(__FILE__, __LINE__, __func__, msg);
243 }
244
245 Move& move = node.move();
246
247 if (move.destination().isGPR()) {
248
249 Port* port = NULL;
250 const Socket& socket = static_cast<const Socket&>(machinePartOf(res));
251 for (int i = 0; i < socket.portCount(); i++) {
252 if (socket.port(i)->inputSocket() == &socket) {
253 if (socket.port(i)->parentUnit() !=
254 &move.destination().registerFile())
255 continue;
256
257 port = socket.port(i);
258 break;
259 }
260 }
261 if (port == NULL){
262 throw InvalidData(
263 __FILE__, __LINE__, __func__,
264 "Broker does not have necessary Port registered!");
265 }
266 TerminalRegister* newDst =
267 new TerminalRegister(*port, move.destination().index());
268 move.setDestination(newDst);
269 }
270
271 res.assign(instructionIndex(cycle), node);
272 assignedResources_.insert(
273 std::pair<const MoveNode*, SchedulingResource*>(&node,&res));
274}
TTAProgram::Move & move()
MoveResMap assignedResources_
bool hasResource(const SchedulingResource &r) const
virtual const TTAMachine::MachinePart & machinePartOf(const SchedulingResource &r) const
virtual void assign(const int cycle, MoveNode &node)=0
Unit * parentUnit() const
Port * port(int index) const
Definition Socket.cc:266
int portCount() const
void setDestination(Terminal *dst)
Definition Move.cc:333
virtual int index() const
Definition Terminal.cc:274
virtual bool isGPR() const
Definition Terminal.cc:107

References __func__, SchedulingResource::assign(), ResourceBroker::assignedResources_, TTAProgram::Move::destination(), ResourceBroker::hasResource(), TTAProgram::Terminal::index(), TTAMachine::Port::inputSocket(), ResourceBroker::instructionIndex(), isApplicable(), TTAProgram::Terminal::isGPR(), ResourceBroker::machinePartOf(), MoveNode::move(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), TTAProgram::Terminal::registerFile(), and TTAProgram::Move::setDestination().

Here is the call graph for this function:

◆ buildResources()

void InputPSocketBroker::buildResources ( const TTAMachine::Machine target)
overridevirtual

Build all resource objects of the controlled type required to model scheduling resources of the given target processor.

This method cannot set up the resource links (dependent and related resources) of the constructed resource objects.

Parameters
targetTarget machine.

Implements ResourceBroker.

Definition at line 318 of file InputPSocketBroker.cc.

318 {
320 for (int i = 0; i < navi.count(); i++) {
321 Socket* socket = navi.item(i);
322 if (socket->direction() == Socket::INPUT) {
323 InputPSocketResource* ipsResource =
325 ResourceBroker::addResource(*socket, ipsResource);
326 }
327 }
328}
void addResource(const TTAMachine::MachinePart &mp, SchedulingResource *res)
unsigned int initiationInterval_
virtual TCEString name() const
ComponentType * item(int index) const
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368
@ INPUT
Data goes from bus to port.
Definition Socket.hh:59
Direction direction() const

References ResourceBroker::addResource(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Socket::direction(), ResourceBroker::initiationInterval_, TTAMachine::Socket::INPUT, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), and TTAMachine::Machine::socketNavigator().

Here is the call graph for this function:

◆ earliestCycle()

int InputPSocketBroker::earliestCycle ( int  cycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return the earliest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Parameters
cycleCycle.
nodeNode.
Returns
The earliest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Implements ResourceBroker.

Definition at line 138 of file InputPSocketBroker.cc.

143 {
144 abortWithError("Not implemented.");
145 return -1;
146}
#define abortWithError(message)

References abortWithError.

◆ isAlreadyAssigned()

bool InputPSocketBroker::isAlreadyAssigned ( int  cycle,
const MoveNode node,
const TTAMachine::Bus  
) const
overridevirtual

Return true if the given node is already assigned a resource of the type managed by this broker, and the assignment appears valid (that is, the broker has marked that resource as in use in the given cycle).

Parameters
cycleCycle.
nodeNode.
Returns
True if the given node is already assigned a resource of the type managed by this broker, and the assignment appears valid (that is, the broker has marked that resource as in use in the given cycle).

Implements ResourceBroker.

Definition at line 183 of file InputPSocketBroker.cc.

184 {
185 cycle = instructionIndex(cycle);
186 Terminal& dst = const_cast<MoveNode&>(node).move().destination();
187 const Port& port = dst.port();
188 if (port.inputSocket() == NULL)
189 return false;
191 if (res != NULL && res->isInUse(cycle) &&
193 return true;
194 } else {
195 return false;
196 }
197}
static bool containsKey(const MapType &aMap, const KeyType &aKey)
virtual bool isInUse(const int cycle) const =0

References ResourceBroker::assignedResources_, MapTools::containsKey(), TTAMachine::Port::inputSocket(), ResourceBroker::instructionIndex(), SchedulingResource::isInUse(), TTAProgram::Terminal::port(), and ResourceBroker::resourceOf().

Here is the call graph for this function:

◆ isApplicable()

bool InputPSocketBroker::isApplicable ( const MoveNode node,
const TTAMachine::Bus preassignedBus = NULL 
) const
overridevirtual

Return true if the given node needs a resource of the type managed by this broker, false otherwise.

This broker is applicable for all moves, but not long immediates.

Parameters
nodeNode.
Returns
True if the given node needs a resource of the type managed by this broker, false otherwise.

Implements ResourceBroker.

Definition at line 210 of file InputPSocketBroker.cc.

211 {
212 return node.isMove();
213}
bool isMove() const

References MoveNode::isMove().

Referenced by allAvailableResources(), assign(), and unassign().

Here is the call graph for this function:

◆ latestCycle()

int InputPSocketBroker::latestCycle ( int  cycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return the latest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Parameters
cycleCycle.
nodeNode.
Returns
The latest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Implements ResourceBroker.

Definition at line 160 of file InputPSocketBroker.cc.

164 {
165 abortWithError("Not implemented.");
166 return -1;
167}

References abortWithError.

◆ setBusBroker()

void InputPSocketBroker::setBusBroker ( ResourceBroker sb)

Gives reference to segmentbroker to this broker.

Cannot be given in constructor because SegmentBroker is created later.

Definition at line 391 of file InputPSocketBroker.cc.

391 {
392 busBroker_ = &sb;
393}

References busBroker_.

Referenced by SimpleResourceManager::buildResourceModel().

◆ setupResourceLinks()

void InputPSocketBroker::setupResourceLinks ( const ResourceMapper mapper)
overridevirtual

Complete resource initialisation by creating the references to other resources due to a dependency or a relation.

Use the given resource mapper to lookup dependent and related resources using machine parts as keys.

Parameters
mapperResource mapper.

Implements ResourceBroker.

Definition at line 340 of file InputPSocketBroker.cc.

340 {
341
342 setResourceMapper(mapper);
343
344 for (ResourceMap::iterator resIter = resMap_.begin();
345 resIter != resMap_.end(); resIter++) {
346
347 const Socket* socket =
348 dynamic_cast<const Socket*>((*resIter).first);
349 if (socket == NULL){
350 throw InvalidData(
351 __FILE__, __LINE__, __func__,
352 "Broker does not have necessary Socket registered!");
353 }
354 SchedulingResource* socketResource = (*resIter).second;
355
356 for (int i = 0; i < socket->portCount(); i++) {
357 Port* port = socket->port(i);
358 FunctionUnit* fu = dynamic_cast<FunctionUnit*>(port->parentUnit());
359
360 if (fu != NULL) {
361 SchedulingResource& relRes =
363 socketResource->addToRelatedGroup(0, relRes);
364 }
365 }
366
367 for (int i = 0; i < socket->segmentCount(); i++) {
368 Segment* segment = socket->segment(i);
369 Bus* bus = segment->parentBus();
370 try {
371 SchedulingResource& relRes =
372 *busBroker_->resourceOf(*bus);
373 socketResource->addToRelatedGroup(1, relRes);
374 } catch (const KeyNotFound& e) {
375 std::string msg = "InputPSocketBroker: finding ";
376 msg += " resource for Segment ";
377 msg += " failed with error: ";
378 msg += e.errorMessageStack();
379 throw KeyNotFound(
380 __FILE__, __LINE__, __func__, msg);
381 }
382 }
383 }
384}
std::string errorMessageStack(bool messagesOnly=false) const
Definition Exception.cc:138
void setResourceMapper(const ResourceMapper &mapper)
ResourceMap resMap_
virtual void addToRelatedGroup(const int group, SchedulingResource &resource)
Bus * parentBus() const
Segment * segment(int index) const
Definition Socket.cc:401
int segmentCount() const

References __func__, SchedulingResource::addToRelatedGroup(), busBroker_, Exception::errorMessageStack(), inputFUBroker_, TTAMachine::Segment::parentBus(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), ResourceBroker::resMap_, ResourceBroker::resourceOf(), TTAMachine::Socket::segment(), TTAMachine::Socket::segmentCount(), and ResourceBroker::setResourceMapper().

Here is the call graph for this function:

◆ unassign()

void InputPSocketBroker::unassign ( MoveNode node)
overridevirtual

Free the resource type managed by this broker and unassign it from given node.

If this broker is not applicable to the given node, or the node is not assigned a resource of the managed type, this method does nothing.

Parameters
nodeNode.
Todo:
Remove from cache of assigned resource objects.

Implements ResourceBroker.

Definition at line 288 of file InputPSocketBroker.cc.

288 {
289 if (!isApplicable(node)) {
290 return;
291 }
292
294 Move& move = const_cast<MoveNode&>(node).move();
295 Terminal& dst = move.destination();
298 assignedResources_, &node)) != &res) {
299 std::string msg =
300 "InputPSocketBroker: assigned resource changed!";
301 throw ModuleRunTimeError(__FILE__,__LINE__, __func__, msg);
302 }
303 res.unassign(node.cycle(), node);
304 assignedResources_.erase(&node);
305 }
306}
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
int cycle() const
Definition MoveNode.cc:421
virtual void unassign(const int cycle, MoveNode &node)=0

References __func__, ResourceBroker::assignedResources_, MapTools::containsKey(), MoveNode::cycle(), TTAProgram::Move::destination(), TTAMachine::Port::inputSocket(), isApplicable(), MapTools::keyForValue(), TTAProgram::Terminal::port(), ResourceBroker::resourceOf(), and SchedulingResource::unassign().

Here is the call graph for this function:

Member Data Documentation

◆ busBroker_

ResourceBroker* InputPSocketBroker::busBroker_
private

Definition at line 98 of file InputPSocketBroker.hh.

Referenced by setBusBroker(), and setupResourceLinks().

◆ inputFUBroker_

ResourceBroker& InputPSocketBroker::inputFUBroker_
private

Definition at line 97 of file InputPSocketBroker.hh.

Referenced by setupResourceLinks().


The documentation for this class was generated from the following files: