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

#include <ExecutionPipelineResourceTable.hh>

Collaboration diagram for ExecutionPipelineResourceTable:
Collaboration graph

Public Member Functions

unsigned int numberOfResources () const
 
unsigned int pipelineSize () const
 
unsigned int maximalLatency () const
 
bool operationPipeline (int op, int cycle, int res) const
 
int operationIndex (const std::string &opName) const
 
bool hasOperation (const std::string &opName) const
 
const std::map< int, int > & operationLatency (unsigned int operationIndex) const
 
const std::string & name () const
 

Static Public Member Functions

static const ExecutionPipelineResourceTableresourceTable (const TTAMachine::FunctionUnit &fu)
 
static void finalize ()
 

Private Types

typedef std::vector< bool > ResourceVector
 Type for resource vector, represents one cycle of use. More...
 
typedef std::vector< ResourceVectorResourceTable
 Type for resource reservation table, resource vector x latency. More...
 
typedef std::map< const TTAMachine::FunctionUnit *, ExecutionPipelineResourceTable * > ResourceTableMap
 

Private Member Functions

 ExecutionPipelineResourceTable (const TTAMachine::FunctionUnit &fu)
 
void setLatency (const std::string &opName, const int output, const int latency)
 
void setResourceUse (const std::string &opName, const int cycle, const int resIndex)
 

Private Attributes

std::string name_
 
int numberOfResources_
 Resource and ports vector width, depends on particular FU. More...
 
unsigned int maximalLatency_
 Maximal latency of operation in FU. More...
 
std::map< std::string, int > operationSupported_
 Operations supported, name - index to operation pipeline vector. More...
 
std::vector< std::map< int, int > > operationLatencies_
 
std::vector< ResourceTableoperationPipelines_
 Pipelines for operations. More...
 

Static Private Attributes

static ResourceTableMap allResourceTables_
 Contains these tables for all FU's. More...
 

Detailed Description

Definition at line 44 of file ExecutionPipelineResourceTable.hh.

Member Typedef Documentation

◆ ResourceTable

Type for resource reservation table, resource vector x latency.

Definition at line 83 of file ExecutionPipelineResourceTable.hh.

◆ ResourceTableMap

Definition at line 86 of file ExecutionPipelineResourceTable.hh.

◆ ResourceVector

typedef std::vector<bool> ExecutionPipelineResourceTable::ResourceVector
private

Type for resource vector, represents one cycle of use.

Definition at line 80 of file ExecutionPipelineResourceTable.hh.

Constructor & Destructor Documentation

◆ ExecutionPipelineResourceTable()

ExecutionPipelineResourceTable::ExecutionPipelineResourceTable ( const TTAMachine::FunctionUnit fu)
private

Definition at line 50 of file ExecutionPipelineResourceTable.cc.

51  :
52  name_(fu.name()),
55 
56  for (int j = 0; j < fu.operationCount(); j++) {
57  HWOperation& hwop = *fu.operation(j);
58  ExecutionPipeline* ep = hwop.pipeline();
59  std::string opName = StringTools::stringToUpper(
60  fu.operation(j)->name());
61 
62  for (int l = 0; l < ep->latency(); l++ ) {
63  for (int k = 0; k < fu.pipelineElementCount(); k++) {
64  PipelineElement *pe = fu.pipelineElement(k);
65  if (ep->isResourceUsed(pe->name(),l)){
66  setResourceUse(opName, l, k);
67  }
68  }
69  for (int k = 0; k < fu.operationPortCount(); k++) {
70  TTAMachine::FUPort* fuPort = fu.operationPort(k);
71  if (ep->isPortWritten(*fuPort,l)) {
73  opName, l,fu.pipelineElementCount()+k);
74  }
75  if (ep->isPortRead(*fuPort,l)) {
77  opName, -1, fu.pipelineElementCount()+k);
78  }
79  }
80  }
81 
82  // set operation latencies
83  ExecutionPipeline::OperandSet writes = ep->writtenOperands();
84  for (ExecutionPipeline::OperandSet::iterator iter =
85  writes.begin(); iter != writes.end(); iter++) {
86  int index = *iter;
87  int latency = hwop.latency(index);
88  setLatency(opName, index, latency);
89  }
90  }
91 }

References TTAMachine::ExecutionPipeline::isPortRead(), TTAMachine::ExecutionPipeline::isPortWritten(), TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::HWOperation::latency(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::PipelineElement::name(), TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), TTAMachine::HWOperation::pipeline(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), setLatency(), setResourceUse(), StringTools::stringToUpper(), and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by resourceTable().

Here is the call graph for this function:

Member Function Documentation

◆ finalize()

void ExecutionPipelineResourceTable::finalize ( )
static

Delete all the resource tables. This can be called after scheduling is done, when resource managers are longer used.

Definition at line 185 of file ExecutionPipelineResourceTable.cc.

References allResourceTables_, and MapTools::deleteAllValues().

