OpenASIP  2.0
Public Member Functions | List of all members
StrictMatchFUEstimator Class Reference
Inheritance diagram for StrictMatchFUEstimator:
Inheritance graph
Collaboration diagram for StrictMatchFUEstimator:
Collaboration graph

Public Member Functions

 StrictMatchFUEstimator (const std::string &name)
 
virtual ~StrictMatchFUEstimator ()
 
 DESCRIPTION ("Simple FU cost estimator plugin that estimates costs of FUs " "simply by looking up direct matches from HDB. In case there's " "no cost data available for the given FU, it's unable to estimate " "it by using linearization etc.")
 
bool estimateArea (const TTAMachine::FunctionUnit &, const IDF::FUImplementationLocation &implementation, AreaInGates &area, HDB::HDBManager &hdb)
 
bool estimatePortWriteDelay (const TTAMachine::FUPort &, const IDF::FUImplementationLocation &implementation, DelayInNanoSeconds &delay, HDB::HDBManager &hdb)
 
bool estimatePortReadDelay (const TTAMachine::FUPort &, const IDF::FUImplementationLocation &implementation, DelayInNanoSeconds &delay, HDB::HDBManager &hdb)
 
bool estimateMaximumComputationDelay (const TTAMachine::FunctionUnit &, const IDF::FUImplementationLocation &implementation, DelayInNanoSeconds &delay, HDB::HDBManager &hdb)
 
virtual bool estimateEnergy (const TTAMachine::FunctionUnit &fu, const IDF::FUImplementationLocation &implementation, const TTAProgram::Program &, const ExecutionTrace &trace, EnergyInMilliJoules &energy, HDB::HDBManager &hdb)
 
- Public Member Functions inherited from CostEstimator::FUCostEstimationPlugin
 FUCostEstimationPlugin (const std::string &name)
 
virtual ~FUCostEstimationPlugin ()
 
- Public Member Functions inherited from CostEstimator::CostEstimationPlugin
 CostEstimationPlugin (const std::string &name)
 
virtual ~CostEstimationPlugin ()
 
virtual std::string name () const
 
virtual std::string description () const
 

Additional Inherited Members

- Protected Attributes inherited from CostEstimator::CostEstimationPlugin
std::string name_
 the name of the plugin class in the HDB; used to identify cost data More...
 

Detailed Description

Definition at line 46 of file StrictMatchFUEstimator.cc.

Constructor & Destructor Documentation

◆ StrictMatchFUEstimator()

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

Definition at line 48 of file StrictMatchFUEstimator.cc.

48  :
50  }

◆ ~StrictMatchFUEstimator()

virtual StrictMatchFUEstimator::~StrictMatchFUEstimator ( )
inlinevirtual

Definition at line 52 of file StrictMatchFUEstimator.cc.

52  {
53  }

Member Function Documentation

◆ DESCRIPTION()

StrictMatchFUEstimator::DESCRIPTION ( "Simple FU cost estimator plugin that estimates costs of FUs " "simply by looking up direct matches from HDB. In case there's " "no cost data available for the given  FU,
it 's unable to estimate " "it by using linearization etc."   
)

◆ estimateArea()

bool StrictMatchFUEstimator::estimateArea ( const TTAMachine::FunctionUnit ,
const IDF::FUImplementationLocation implementation,
AreaInGates area,
HDB::HDBManager hdb 
)
inlinevirtual

Estimates the function unit's area by fetching cost data named 'area' from HDB.

Reimplemented from CostEstimator::FUCostEstimationPlugin.

Definition at line 67 of file StrictMatchFUEstimator.cc.

71  {
72 //#define DEBUG_AREA_ESTIMATION
73  try {
74  // simply fetch the area data of the FU, if any
75  DataObject areaFromDB = hdb.fuCostEstimationData(
76  "area", implementation.id(), name_);
77  area = areaFromDB.doubleValue();
78 #ifdef DEBUG_AREA_ESTIMATION
80  << fu.name() << " area " << area << std::endl;
81 #endif
82  return true;
83  } catch (const KeyNotFound&) {
84  // if no area data found, don't even try to estimate the area
85  // somehow
86  return false;
87  } catch (const Exception& e) {
88  // for example, if doubleValue() conversion failed, then it's
89  // a problem with HDB contents
91  return false;
92  }
93  return false;
94  }

References debugLog, DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fuCostEstimationData(), implementation, and Application::logStream().

Here is the call graph for this function:

◆ estimateEnergy()

virtual bool StrictMatchFUEstimator::estimateEnergy ( const TTAMachine::FunctionUnit fu,
const IDF::FUImplementationLocation implementation,
const TTAProgram::Program ,
const ExecutionTrace trace,
EnergyInMilliJoules energy,
HDB::HDBManager hdb 
)
inlinevirtual

Estimates the energy consumed by given FU.

Estimate is done by computing the sum of all operation execution energies and FU idle energy. Operation execution energies are stored with entries named 'operation_execution_energy operation_name'. The idle energy is in entry named 'fu_idle_energy'.

