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

#include <FUResource.hh>

Inheritance diagram for FUResource:
Inheritance graph
Collaboration diagram for FUResource:
Collaboration graph

Public Member Functions

 FUResource (const std::string &name, int operationCount, int nopSlotWeight, unsigned int initiationInterval=0)
 
virtual ~FUResource ()
 
virtual bool isInUse (const int cycle) const override
 
virtual bool isAvailable (const int cycle) const override
 
virtual bool canAssign (const int cycle, const MoveNode &node) const override
 
virtual void assign (const int cycle, MoveNode &node) override
 
virtual void unassign (const int cycle, MoveNode &node) override
 
virtual bool operator< (const SchedulingResource &other) const override
 
- Public Member Functions inherited from SchedulingResource
virtual ~SchedulingResource ()
 
 SchedulingResource (const std::string &name, const unsigned int ii=0)
 
virtual int relatedResourceGroupCount () const
 
virtual int dependentResourceGroupCount () const
 
int relatedResourceCount (const int group) const
 
int dependentResourceCount (const int group) const
 
virtual void addToRelatedGroup (const int group, SchedulingResource &resource)
 
virtual void addToDependentGroup (const int group, SchedulingResource &resource)
 
virtual SchedulingResourcerelatedResource (const int group, const int index) const
 
virtual SchedulingResourcedependentResource (const int group, const int index) const
 
virtual bool hasRelatedResource (const SchedulingResource &sResource) const
 
virtual bool hasDependentResource (const SchedulingResource &sResource) const
 
virtual const std::string & name () const
 
virtual int useCount () const
 
virtual void increaseUseCount ()
 
virtual void decreaseUseCount ()
 
virtual bool isInputPSocketResource () const
 
virtual bool isOutputPSocketResource () const
 
virtual bool isShortImmPSocketResource () const
 
virtual bool isInputFUResource () const
 
virtual bool isOutputFUResource () const
 
virtual bool isExecutionPipelineResource () const
 
virtual bool isBusResource () const
 
virtual bool isSegmentResource () const
 
virtual bool isIUResource () const
 
virtual bool isITemplateResource () const
 
int instructionIndex (int cycle) const
 
void setInitiationInterval (unsigned int ii)
 
int initiationInterval () const
 
virtual void clear ()
 
virtual void setMaxCycle (unsigned int)
 

Private Member Functions

 FUResource (const FUResource &)
 
FUResourceoperator= (const FUResource &)
 

Private Attributes

int opCount_
 
int nopSlotWeight_
 

Additional Inherited Members

- Protected Member Functions inherited from SchedulingResource
virtual bool validateDependentGroups ()
 
virtual bool validateRelatedGroups ()
 
- Protected Attributes inherited from SchedulingResource
int initiationInterval_
 

Detailed Description

An interface for scheduling FU resources of Resource Model

Definition at line 46 of file FUResource.hh.

Constructor & Destructor Documentation

◆ FUResource() [1/2]

FUResource::FUResource ( const std::string &  name,
int  opCount,
int  nopSlotWeight,
unsigned int  initiationInterval = 0 
)

Constructor defining resource name

Parameters
nameName of resource

Definition at line 43 of file FUResource.cc.

44  :
46  nopSlotWeight_(nopSlotWeight) {
47 }

◆ ~FUResource()

FUResource::~FUResource ( )
virtual

Empty destructor

Definition at line 52 of file FUResource.cc.

52 {}

◆ FUResource() [2/2]

FUResource::FUResource ( const FUResource )
private

Member Function Documentation

◆ assign()

void FUResource::assign ( const int  cycle,
MoveNode node 
)
overridevirtual

Assign resource to given node for given cycle

Parameters
cycleCycle to assign
nodeMoveNode assigned

Implements SchedulingResource.

Reimplemented in OutputFUResource, and InputFUResource.

Definition at line 100 of file FUResource.cc.

100  {
101 
102  // Implemented in derived classes
103  abortWithError("assign of FUResource called!");
104 }

References abortWithError.

◆ canAssign()

bool FUResource::canAssign ( const int  cycle,
const MoveNode node 
) const
overridevirtual

Return true if resource can be assigned for given resource in given cycle

Parameters
cycleCycle to test
nodeMoveNode to test
Returns
true if node can be assigned to cycle

Implements SchedulingResource.

Reimplemented in OutputFUResource, and InputFUResource.

Definition at line 125 of file FUResource.cc.

125  {
126  // Implemented in derived classes
127  abortWithError("canAssign of FUResource called!");
128  return false;
129 }

References abortWithError.

◆ isAvailable()

bool FUResource::isAvailable ( const int  cycle) const
overridevirtual

Test if resource FUResource is available. Not all of the PSocket are inUse.

Parameters
cycleCycle which to test
Returns
True if FUResource is available in cycle

Implements SchedulingResource.

Reimplemented in InputFUResource.

Definition at line 80 of file FUResource.cc.

80  {
81  for (int i = 0; i < dependentResourceGroupCount(); i++) {
82  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
85  if (dependentResource(i, j).isAvailable(cycle)) {
86  return true;
87  }
88  }
89  }
90  }
91  return false;
92 }

References SchedulingResource::dependentResource(), SchedulingResource::dependentResourceCount(), SchedulingResource::dependentResourceGroupCount(), SchedulingResource::isAvailable(), SchedulingResource::isInputPSocketResource(), and SchedulingResource::isOutputPSocketResource().

Referenced by InputFUResource::isAvailable().

Here is the call graph for this function:

◆ isInUse()