Referenced by SimpleResourceManager::disposeRM().

Here is the call graph for this function:

◆ hasOperation()

bool ExecutionPipelineResourceTable::hasOperation ( const std::string &  opName) const
inline

◆ maximalLatency()

unsigned int ExecutionPipelineResourceTable::maximalLatency ( ) const
inline

◆ name()

const std::string& ExecutionPipelineResourceTable::name ( ) const
inline

◆ numberOfResources()

unsigned int ExecutionPipelineResourceTable::numberOfResources ( ) const
inline

◆ operationIndex()

int ExecutionPipelineResourceTable::operationIndex ( const std::string &  opName) const
inline

◆ operationLatency()

const std::map<int,int>& ExecutionPipelineResourceTable::operationLatency ( unsigned int  operationIndex) const
inline

◆ operationPipeline()

bool ExecutionPipelineResourceTable::operationPipeline ( int  op,
int  cycle,
int  res 
) const
inline

◆ pipelineSize()

unsigned int ExecutionPipelineResourceTable::pipelineSize ( ) const
inline

◆ resourceTable()

const ExecutionPipelineResourceTable & ExecutionPipelineResourceTable::resourceTable ( const TTAMachine::FunctionUnit fu)
static

Gives an resource table for given FU. If no existing found, creates a new one.

Parameters
fufunction unit whose resource table we are asking for.

Definition at line 164 of file ExecutionPipelineResourceTable.cc.

165  {
166 
167  ResourceTableMap::iterator i = allResourceTables_.find(&fu);
168 
169  if (i != allResourceTables_.end()) {
170  return *i->second;
171  }
172 
173  ExecutionPipelineResourceTable* newTable =
175  allResourceTables_[&fu] = newTable;
176  return *newTable;
177 }

References allResourceTables_, and ExecutionPipelineResourceTable().

Here is the call graph for this function:

◆ setLatency()

void ExecutionPipelineResourceTable::setLatency ( const std::string &  opName,
const int  output,
const int  latency 
)
private

Sets latency of an output of an operation. The resource usage of the operation has to be set before calling this.

Parameters
opNameoperation to set the latency
outputindex of the output operand(stating from numberofinputoperand, not 0/1)
latencylatency of the output of the operation

Definition at line 139 of file ExecutionPipelineResourceTable.cc.

142  {
143 
145  ResourceTable newOp(maximalLatency_, std::vector<bool>(0, false));
146  operationPipelines_.push_back(newOp);
147  operationSupported_[opName] = operationPipelines_.size() - 1;
148  }
149 
150  int pIndex = MapTools::valueForKey<int>(operationSupported_, opName);
151  while (static_cast<int>(operationLatencies_.size()) <= pIndex) {
152  operationLatencies_.push_back(std::map<int,int>());
153  }
154  operationLatencies_[pIndex][output] = latency;
155 }

References MapTools::containsKey(), maximalLatency_, operationLatencies_, operationPipelines_, and operationSupported_.

Referenced by ExecutionPipelineResourceTable().

Here is the call graph for this function:

◆ setResourceUse()

void ExecutionPipelineResourceTable::setResourceUse ( const std::string &  opName,
const int  cycle,
const int  resIndex 
)
private

Sets usage of resource/port to true for given cycle and resource number and particular pipeline.

Parameters
opNameName of operation to set resource for
cycleCycle in which to set usage
indexIndex of resource/port in resource vector

Definition at line 102 of file ExecutionPipelineResourceTable.cc.

105  {
106 
107  if (cycle > (signed)maximalLatency_) {
108  throw InvalidData(__FILE__, __LINE__, __func__,
109  "Trying to set resource use to cycle out of scope of "
110  "FU pipeline!");
111  }
112  if (resIndex >= numberOfResources_ || resIndex < 0){
113  throw InvalidData(__FILE__, __LINE__, __func__,
114  "Trying to set resource use for resource out of scope of "
115  "FU pipeline!");
116  }
117 
119  ResourceTable newOp(
120  maximalLatency_, std::vector<bool>(numberOfResources_, false));
121  operationPipelines_.push_back(newOp);
122  operationSupported_[opName] = operationPipelines_.size() - 1;
123  }
124  int pIndex = MapTools::valueForKey<int>(operationSupported_, opName);
125  if(cycle > -1) {
126  operationPipelines_[pIndex][cycle][resIndex] = true;
127  }
128 }

References __func__, MapTools::containsKey(), maximalLatency_, numberOfResources_, operationPipelines_, and operationSupported_.

Referenced by ExecutionPipelineResourceTable().

Here is the call graph for this function:

Member Data Documentation

◆ allResourceTables_

ExecutionPipelineResourceTable::ResourceTableMap ExecutionPipelineResourceTable::allResourceTables_
staticprivate

Contains these tables for all FU's.

Definition at line 100 of file ExecutionPipelineResourceTable.hh.

Referenced by finalize(), and resourceTable().