Reimplemented from CostEstimator::FUCostEstimationPlugin.

Definition at line 208 of file StrictMatchFUEstimator.cc.

214  {
215 
216 //#define DEBUG_ENERGY_ESTIMATION
217  energy = 0.0;
218  ClockCycleCount cyclesWithFUAccess = 0;
219 #ifdef DEBUG_ENERGY_ESTIMATION
221  << "## function unit " << fu.name() << ": " << std::endl;
222 #endif
223  try {
227  const_iterator i = operationTriggers->begin();
228  i != operationTriggers->end(); ++i) {
229 
230  const ExecutionTrace::FUOperationTriggerCount& triggerCount =
231  *i;
232 
233  const ExecutionTrace::OperationID operation =
234  StringTools::stringToLower(triggerCount.get<0>());
235 
237  triggerCount.get<1>();
238 
239  const std::string dataName =
240  std::string("operation_execution_energy ") +
241  operation;
242 
243  try {
244  DataObject energyFromDB = hdb.fuCostEstimationData(
245  dataName, implementation.id(), name_);
246  EnergyInMilliJoules energyOfAccess =
247  energyFromDB.doubleValue()*count;
248 #ifdef DEBUG_ENERGY_ESTIMATION
250  << "## " << operation << " = "
251  << energyFromDB.doubleValue() << " times "
252  << count << " = " << energyOfAccess << std::endl;
253 #endif
254  energy += energyOfAccess;
255  cyclesWithFUAccess += count;
256  } catch (const KeyNotFound&) {
257  // if no data found, don't even try to estimate the energy
258  delete operationTriggers;
259  operationTriggers = NULL;
261  << "Cost estimation data '" << dataName
262  << "' not found in HDB." << std::endl;
263  return false;
264  } catch (const Exception& e) {
265  delete operationTriggers;
266  operationTriggers = NULL;
267  debugLog(e.errorMessage());
268  return false;
269  }
270 
271  }
272  delete operationTriggers;
273  operationTriggers = NULL;
274  } catch (const Exception& e) {
275  debugLog(e.errorMessage());
276  return false;
277  }
278 
279  // add the cost of FU idling
280  const ClockCycleCount idleCycles =
281  trace.simulatedCycleCount() - cyclesWithFUAccess;
282  const std::string dataName = std::string("fu_idle_energy");
283 
284  try {
285  DataObject energyFromDB = hdb.fuCostEstimationData(
286  dataName, implementation.id(), name_);
287  EnergyInMilliJoules idleEnergy =
288  energyFromDB.doubleValue()*idleCycles;
289 #ifdef DEBUG_ENERGY_ESTIMATION
291  << "## idle energy " << energyFromDB.doubleValue() << " times "
292  << idleCycles << " = " << idleEnergy << std::endl;
293 
294 #endif
295  energy += idleEnergy;
296 
297  } catch (const KeyNotFound&) {
298  // if no data found, don't even try to estimate the energy
300  << "Cost estimation data '" << dataName
301  << "' for FU with id " << implementation.id()
302  << " not found in HDB." << std::endl;
303  return false;
304  } catch (const Exception& e) {
305  debugLog(e.errorMessage());
306  return false;
307  }
308 
309  return true;
310  }

References debugLog, DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fuCostEstimationData(), ExecutionTrace::functionUnitOperationTriggerCounts(), implementation, Application::logStream(), TTAMachine::Component::name(), ExecutionTrace::simulatedCycleCount(), StringTools::stringToLower(), and trace.

Here is the call graph for this function:

◆ estimateMaximumComputationDelay()

bool StrictMatchFUEstimator::estimateMaximumComputationDelay ( const TTAMachine::FunctionUnit ,
const IDF::FUImplementationLocation implementation,
DelayInNanoSeconds delay,
HDB::HDBManager hdb 
)
inlinevirtual

Estimates the function unit maximum computation delay by fetching cost data named 'computation_delay' from HDB.

Reimplemented from CostEstimator::FUCostEstimationPlugin.

Definition at line 172 of file StrictMatchFUEstimator.cc.

176  {
177 
178  try {
179  // simply fetch the delay data of the FU port, if any
180  DataObject delayFromDB = hdb.fuCostEstimationData(
181  "computation_delay", implementation.id(), name_);
182  delay = delayFromDB.doubleValue();
183  return true;
184  } catch (const KeyNotFound&) {
185  // if no data found, don't even try to estimate the area
187  << "No computation_delay cost data found for FU "
188  << implementation.id() << ", plugin " << name_ << std::endl;
189  return false;
190  } catch (const Exception& e) {
191  // for example, if doubleValue() conversion failed, then it's
192  // a problem with HDB contents
193  debugLog(e.errorMessage());
194  return false;
195  }
196 
197  return false;
198  }

References debugLog, DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fuCostEstimationData(), implementation, and Application::logStream().

Here is the call graph for this function:

◆ estimatePortReadDelay()

bool StrictMatchFUEstimator::estimatePortReadDelay ( const TTAMachine::FUPort ,
const IDF::FUImplementationLocation implementation,
DelayInNanoSeconds delay,
HDB::HDBManager hdb 
)
inlinevirtual

