TCE  1.21
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
ResourceVector Class Reference

#include <ResourceVector.hh>

Collaboration diagram for ResourceVector:
Collaboration graph

Public Types

typedef std::set< std::string > ResourceSet
 Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:", port usages with "port:". More...
 

Public Member Functions

 ResourceVector ()
 
 ResourceVector (const TTAMachine::ExecutionPipeline &pipeline)
 
virtual ~ResourceVector ()
 
const ResourceSetresourcesUsedAtCycle (unsigned cycle) const
 
std::size_t width () const
 
std::string toString () const
 
virtual bool conflictsWith (const ResourceVector &other, unsigned cycle) const
 
virtual void mergeWith (const ResourceVector &other, unsigned cycle)
 
virtual void shiftLeft ()
 
virtual void clear ()
 
virtual bool operator== (const ResourceVector &rightHand) const
 

Private Types

typedef std::deque< ResourceSetResourceUsageIndex
 Each resource usage is stored as a string. More...
 

Private Attributes

ResourceUsageIndex resources_
 The storage for the resource usages. More...
 

Detailed Description

Represents a resource vector used in building the states in case of an function unit FSA.

Definition at line 51 of file ResourceVector.hh.

Member Typedef Documentation

◆ ResourceSet

typedef std::set<std::string> ResourceVector::ResourceSet

Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:", port usages with "port:".

Definition at line 55 of file ResourceVector.hh.

◆ ResourceUsageIndex

typedef std::deque<ResourceSet> ResourceVector::ResourceUsageIndex
private

Each resource usage is stored as a string.

Definition at line 80 of file ResourceVector.hh.

Constructor & Destructor Documentation

◆ ResourceVector() [1/2]

ResourceVector::ResourceVector ( )
inline

Definition at line 57 of file ResourceVector.hh.

57 {};

◆ ResourceVector() [2/2]

ResourceVector::ResourceVector ( const TTAMachine::ExecutionPipeline pipeline)

Constructor.

Builds the resource vector out of MOM ExecutionPipeline.

Parameters
pipelineThe ExecutionPipeline to build the resource vector for.

Definition at line 50 of file ResourceVector.cc.