◆ maximalLatency_

unsigned int ExecutionPipelineResourceTable::maximalLatency_
private

Maximal latency of operation in FU.

Definition at line 91 of file ExecutionPipelineResourceTable.hh.

Referenced by setLatency(), and setResourceUse().

◆ name_

std::string ExecutionPipelineResourceTable::name_
private

Definition at line 77 of file ExecutionPipelineResourceTable.hh.

◆ numberOfResources_

int ExecutionPipelineResourceTable::numberOfResources_
private

Resource and ports vector width, depends on particular FU.

Definition at line 89 of file ExecutionPipelineResourceTable.hh.

Referenced by setResourceUse().

◆ operationLatencies_

std::vector<std::map<int,int> > ExecutionPipelineResourceTable::operationLatencies_
private

Definition at line 95 of file ExecutionPipelineResourceTable.hh.

Referenced by setLatency().

◆ operationPipelines_

std::vector<ResourceTable> ExecutionPipelineResourceTable::operationPipelines_
private

Pipelines for operations.

Definition at line 97 of file ExecutionPipelineResourceTable.hh.

Referenced by setLatency(), and setResourceUse().

◆ operationSupported_

std::map<std::string, int> ExecutionPipelineResourceTable::operationSupported_
private

Operations supported, name - index to operation pipeline vector.

Definition at line 93 of file ExecutionPipelineResourceTable.hh.

Referenced by setLatency(), and setResourceUse().


The documentation for this class was generated from the following files:
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ExecutionPipelineResourceTable::operationLatencies_
std::vector< std::map< int, int > > operationLatencies_
Definition: ExecutionPipelineResourceTable.hh:95
TTAMachine::HWOperation
Definition: HWOperation.hh:52
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
ExecutionPipelineResourceTable::setResourceUse
void setResourceUse(const std::string &opName, const int cycle, const int resIndex)
Definition: ExecutionPipelineResourceTable.cc:102
ExecutionPipelineResourceTable::ExecutionPipelineResourceTable
ExecutionPipelineResourceTable(const TTAMachine::FunctionUnit &fu)
Definition: ExecutionPipelineResourceTable.cc:50
TTAMachine::ExecutionPipeline::writtenOperands
OperandSet writtenOperands(int cycle) const
Definition: ExecutionPipeline.cc:429
TTAMachine::PipelineElement::name
const std::string & name() const
TTAMachine::FunctionUnit::maxLatency
virtual int maxLatency() const
Definition: FunctionUnit.cc:443
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
TTAMachine::FUPort
Definition: FUPort.hh:46
ExecutionPipelineResourceTable::allResourceTables_
static ResourceTableMap allResourceTables_
Contains these tables for all FU's.
Definition: ExecutionPipelineResourceTable.hh:100
ExecutionPipelineResourceTable::name_
std::string name_
Definition: ExecutionPipelineResourceTable.hh:77
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
InvalidData
Definition: Exception.hh:149
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
ExecutionPipelineResourceTable::maximalLatency_
unsigned int maximalLatency_
Maximal latency of operation in FU.
Definition: ExecutionPipelineResourceTable.hh:91
TTAMachine::ExecutionPipeline::isPortWritten
bool isPortWritten(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:386
__func__
#define __func__
Definition: Application.hh:67
ExecutionPipelineResourceTable::ResourceTable
std::vector< ResourceVector > ResourceTable
Type for resource reservation table, resource vector x latency.
Definition: ExecutionPipelineResourceTable.hh:83
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
ExecutionPipelineResourceTable::numberOfResources_
int numberOfResources_
Resource and ports vector width, depends on particular FU.
Definition: ExecutionPipelineResourceTable.hh:89
TTAMachine::FunctionUnit::operationPortCount
virtual int operationPortCount() const
Definition: FunctionUnit.cc:182
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
TTAMachine::ExecutionPipeline::isPortRead
bool isPortRead(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:362
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
ExecutionPipelineResourceTable::operationPipelines_
std::vector< ResourceTable > operationPipelines_
Pipelines for operations.
Definition: ExecutionPipelineResourceTable.hh:97
TTAMachine::PipelineElement
Definition: PipelineElement.hh:46
ExecutionPipelineResourceTable::setLatency
void setLatency(const std::string &opName, const int output, const int latency)
Definition: ExecutionPipelineResourceTable.cc:139
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
ExecutionPipelineResourceTable::operationSupported_
std::map< std::string, int > operationSupported_
Operations supported, name - index to operation pipeline vector.
Definition: ExecutionPipelineResourceTable.hh:93
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
ExecutionPipelineResourceTable
Definition: ExecutionPipelineResourceTable.hh:44
TTAMachine::ExecutionPipeline::latency
int latency() const
Definition: ExecutionPipeline.cc:482
TTAMachine::ExecutionPipeline::isResourceUsed
bool isResourceUsed(const std::string &name, int cycle) const
Definition: ExecutionPipeline.cc:300