OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
InterpolatingFUEstimator Class Reference
Inheritance diagram for InterpolatingFUEstimator:
Inheritance graph
Collaboration diagram for InterpolatingFUEstimator:
Collaboration graph

Public Member Functions

 InterpolatingFUEstimator (const std::string &name)
 
virtual ~InterpolatingFUEstimator ()
 
 DESCRIPTION ("FU cost estimator plugin that estimates costs of FUs by generating" "cost database from cost values of HDB and uses interpolation to " "estimate the costs. In case there's no cost data available for the " "given FU the plugin interpolates the estimate if possible.")
 
bool estimateArea (const TTAMachine::FunctionUnit &fu, const IDF::FUImplementationLocation &, AreaInGates &area, HDB::HDBManager &hdb)
 
bool estimatePortWriteDelay (const TTAMachine::FUPort &port, const IDF::FUImplementationLocation &, DelayInNanoSeconds &delay, HDB::HDBManager &hdb)
 
bool estimatePortReadDelay (const TTAMachine::FUPort &port, const IDF::FUImplementationLocation &, DelayInNanoSeconds &delay, HDB::HDBManager &hdb)
 
bool estimateMaximumComputationDelay (const TTAMachine::FunctionUnit &fu, const IDF::FUImplementationLocation &, 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
 

Private Types

typedef std::map< const EntryKeyProperty *, CostDBTypes::MatchTypeTableMatchTypeMap
 Search type for each entry type.
 

Private Member Functions

void initializeEstimator (const HDBManager &hdb)
 
void createSearchTypes ()
 
CostDBTypes::EntryTable createSearch (const FunctionUnit &fu) const
 

Private Attributes

CostDatabaseRegistrycostDatabaseRegistry_
 Registry of cost databases.
 
CostDatabasecostdb_
 Cost database being used.
 
SearchStrategystrategy_
 Search strategy to be used with the cost database.
 
EntryKeyPropertyunitProperty_
 Entry key property of function unit.
 
MatchTypeMap searchTypes_
 Types of matches used for searching entries from the cost database.
 
CostDBTypes::MatchTypeTable unitMatchType_
 Table of types of match.
 

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
 

Detailed Description

Definition at line 62 of file InterpolatingFUEstimator.cc.

Member Typedef Documentation

◆ MatchTypeMap

Search type for each entry type.

Definition at line 408 of file InterpolatingFUEstimator.cc.

Constructor & Destructor Documentation

◆ InterpolatingFUEstimator()

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

Definition at line 64 of file InterpolatingFUEstimator.cc.

References costDatabaseRegistry_, and CostDatabaseRegistry::instance().

Here is the call graph for this function:

◆ ~InterpolatingFUEstimator()

virtual InterpolatingFUEstimator::~InterpolatingFUEstimator ( )
inlinevirtual

Definition at line 69 of file InterpolatingFUEstimator.cc.

69 {
70 }

Member Function Documentation

◆ createSearch()

CostDBTypes::EntryTable InterpolatingFUEstimator::createSearch ( const FunctionUnit fu) const
inlineprivate

Creates a search to cost database to find entries matching the given function unit.

Parameters
fuFunction unit which matches are searched.
Returns
Returns entries that matched the function unit.

Definition at line 453 of file InterpolatingFUEstimator.cc.

453 {
454
456 int ports = fu.operationPortCount();
457 int width = 0;
458 for (int n = 0; n < ports; n++) {
459 BaseFUPort* port = fu.port(n);
460 if (dynamic_cast<FUPort*>(port) != NULL) {
461 FUPort* fuPort = dynamic_cast<FUPort*>(port);
462 if (width == 0) {
463 width = fuPort->width();
464 } else if (width != fuPort->width()) {
465 return results;
466 }
467 }
468 }
470 searchKey->addField(
471 new EntryKeyField(
472 new EntryKeyDataInt(width),
474 searchKey->addField(
475 new EntryKeyField(
478 // Perform a database query.
479 try {
480 results = costdb_->search(*searchKey, unitMatchType_);
481 } catch (Exception& e) {
482 // no results
483 delete searchKey;
484 searchKey = 0;
485 throw e;
486 }
487 delete searchKey;
488 searchKey = 0;
489
490 return results;
491}
void addField(EntryKeyField *field)
static const std::string EKF_FUNCTION_UNIT
Field type for function unit entry;.
std::vector< CostDBEntry * > EntryTable
Table of database entries.
static const std::string EKF_BIT_WIDTH
Field type for bit width of an entry.
CostDBTypes::EntryTable search(const CostDBEntryKey &searchKey, const CostDBTypes::MatchTypeTable &match) const
EntryKeyFieldProperty * fieldProperty(std::string field) const
CostDatabase * costdb_
Cost database being used.
EntryKeyProperty * unitProperty_
Entry key property of function unit.
CostDBTypes::MatchTypeTable unitMatchType_
Table of types of match.
virtual int width() const
virtual int operationPortCount() const
virtual BaseFUPort * port(const std::string &name) const

References CostDBEntryKey::addField(), costdb_, CostDBTypes::EKF_BIT_WIDTH, CostDBTypes::EKF_FUNCTION_UNIT, EntryKeyProperty::fieldProperty(), TTAMachine::FunctionUnit::operationPortCount(), TTAMachine::FunctionUnit::port(), CostDatabase::search(), unitMatchType_, unitProperty_, and TTAMachine::BaseFUPort::width().

Referenced by estimateArea(), estimateEnergy(), estimateMaximumComputationDelay(), estimatePortReadDelay(), and estimatePortWriteDelay().

Here is the call graph for this function:

◆ createSearchTypes()

void InterpolatingFUEstimator::createSearchTypes ( )
inlineprivate

◆ DESCRIPTION()

InterpolatingFUEstimator::DESCRIPTION ( "FU cost estimator plugin that estimates costs of FUs by generating" "cost database from cost values of HDB and uses interpolation to " "estimate the costs. In case there's no cost data available for the " "given FU the plugin interpolates the estimate if possible."  )

◆ estimateArea()

bool InterpolatingFUEstimator::estimateArea ( const TTAMachine::FunctionUnit fu,
const IDF::FUImplementationLocation ,
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 84 of file InterpolatingFUEstimator.cc.

88 {
89
90//#define DEBUG_AREA_ESTIMATION
91 try {
94 CostDBTypes::EntryTable::const_iterator i = results.begin();
95 area = 0.0;
96 // worst case area is returned
97 for (;i < results.end(); i++) {
98 for (int n = 0; n < (*i)->statisticsCount(); n++) {
99 if (area < (*i)->statistics(n).area()) {
100 area = (*i)->statistics(n).area();
101 }
102 }
103 }
104 } catch (Exception& e) {
105 return false;
106 }
107#ifdef DEBUG_AREA_ESTIMATION
109 << fu.name() << " area " << area << std::endl;
110#endif
111 return true;
112 }
static std::ostream & logStream()
void initializeEstimator(const HDBManager &hdb)
CostDBTypes::EntryTable createSearch(const FunctionUnit &fu) const
virtual TCEString name() const

References createSearch(), initializeEstimator(), Application::logStream(), and TTAMachine::Component::name().

Here is the call graph for this function:

◆ estimateEnergy()

virtual bool InterpolatingFUEstimator::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 263 of file InterpolatingFUEstimator.cc.

269 {
270
271//#define DEBUG_ENERGY_ESTIMATION
272 try {
275
276 energy = 0.0;
277 ClockCycleCount cyclesWithFUAccess = 0;
278#ifdef DEBUG_ENERGY_ESTIMATION
280 << "## function unit " << fu.name() << ": " << std::endl;
281#endif
285 const_iterator i = operationTriggers->begin();
286 i != operationTriggers->end(); ++i) {
287
288 const ExecutionTrace::FUOperationTriggerCount& triggerCount =
289 *i;
290
291 const ExecutionTrace::OperationID operation =
292 StringTools::stringToLower(triggerCount.get<0>());
293
295 triggerCount.get<1>();
296
297 const std::string dataName =
298 std::string("operation_execution_energy ") + operation;
299
300 try {
301 CostDBTypes::EntryTable::const_iterator i = results.begin();
302 for (;i < results.end(); i++) {
303
304 // in case there are multiple operation execution
305 // energies, select the worst case in the result
306 // @todo ensure that multiple results is not a bug
307 EnergyInMilliJoules tempEnergy = 0.0;
308 for (int n = 0; n < (*i)->statisticsCount(); n++) {
309 if (((*i)->statistics(n).energyOperation(
310 operation) * count) > tempEnergy) {
311
312 tempEnergy +=
313 (*i)->statistics(n).energyOperation(
314 operation) * count;
315 }
316#ifdef DEBUG_ENERGY_ESTIMATION
317 if (n > 0) {
319 << " NOTE: Multiple fu execution energy"
320 << " results found!"
321 << " operation: " << operation
322 << " "
323 << (*i)->statistics(n).energyOperation(
324 operation)
325 << std::endl;
326 }
327#endif
328 }
329 energy += tempEnergy;
330 }
331 cyclesWithFUAccess += count;
332 } catch (const KeyNotFound&) {
333 // if no data found, don't even try to estimate the area
334 delete operationTriggers;
335 operationTriggers = NULL;
337 << "Cost estimation data '" << dataName
338 << "' not found in HDB." << std::endl;
339 return false;
340 } catch (const Exception& e) {
341 delete operationTriggers;
342 operationTriggers = NULL;
344 return false;
345 }
346
347 }
348 delete operationTriggers;
349 operationTriggers = NULL;
350
351 // add the cost of FU idling
352 const ClockCycleCount idleCycles =
353 trace.simulatedCycleCount() - cyclesWithFUAccess;
354 const std::string dataName = std::string("fu_idle_energy");
355
356 try {
357 CostDBTypes::EntryTable::const_iterator i = results.begin();
358 for (;i < results.end(); i++) {
359
360 // in case there are multiple fu idle energies,
361 // select the worst case in the result
362 // @todo ensure that multiple results is not a bug
363 EnergyInMilliJoules tempEnergy = 0.0;
364 for (int n = 0; n < (*i)->statisticsCount(); n++) {
365 if (((*i)->statistics(n).energyIdle() * idleCycles) >
366 tempEnergy) {
367
368 tempEnergy =
369 (*i)->statistics(n).energyIdle() * idleCycles;
370 }
371#ifdef DEBUG_ENERGY_ESTIMATION
372 if (n > 0) {
374 << " NOTE: Multiple fu idle energy results found!"
375 << (*i)->statistics(n).energyIdle()
376 << std::endl;
377 }
378#endif
379 }
380 energy += tempEnergy;
381 }
382 } catch (const KeyNotFound&) {
383 // if no data found, don't even try to estimate the area
385 << "Cost estimation data '" << dataName
386 << "' for FU with id " << implementation.id()
387 << " not found in HDB." << std::endl;
388 return false;
389 }
390 } catch (const Exception& e) {
392 return false;
393 }
394
395 return true;
396 }
#define debugLog(text)
ExecutionTrace * trace
the execution trace database
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
CycleCount ClockCycleCount
Alias for ClockCycleCount.
std::string errorMessage() const
Definition Exception.cc:123
std::string OperationID
a type for storing operation identifiers
ClockCycleCount OperationTriggerCount
a type for operation trigger counts
ClockCycleCount simulatedCycleCount() const
std::list< FUOperationTriggerCount > FUOperationTriggerCountList
type to be used for lists of function operation execution counts
FUOperationTriggerCountList * functionUnitOperationTriggerCounts(FunctionUnitID functionUnit) const
boost::tuple< OperationID, OperationTriggerCount > FUOperationTriggerCount
type to be used as a key for storing function unit operation execution counts
static std::string stringToLower(const std::string &source)
double EnergyInMilliJoules
type for consumed energy in milli joules

References createSearch(), debugLog, Exception::errorMessage(), ExecutionTrace::functionUnitOperationTriggerCounts(), implementation, initializeEstimator(), Application::logStream(), TTAMachine::Component::name(), ExecutionTrace::simulatedCycleCount(), StringTools::stringToLower(), and trace.

Here is the call graph for this function:

◆ estimateMaximumComputationDelay()

bool InterpolatingFUEstimator::estimateMaximumComputationDelay ( const TTAMachine::FunctionUnit fu,
const IDF::FUImplementationLocation ,
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 226 of file InterpolatingFUEstimator.cc.

230 {
231
232//#define DEBUG_DELAY_ESTIMATION
233 try {
236 CostDBTypes::EntryTable::const_iterator i = results.begin();
237 delay = 0.0;
238 // the worst case is returned if found multiple results
239 for (;i < results.end(); i++) {
240 for (int n = 0; n < (*i)->statisticsCount(); n++) {
241 if (delay < (*i)->statistics(n).delay()) {
242 delay = (*i)->statistics(n).delay();
243 }
244 }
245 }
246 } catch (Exception& e) {
247 return false;
248 }
249#ifdef DEBUG_DELAY_ESTIMATION
251 << fu.name() << " computation delay " << delay << std::endl;
252#endif // DEBUG_DELAY_ESTIMATION
253 return true;
254 }

References createSearch(), initializeEstimator(), Application::logStream(), and TTAMachine::Component::name().

Here is the call graph for this function:

◆ estimatePortReadDelay()

bool InterpolatingFUEstimator::estimatePortReadDelay ( const TTAMachine::FUPort port,
const IDF::FUImplementationLocation ,
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 177 of file InterpolatingFUEstimator.cc.

181 {
182
183//#define DEBUG_DELAY_ESTIMATION
184 try {
187 CostDBTypes::EntryTable::const_iterator i = results.begin();
188 delay = 0.0;
189 // worst case delay is returned
190 for (;i < results.end(); i++) {
191 for (int n = 0; n < (*i)->statisticsCount(); n++) {
192#ifndef UNIQUE_PORT_DELAY
193 if (delay < (*i)->statistics(n).delayPort("output_delay")) {
194 delay = (*i)->statistics(n).delayPort("output_delay");
195 }
196#endif // UNIQUE_PORT_DELAY
197#ifdef UNIQUE_PORT_DELAY
198 // this one is used if defferent ports of an unit
199 // can have different delays
200 if (delay < (*i)->statistics(n).delayPort(port.name())) {
201 delay = (*i)->statistics(n).delayPort(port.name());
202 }
203#endif // UNIQUE_PORT_DELAY
204 }
205 }
206 } catch (Exception& e) {
207#ifdef DEBUG_DELAY_ESTIMATION
208 Application::logStream() << "No input_delay data for function "
209 << "unit "
210 << port.parentUnit()->name()
211 << " found in HDB." << std::endl;
212#endif // DEBUG_DELAY_ESTIMATION
213 return false;
214 }
215#ifdef DEBUG_DELAY_ESTIMATION
217 << port.name() << " (port) delay " << delay << std::endl;
218#endif // DEBUG_DELAY_ESTIMATION
219 return true;
220 }
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
virtual std::string name() const
Definition Port.cc:141

References createSearch(), initializeEstimator(), Application::logStream(), TTAMachine::Component::name(), TTAMachine::Port::name(), and TTAMachine::BaseFUPort::parentUnit().

Here is the call graph for this function:

◆ estimatePortWriteDelay()

bool InterpolatingFUEstimator::estimatePortWriteDelay ( const TTAMachine::FUPort port,
const IDF::FUImplementationLocation ,
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 122 of file InterpolatingFUEstimator.cc.

126 {
127
128//#define DEBUG_DELAY_ESTIMATION
129
130 try {
133
134 CostDBTypes::EntryTable::const_iterator i = results.begin();
135 delay = 0.0;
136 // worst case delay is returned
137 for (;i < results.end(); i++) {
138 for (int n = 0; n < (*i)->statisticsCount(); n++) {
139#ifndef UNIQUE_PORT_DELAY
140 if (delay < (*i)->statistics(n).delayPort("input_delay")) {
141 delay = (*i)->statistics(n).delayPort("input_delay");
142 }
143#endif // UNIQUE_PORT_DELAY
144#ifdef UNIQUE_PORT_DELAY
145 // this one is used if defferent ports of an unit
146 // can have different delays
147 if (delay < (*i)->statistics(n).delayPort(port.name())) {
148 delay = (*i)->statistics(n).delayPort(port.name());
149 }
150#endif // UNIQUE_PORT_DELAY
151 }
152 }
153 } catch (Exception& e) {
154#ifdef DEBUG_DELAY_ESTIMATION
155 Application::logStream() << "No input_delay data for function "
156 << "unit "
157 << port.parentUnit()->name()
158 << " found in HDB." << std::endl;
159#endif // DEBUG_DELAY_ESTIMATION
160 return false;
161 }
162#ifdef DEBUG_DELAY_ESTIMATION
164 << port.name() << " (port) delay " << delay << std::endl;
165#endif
166 return true;
167 }

References createSearch(), initializeEstimator(), Application::logStream(), TTAMachine::Component::name(), TTAMachine::Port::name(), and TTAMachine::BaseFUPort::parentUnit().

Here is the call graph for this function:

◆ initializeEstimator()

void InterpolatingFUEstimator::initializeEstimator ( const HDBManager hdb)
inlineprivate

Initializes the plugin.

Parameters
hdbThe HDB to be used in searching entries. Cost database is created in basis of this HDB.

Definition at line 421 of file InterpolatingFUEstimator.cc.

421 {
422
424 strategy_ = new FilterSearch();
428}
static const std::string EK_UNIT
Entry type for function units.
CostDatabase & costDatabase(const HDB::HDBManager &hdb)
void setSearchStrategy(SearchStrategy *strategy)
static EntryKeyProperty * find(std::string type)
SearchStrategy * strategy_
Search strategy to be used with the cost database.

References CostDatabaseRegistry::costDatabase(), costDatabaseRegistry_, costdb_, createSearchTypes(), CostDBTypes::EK_UNIT, EntryKeyProperty::find(), CostDatabase::setSearchStrategy(), strategy_, and unitProperty_.

Referenced by estimateArea(), estimateEnergy(), estimateMaximumComputationDelay(), estimatePortReadDelay(), and estimatePortWriteDelay().

Here is the call graph for this function:

Member Data Documentation

◆ costDatabaseRegistry_

CostDatabaseRegistry* InterpolatingFUEstimator::costDatabaseRegistry_
private

Registry of cost databases.

Definition at line 399 of file InterpolatingFUEstimator.cc.

Referenced by initializeEstimator(), and InterpolatingFUEstimator().

◆ costdb_

CostDatabase* InterpolatingFUEstimator::costdb_
private

Cost database being used.

Definition at line 401 of file InterpolatingFUEstimator.cc.

Referenced by createSearch(), and initializeEstimator().

◆ searchTypes_

MatchTypeMap InterpolatingFUEstimator::searchTypes_
private

Types of matches used for searching entries from the cost database.

Definition at line 410 of file InterpolatingFUEstimator.cc.

◆ strategy_

SearchStrategy* InterpolatingFUEstimator::strategy_
private

Search strategy to be used with the cost database.

Definition at line 403 of file InterpolatingFUEstimator.cc.

Referenced by initializeEstimator().

◆ unitMatchType_

CostDBTypes::MatchTypeTable InterpolatingFUEstimator::unitMatchType_
private

Table of types of match.

Definition at line 412 of file InterpolatingFUEstimator.cc.

Referenced by createSearch(), and createSearchTypes().

◆ unitProperty_

EntryKeyProperty* InterpolatingFUEstimator::unitProperty_
private

Entry key property of function unit.

Definition at line 405 of file InterpolatingFUEstimator.cc.

Referenced by createSearch(), createSearchTypes(), and initializeEstimator().


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