References TTAMachine::FUPort::bindingString(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::ExecutionPipeline::parentOperation(), TTAMachine::HWOperation::port(), TTAMachine::ExecutionPipeline::readOperands(), resources_, TTAMachine::ExecutionPipeline::resourceUsages(), and TTAMachine::ExecutionPipeline::writtenOperands().

50  {
51 
52  resources_.resize(pipeline.latency(), ResourceSet());
53 
54  for (int i = 0; i < pipeline.latency(); ++i) {
56  pipeline.resourceUsages(i);
57  TTAMachine::ExecutionPipeline::ResourceSet::const_iterator res =
58  resourceUsages.begin();
59  while (res != resourceUsages.end()) {
60  resources_.at(i).insert(std::string("res:") + (*res)->name());
61  ++res;
62  }
64  pipeline.readOperands(i);
66  pipeline.writtenOperands(i);
67  TTAMachine::ExecutionPipeline::OperandSet::const_iterator op =
68  readOperands.begin();
69  while (op != readOperands.end()) {
70  const TTAMachine::FUPort* fuPort =
71  pipeline.parentOperation()->port(*op);
72  resources_.at(i).insert(
73  std::string("port:") + fuPort->bindingString());
74  ++op;
75  }
76 
77  op = writtenOperands.begin();
78  while (op != writtenOperands.end()) {
79  const TTAMachine::FUPort* fuPort =
80  pipeline.parentOperation()->port(*op);
81  resources_.at(i).insert(
82  std::string("port:") + fuPort->bindingString());
83  ++op;
84  }
85  }
86 }
ResourceUsageIndex resources_
The storage for the resource usages.
std::set< int > OperandSet
Set for operand indexes.
std::string bindingString() const
Definition: FUPort.cc:280
std::set< std::string > ResourceSet
Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:"...
OperandSet readOperands(int cycle) const
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:305
OperandSet writtenOperands(int cycle) const
std::set< PipelineElement *, PipelineElement::Comparator > ResourceSet
Set for pipeline elements.
const HWOperation * parentOperation() const
ResourceSet resourceUsages(int cycle) const
Here is the call graph for this function:

◆ ~ResourceVector()

ResourceVector::~ResourceVector ( )
virtual

Destructor.

Definition at line 91 of file ResourceVector.cc.

91  {
92 }

Member Function Documentation

◆ clear()

void ResourceVector::clear ( )
virtual

Clears the resource vector.

Result is an empty resource vector with no columns

Definition at line 218 of file ResourceVector.cc.

References resources_.

Referenced by ResourceVectorFUResourceConflictDetector::reset().

218  {
219  resources_.clear();
220 }
ResourceUsageIndex resources_
The storage for the resource usages.

◆ conflictsWith()

bool ResourceVector::conflictsWith ( const ResourceVector other,
unsigned  cycle 
) const
virtual

Returns true if the given resource vector has conflicting resource usages when issued after given count of cycles.

Parameters
otherThe another resource vector.
cycleThe count of cycles after which the operation is issued.
Returns
True iff there is a conflict.

Definition at line 152 of file ResourceVector.cc.

References resources_, resourcesUsedAtCycle(), and width().

Referenced by ResourceVectorFUResourceConflictDetector::issueOperation().

153  {
154 
155  for (std::size_t c = cycle; c < resources_.size(); ++c) {
156 
157  if (other.width() <= c - cycle)
158  return false;
159 
160  ResourceSet conflictingResources;
161  const ResourceSet& thisResources = resources_.at(c);
162  const ResourceSet& otherResources =
163  other.resourcesUsedAtCycle(c - cycle);
164 
165  if (thisResources.size() == 0 || otherResources.size() == 0)
166  return false;
167 
168  // check if any of the resources in another resource set is
169  // found in the another
170  ResourceSet::const_iterator i = thisResources.begin();
171  while (i != thisResources.end()) {
172  if (otherResources.find(*i) != otherResources.end())
173  return true;
174  ++i;
175  }
176  }
177  return false;
178 }
ResourceUsageIndex resources_
The storage for the resource usages.
std::set< std::string > ResourceSet
Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:"...
const ResourceSet & resourcesUsedAtCycle(unsigned cycle) const
std::size_t width() const
Here is the call graph for this function:

◆ mergeWith()

void ResourceVector::mergeWith ( const ResourceVector other,
unsigned  cycle 
)
virtual

Merges the resource vector with the given resource vector starting from the given cycle.

This method is used for producing the composite vector for simulation. The resulting resource vector is "stretched" in case there are no enough cycle elements in to contain the merged elements.

Parameters
otherThe another resource vector.
cycleThe count of cycles after which the operation is issued.

Definition at line 192 of file ResourceVector.cc.

References resources_, resourcesUsedAtCycle(), and width().

Referenced by ResourceVectorFUResourceConflictDetector::issueOperation().

192  {
193 
194  resources_.resize(std::max(resources_.size(), cycle + other.width()));
195 
196  for (std::size_t i = 0; i < other.width(); ++i) {
197  const ResourceSet& otherResources = other.resourcesUsedAtCycle(i);
198  resources_[cycle + i].insert(
199  otherResources.begin(), otherResources.end());
200  }
201 }
ResourceUsageIndex resources_
The storage for the resource usages.
std::set< std::string > ResourceSet
Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:"...
const ResourceSet & resourcesUsedAtCycle(unsigned cycle) const
std::size_t width() const
Here is the call graph for this function:

◆ operator==()

bool ResourceVector::operator== ( const ResourceVector rightHand) const
virtual

Compares two ResourceVectors.

Parameters
rightHandRight hand operand.
Returns
True is the two vectors match false otherwise.

Definition at line 230 of file ResourceVector.cc.

References toString().

230  {
231 
232  if (toString() != rightHand.toString()) {
233  return false;
234  }
235  return true;
236 }
std::string toString() const
Here is the call graph for this function:

◆ resourcesUsedAtCycle()

const ResourceVector::ResourceSet & ResourceVector::resourcesUsedAtCycle ( unsigned  cycle) const

Returns the set that contains the resources used at the given cycle.

Parameters
cycleThe cycle.
Returns
The set of resources.
Exceptions
OutOfRangeIf the cycle is out of range.

Definition at line 102 of file ResourceVector.cc.

References __func__, and resources_.

Referenced by conflictsWith(), and mergeWith().

102  {
103  if (cycle > resources_.size())
104  throw OutOfRange(__FILE__, __LINE__, __func__);
105  return resources_.at(cycle);
106 }
#define __func__
Definition: Application.hh:67
ResourceUsageIndex resources_
The storage for the resource usages.

◆ shiftLeft()

void ResourceVector::shiftLeft ( )
virtual

Shifts the resource vector one step left, i.e., deletes the first column.

Definition at line 207 of file ResourceVector.cc.

References resources_.

Referenced by ResourceVectorFUResourceConflictDetector::advanceCycle().

207  {
208  if (resources_.size() > 0)
209  resources_.pop_front();
210 }
ResourceUsageIndex resources_
The storage for the resource usages.

◆ toString()

std::string ResourceVector::toString ( ) const

Returns a textual description of the resource vector.

Returns
A string describing the vector.

Definition at line 114 of file ResourceVector.cc.

References resources_, and Conversion::toString().

Referenced by operator==().

114  {
115 
116  std::string theString = "";
117  for (unsigned cycle = 0; cycle < resources_.size(); ++cycle) {
118  theString += std::string("[") + Conversion::toString(cycle) + ":{";
119 
120  const ResourceSet& resSet = resources_.at(cycle);
121  for (ResourceSet::const_iterator i = resSet.begin();
122  i != resSet.end();) {
123  theString += *i;
124  ++i;
125  if (i != resSet.end())
126  theString += ",";
127  }
128  theString += "}]";
129  }
130  return theString;
131 }
ResourceUsageIndex resources_
The storage for the resource usages.
std::set< std::string > ResourceSet
Resources are stored in a set as strings. Normal pipeline resource usages are prefixed with "res:"...
static std::string toString(const T &source)
Here is the call graph for this function:

◆ width()

std::size_t ResourceVector::width ( ) const

Returns the width of the resource vector.

Returns
The width.

Definition at line 139 of file ResourceVector.cc.

References resources_.

Referenced by conflictsWith(), mergeWith(), and ResourceVectorSet::ResourceVectorSet().

139  {
140  return resources_.size();
141 }
ResourceUsageIndex resources_
The storage for the resource usages.

Member Data Documentation

◆ resources_

ResourceUsageIndex ResourceVector::resources_
private

The storage for the resource usages.

Definition at line 82 of file ResourceVector.hh.

Referenced by clear(), conflictsWith(), mergeWith(), resourcesUsedAtCycle(), ResourceVector(), shiftLeft(), toString(), and width().


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