bool FUResource::isInUse ( const int  cycle) const
overridevirtual

Test if resource FUResource is used in given cycle, meaning InputPSocket or OutputPSocket is in use or ExecutionPipeline is inUse.

Parameters
cycleCycle which to test
Returns
True if FUResource is already used in cycle

Implements SchedulingResource.

Reimplemented in InputFUResource.

Definition at line 62 of file FUResource.cc.

62  {
63  for (int i = 0; i < dependentResourceGroupCount(); i++) {
64  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
65  if (dependentResource(i, j).isInUse(cycle)) {
66  return true;
67  }
68  }
69  }
70  return false;
71 }

References SchedulingResource::dependentResource(), SchedulingResource::dependentResourceCount(), SchedulingResource::dependentResourceGroupCount(), and SchedulingResource::isInUse().

Referenced by InputFUResource::isInUse().

Here is the call graph for this function:

◆ operator<()

bool FUResource::operator< ( const SchedulingResource other) const
overridevirtual

Comparison operator.

Favours least used FU's and FU's with less operations.

Reimplemented from SchedulingResource.

Definition at line 137 of file FUResource.cc.

137  {
138 
139  const FUResource *fur = static_cast<const FUResource*>(&other);
140  if (fur == NULL) {
141  return false;
142  }
143 
144  if (nopSlotWeight_ < fur->nopSlotWeight_) {
145  return true;
146  }
147 
148  if (nopSlotWeight_ > fur->nopSlotWeight_) {
149  return false;
150  }
151 
152  if (opCount_ < fur->opCount_) {
153  return true;
154  }
155  if (opCount_ > fur->opCount_) {
156  return false;
157  }
158 
159  // favours FU's with connections to less busses.
160  int connCount = 0;
161  int connCount2 = 0;
162 
163  // count the connections.
164  for (int i = 0; i < dependentResourceCount(0); i++) {
166  if (dynamic_cast<InputPSocketResource*>(&r)) {
167  connCount += r.relatedResourceCount(1);
168  } else {
169  connCount += r.relatedResourceCount(2);
170  }
171  }
172 
173  for (int i = 0; i < other.dependentResourceCount(0); i++) {
174  SchedulingResource& r = other.dependentResource(0,i);
175  if (dynamic_cast<InputPSocketResource*>(&r)) {
176  connCount2 += r.relatedResourceCount(1);
177  } else {
178  connCount2 += r.relatedResourceCount(2);
179  }
180  }
181 
182  if (connCount < connCount2) {
183  return true;
184  }
185  if (connCount > connCount2) {
186  return false;
187  }
188 
189  // then use count
190  if (useCount() < other.useCount()) {
191  return true;
192  }
193  if (useCount() > other.useCount()) {
194  return false;
195  }
196 
197  return name() < other.name();
198 }

References SchedulingResource::dependentResource(), SchedulingResource::dependentResourceCount(), SchedulingResource::name(), nopSlotWeight_, opCount_, SchedulingResource::relatedResourceCount(), and SchedulingResource::useCount().

Here is the call graph for this function:

◆ operator=()

FUResource& FUResource::operator= ( const FUResource )
private

◆ unassign()

void FUResource::unassign ( const int  cycle,
MoveNode node 
)
overridevirtual

Unassign resource from given node for given cycle

Parameters
cycleCycle to remove assignment from
nodeMoveNode to remove assignment from

Implements SchedulingResource.

Reimplemented in OutputFUResource, and InputFUResource.

Definition at line 112 of file FUResource.cc.

112  {
113 
114  // Implemented in derived classes
115  abortWithError("unassign of FUResource called!");
116 }

References abortWithError.

Member Data Documentation

◆ nopSlotWeight_

int FUResource::nopSlotWeight_
private

Definition at line 66 of file FUResource.hh.

Referenced by operator<().

◆ opCount_

int FUResource::opCount_
private

Definition at line 65 of file FUResource.hh.

Referenced by operator<().


The documentation for this class was generated from the following files:
SchedulingResource::dependentResourceGroupCount
virtual int dependentResourceGroupCount() const
Definition: SchedulingResource.cc:71
SchedulingResource::SchedulingResource
SchedulingResource(const std::string &name, const unsigned int ii=0)
Definition: SchedulingResource.cc:51
SchedulingResource::isInputPSocketResource
virtual bool isInputPSocketResource() const
SchedulingResource::dependentResource
virtual SchedulingResource & dependentResource(const int group, const int index) const
Definition: SchedulingResource.cc:158
SchedulingResource::dependentResourceCount
int dependentResourceCount(const int group) const
InputPSocketResource
Definition: InputPSocketResource.hh:47
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
SchedulingResource::useCount
virtual int useCount() const
Definition: SchedulingResource.cc:346
SchedulingResource
Definition: SchedulingResource.hh:52
FUResource
Definition: FUResource.hh:46
FUResource::opCount_
int opCount_
Definition: FUResource.hh:65
SchedulingResource::isOutputPSocketResource
virtual bool isOutputPSocketResource() const
SchedulingResource::isInUse
virtual bool isInUse(const int cycle) const =0
SchedulingResource::initiationInterval
int initiationInterval() const
Definition: SchedulingResource.cc:385
SchedulingResource::relatedResourceCount
int relatedResourceCount(const int group) const
SchedulingResource::isAvailable
virtual bool isAvailable(const int cycle) const =0
SchedulingResource::name
virtual const std::string & name() const
FUResource::nopSlotWeight_
int nopSlotWeight_
Definition: FUResource.hh:66