Estimates the function unit port read delay by fetching cost data named 'output_delay' from HDB.

Assumes that all ports have the same output delay, that is, there is only one 'output_delay' entry for a FU in HDB.

Reimplemented from CostEstimator::FUCostEstimationPlugin.

Definition at line 140 of file StrictMatchFUEstimator.cc.

144  {
145 
146  try {
147  // simply fetch the delay data of the FU port, if any
148  DataObject delayFromDB = hdb.fuCostEstimationData(
149  "output_delay", implementation.id(), name_);
150  delay = delayFromDB.doubleValue();
151  return true;
152  } catch (const KeyNotFound&) {
153  // if no data found, don't even try to estimate the area
155  << "No output_delay cost data found for FU "
156  << implementation.id() << ", plugin " << name_ << std::endl;
157  return false;
158  } catch (const Exception& e) {
159  // for example, if doubleValue() conversion failed, then it's
160  // a problem with HDB contents
161  debugLog(e.errorMessage());
162  return false;
163  }
164 
165  return false;
166  }

References debugLog, DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fuCostEstimationData(), implementation, and Application::logStream().

Here is the call graph for this function:

◆ estimatePortWriteDelay()

bool StrictMatchFUEstimator::estimatePortWriteDelay ( const TTAMachine::FUPort ,
const IDF::FUImplementationLocation implementation,
DelayInNanoSeconds delay,
HDB::HDBManager hdb 
)
inlinevirtual

Estimates the function unit port write delay by fetching cost data named 'input_delay' from HDB.

Assumes that all ports have the same input delay, that is, there is only one 'input_delay' entry for a FU in HDB.

Reimplemented from CostEstimator::FUCostEstimationPlugin.

Definition at line 104 of file StrictMatchFUEstimator.cc.

108  {
109 
110  try {
111  // simply fetch the delay data of the FU port, if any
112  DataObject delayFromDB = hdb.fuCostEstimationData(
113  "input_delay", implementation.id(), name_);
114  delay = delayFromDB.doubleValue();
115  return true;
116  } catch (const KeyNotFound&) {
117  // if no data found, don't even try to estimate the area
119  << "No input_delay cost data found for FU "
120  << implementation.id() << ", plugin " << name_ << std::endl;
121  return false;
122  } catch (const Exception& e) {
123  // for example, if doubleValue() conversion failed, then it's
124  // a problem with HDB contents
125  debugLog(e.errorMessage());
126  return false;
127  }
128 
129  return false;
130  }

References debugLog, DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fuCostEstimationData(), implementation, and Application::logStream().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
ExecutionTrace::OperationTriggerCount
ClockCycleCount OperationTriggerCount
a type for operation trigger counts
Definition: ExecutionTrace.hh:93
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
CostEstimator::CostEstimationPlugin::name
virtual std::string name() const
Definition: CostEstimationPlugin.cc:63
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
DataObject
Definition: DataObject.hh:50
ExecutionTrace::FUOperationTriggerCountList
std::list< FUOperationTriggerCount > FUOperationTriggerCountList
type to be used for lists of function operation execution counts
Definition: ExecutionTrace.hh:116
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
DataObject::doubleValue
virtual double doubleValue() const
Definition: DataObject.cc:386
CostEstimator::EnergyInMilliJoules
double EnergyInMilliJoules
type for consumed energy in milli joules
Definition: CostEstimatorTypes.hh:37
CostEstimator::FUCostEstimationPlugin::FUCostEstimationPlugin
FUCostEstimationPlugin(const std::string &name)
Definition: FUCostEstimationPlugin.cc:44
ExecutionTrace::OperationID
std::string OperationID
a type for storing operation identifiers
Definition: ExecutionTrace.hh:75
Exception
Definition: Exception.hh:54
ExecutionTrace::functionUnitOperationTriggerCounts
FUOperationTriggerCountList * functionUnitOperationTriggerCounts(FunctionUnitID functionUnit) const
Definition: ExecutionTrace.cc:591
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CostEstimator::CostEstimationPlugin::name_
std::string name_
the name of the plugin class in the HDB; used to identify cost data
Definition: CostEstimationPlugin.hh:55
ExecutionTrace::simulatedCycleCount
ClockCycleCount simulatedCycleCount() const
Definition: ExecutionTrace.cc:764
trace
ExecutionTrace * trace
the execution trace database
Definition: EstimatorCmdLineUI.cc:66
HDB::HDBManager::fuCostEstimationData
DataObject fuCostEstimationData(const std::string &valueName, RowID implementationId, const std::string &pluginName) const
Definition: HDBManager.cc:3289
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
KeyNotFound
Definition: Exception.hh:285
ExecutionTrace::FUOperationTriggerCount
boost::tuple< OperationID, OperationTriggerCount > FUOperationTriggerCount
type to be used as a key for storing function unit operation execution counts
Definition: ExecutionTrace.hh:113
debugLog
#define debugLog(text)
Definition: Application.hh:95
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160