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

Classes

struct  ICParameters
 

Public Member Functions

 DefaultICDecoderEstimator (const std::string &name)
 
virtual ~DefaultICDecoderEstimator ()
 
virtual bool estimateICDelayOfPath (HDB::HDBRegistry &hdbRegistry, const TransportPath &path, const IDF::MachineImplementation &machineImplementation, const IDF::SocketImplementationLocation &, const IDF::BusImplementationLocation &, const IDF::SocketImplementationLocation &, DelayInNanoSeconds &delay)
 
virtual bool estimateICArea (HDB::HDBRegistry &hdbRegistry, const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation, AreaInGates &area)
 
virtual bool estimateICEnergy (HDB::HDBRegistry &hdbRegistry, const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation, const TTAProgram::Program &, const ExecutionTrace &traceDB, EnergyInMilliJoules &energy)
 
- Public Member Functions inherited from CostEstimator::ICDecoderEstimatorPlugin
 ICDecoderEstimatorPlugin (const std::string &name)
 
virtual ~ICDecoderEstimatorPlugin ()
 
virtual TTAMachine::ControlUnitgenerateControlUnit ()
 
- 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::vector< ICParametersFanInFanOutCombinationSet
 

Private Member Functions

DelayInNanoSeconds delayOfSocket (HDB::HDBManager &hdb, const TTAMachine::Socket &socket)
 
DelayInNanoSeconds delayOfBus (HDB::HDBManager &hdb, const TTAMachine::Bus &bus)
 
DelayInNanoSeconds delayOfSocket (HDB::HDBRegistry &hdbRegistry, const IDF::SocketImplementationLocation &implementation)
 
DelayInNanoSeconds delayOfBus (HDB::HDBRegistry &hdbRegistry, const IDF::BusImplementationLocation &implementation)
 
DataObject valueFromKeyValuePairString (const std::string &keyName, const std::string &keyValuePairString)
 
FanInFanOutCombinationSet generateFanInFanOutCombinations (std::vector< std::size_t > &inputWidths, std::vector< std::size_t > &outputWidths)
 
FanInFanOutCombinationSet socketParameters (const TTAMachine::Socket &socket)
 
FanInFanOutCombinationSet busParameters (const TTAMachine::Bus &bus)
 

Private Attributes

std::set< std::string > missingComponents_
 Set for component names that are missing from HDB.
 

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

The default IC&decoder cost estimation plugin.

Definition at line 124 of file DefaultICDecoderPlugin.cc.

Member Typedef Documentation

◆ FanInFanOutCombinationSet

Definition at line 725 of file DefaultICDecoderPlugin.cc.

Constructor & Destructor Documentation

◆ DefaultICDecoderEstimator()

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

Constructor.

Parameters
nameThe name of this plugin.
dataSourceThe HDB used to fetch cost estimation data.

Definition at line 133 of file DefaultICDecoderPlugin.cc.

◆ ~DefaultICDecoderEstimator()

virtual DefaultICDecoderEstimator::~DefaultICDecoderEstimator ( )
inlinevirtual

Destructor.

Definition at line 141 of file DefaultICDecoderPlugin.cc.

141 {
142 }

Member Function Documentation

◆ busParameters()

FanInFanOutCombinationSet DefaultICDecoderEstimator::busParameters ( const TTAMachine::Bus bus)
inlineprivate

Generates fanin/fanout/width combinations to a bus.

Parameters
busBus which parameters are generated.
Returns
Set of fanin/fanout/width combinations.

Definition at line 862 of file DefaultICDecoderPlugin.cc.

863 {
864
865 std::vector<std::size_t> inputWidths;
866 std::vector<std::size_t> outputWidths;
867
869 bus.machine()->socketNavigator();
870 for (int i = 0; i < socketNav.count(); ++i) {
871 const TTAMachine::Socket& socket = *socketNav.item(i);
872 if (bus.isConnectedTo(socket)) {
873 std::size_t width = 0;
874 for (int port = 0; port < socket.portCount(); port++) {
875 if (static_cast<unsigned int>(
876 socket.port(port)->width()) > width) {
877 width = socket.port(port)->width();
878 }
879 }
880 if (width == 0) {
881 continue;
882 }
883 if (socket.direction() == TTAMachine::Socket::OUTPUT) {
884 inputWidths.push_back(width);
885 } else {
886 outputWidths.push_back(width);
887 }
888 }
889 }
890
891 return generateFanInFanOutCombinations(inputWidths, outputWidths);
892 }
FanInFanOutCombinationSet generateFanInFanOutCombinations(std::vector< std::size_t > &inputWidths, std::vector< std::size_t > &outputWidths)
virtual bool isConnectedTo(const Socket &socket) const
Definition Bus.cc:303
virtual Machine * machine() const
ComponentType * item(int index) const
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368
virtual int width() const =0
@ OUTPUT
Data goes from port to bus.
Definition Socket.hh:60
Direction direction() const
Port * port(int index) const
Definition Socket.cc:266
int portCount() const

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Socket::direction(), generateFanInFanOutCombinations(), TTAMachine::Bus::isConnectedTo(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Socket::OUTPUT, TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), TTAMachine::Machine::socketNavigator(), and TTAMachine::Port::width().

Referenced by delayOfBus(), estimateICArea(), and estimateICEnergy().

Here is the call graph for this function:

◆ delayOfBus() [1/2]

DelayInNanoSeconds DefaultICDecoderEstimator::delayOfBus ( HDB::HDBManager hdb,
const TTAMachine::Bus bus 
)
inlineprivate

Finds out the delay of the given bus.

Definition at line 583 of file DefaultICDecoderPlugin.cc.

583 {
584 DelayInNanoSeconds delay = 0;
585 std::string busName = "";
586 try {
587 FanInFanOutCombinationSet parameterSet = busParameters(bus);
588 // bus fanin, fanout and data width is added to name string
589 FanInFanOutCombinationSet::const_iterator iter =
590 parameterSet.begin();
591 for (; iter != parameterSet.end(); iter++) {
592 busName = "sub_bus " +
593 Conversion::toString((*iter).fanIn) + " " +
594 Conversion::toString((*iter).fanOut) + " " +
595 Conversion::toString((*iter).dataWidth);
596
597 try {
598 DataObject subbusData =
599 hdb.costEstimationDataValue(busName, name());
600
602 "throughput_delay",
603 subbusData.stringValue()).doubleValue();
604 } catch (const KeyNotFound& e) {
605 std::set<std::string>::iterator iter =
606 missingComponents_.find("tdelay" + busName);
607 if (iter == missingComponents_.end()) {
608 std::cerr << "Warning: Could not get throughput delay "
609 << "data for '"
610 << busName << "' from HDB: "
611 << hdb.fileName() << ". This value is "
612 << "not counted to total." << std::endl;
613 missingComponents_.insert("tdelay" + busName);
614 }
615 }
616 }
617 } catch (const Exception& e) {
618 throw Exception(
619 __FILE__, __LINE__, __func__,
620 std::string("Cannot fetch bus delay data '") +
621 busName + "'." + e.errorMessage());
622 }
623 return delay;
624 }
#define __func__
static std::string toString(const T &source)
virtual std::string stringValue() const
virtual double doubleValue() const
std::vector< ICParameters > FanInFanOutCombinationSet
FanInFanOutCombinationSet busParameters(const TTAMachine::Bus &bus)
std::set< std::string > missingComponents_
Set for component names that are missing from HDB.
DataObject valueFromKeyValuePairString(const std::string &keyName, const std::string &keyValuePairString)
std::string errorMessage() const
Definition Exception.cc:123
std::string fileName() const
virtual DataObject costEstimationDataValue(const std::string &valueName, const std::string &pluginName) const
double DelayInNanoSeconds
type for propagation delays in nano seconds

References __func__, busParameters(), HDB::HDBManager::costEstimationDataValue(), DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fileName(), missingComponents_, CostEstimator::CostEstimationPlugin::name(), DataObject::stringValue(), Conversion::toString(), and valueFromKeyValuePairString().

Referenced by estimateICDelayOfPath().

Here is the call graph for this function:

◆ delayOfBus() [2/2]

DelayInNanoSeconds DefaultICDecoderEstimator::delayOfBus ( HDB::HDBRegistry hdbRegistry,
const IDF::BusImplementationLocation implementation 
)
inlineprivate

Finds out the delay of the given bus.

Definition at line 666 of file DefaultICDecoderPlugin.cc.

668 {
669 // First fetch the id of the 'delay_subbus_reference' of the
670 // socket. The id is used to fetch the subbus data which carries
671 // the delay data.
672 int implementationId = implementation.id();
673
674 HDB::HDBManager& hdb = hdbRegistry.hdb(implementation.hdbFile());
675
676 try {
677 return hdb.busCostEstimationData(
678 "throughput_delay", implementationId, name_).doubleValue();
679
680 } catch (const Exception& e) {
681 throw Exception(
682 __FILE__, __LINE__, __func__,
683 std::string("Cannot fetch bus delay data. ") +
684 e.errorMessage());
685 }
686 }
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
std::string name_
the name of the plugin class in the HDB; used to identify cost data
DataObject busCostEstimationData(const std::string &valueName, RowID busID, const std::string &pluginName) const
CachedHDBManager & hdb(const std::string fileName)

References __func__, HDB::HDBManager::busCostEstimationData(), DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBRegistry::hdb(), implementation, and CostEstimator::CostEstimationPlugin::name_.

Here is the call graph for this function:

◆ delayOfSocket() [1/2]

DelayInNanoSeconds DefaultICDecoderEstimator::delayOfSocket ( HDB::HDBManager hdb,
const TTAMachine::Socket socket 
)
inlineprivate

Finds out the delay of the given socket.

Definition at line 522 of file DefaultICDecoderPlugin.cc.

522 {
523 DelayInNanoSeconds delay = 0;
524 std::string socketName = "";
525 try {
526 if (socket.direction() == TTAMachine::Socket::INPUT) {
527 socketName = "input_sub_socket";
528 } else if (socket.direction() == TTAMachine::Socket::OUTPUT) {
529 socketName = "output_sub_socket";
530 } else {
531 // Socket direction is unknown, should never be
532 assert(false);
533 }
534
535 FanInFanOutCombinationSet parameterSet =
536 socketParameters(socket);
537 // socket fanin, fanout and data width is added to name string
538 FanInFanOutCombinationSet::const_iterator iter =
539 parameterSet.begin();
540 std::string socketNameCopy = socketName;
541 for (; iter != parameterSet.end(); iter++) {
542 socketName = socketNameCopy + " " +
543 Conversion::toString((*iter).fanIn) + " " +
544 Conversion::toString((*iter).fanOut) + " " +
545 Conversion::toString((*iter).dataWidth);
546 if (socket.direction() == TTAMachine::Socket::INPUT &&
547 (*iter).fanIn == 1 && (*iter).fanOut == 1) {
548 // input socket 1 1 * --> no delay
549 return 0;
550 }
551 try {
552 DataObject subsocketData =
553 hdb.costEstimationDataValue(socketName, name());
555 "throughput_delay",
556 subsocketData.stringValue()).doubleValue();
557 } catch (const KeyNotFound& e) {
558 std::set<std::string>::iterator iter =
559 missingComponents_.find("tdelay" + socketName);
560 if (iter == missingComponents_.end()) {
561 std::cerr << "Warning: Could not get throughput delay "
562 << "data for '"
563 << socketName << "' from HDB: "
564 << hdb.fileName() << ". This value is "
565 << "not counted to total." << std::endl;
566 missingComponents_.insert("tdelay" + socketName);
567 }
568 }
569 }
570 } catch (const Exception& e) {
571 throw Exception(
572 __FILE__, __LINE__, __func__,
573 std::string("Cannot fetch socket delay data '") +
574 socketName + "'." + e.errorMessage());
575 }
576 return delay;
577 }
#define assert(condition)
FanInFanOutCombinationSet socketParameters(const TTAMachine::Socket &socket)
@ INPUT
Data goes from bus to port.
Definition Socket.hh:59

References __func__, assert, HDB::HDBManager::costEstimationDataValue(), TTAMachine::Socket::direction(), DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fileName(), TTAMachine::Socket::INPUT, missingComponents_, CostEstimator::CostEstimationPlugin::name(), TTAMachine::Socket::OUTPUT, socketParameters(), DataObject::stringValue(), Conversion::toString(), and valueFromKeyValuePairString().

Referenced by estimateICDelayOfPath().

Here is the call graph for this function:

◆ delayOfSocket() [2/2]

DelayInNanoSeconds DefaultICDecoderEstimator::delayOfSocket ( HDB::HDBRegistry hdbRegistry,
const IDF::SocketImplementationLocation implementation 
)
inlineprivate

Finds out the delay of the given socket.

Not used with current implementation.

Definition at line 632 of file DefaultICDecoderPlugin.cc.

634 {
635 // First fetch the id of the 'delay_subsocket_reference' of the
636 // socket. The id is used to fetch the subsocket data which carries
637 // the delay data.
638 int implementationId = implementation.id();
639
640 HDB::HDBManager& hdb = hdbRegistry.hdb(implementation.hdbFile());
641
642 std::string entry = "delay_subsocket_reference";
643
644 try {
645 DataObject subsocketReference =
646 hdb.socketCostEstimationData(entry, implementationId, name_);
647
648 int entryId = subsocketReference.integerValue();
649
650 entry = std::string("id=") + Conversion::toString(entryId);
651 DataObject subsocketData = hdb.costEstimationDataValue(entryId);
653 "throughput_delay", subsocketData.stringValue()).doubleValue();
654 } catch (const Exception& e) {
655 throw Exception(
656 __FILE__, __LINE__, __func__,
657 std::string("Cannot fetch socket delay data '") +
658 entry + "'." + e.errorMessage());
659 }
660 }
virtual int integerValue() const
DataObject socketCostEstimationData(const std::string &valueName, RowID socketID, const std::string &pluginName) const

References __func__, HDB::HDBManager::costEstimationDataValue(), DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBRegistry::hdb(), implementation, DataObject::integerValue(), CostEstimator::CostEstimationPlugin::name_, HDB::HDBManager::socketCostEstimationData(), DataObject::stringValue(), Conversion::toString(), and valueFromKeyValuePairString().

Here is the call graph for this function:

◆ estimateICArea()

virtual bool DefaultICDecoderEstimator::estimateICArea ( HDB::HDBRegistry hdbRegistry,
const TTAMachine::Machine machine,
const IDF::MachineImplementation machineImplementation,
AreaInGates area 
)
inlinevirtual

Estimates the area of an IC path.

The default implementation estimates the area by summing up areas of of all subcomponents of sockets and buses in the machine. Subcomponent data is entered by user to HDB before estimation. The estimation algorithm does not figure out the subcomponents, it only sums up the c costs of all subcomponents of a machine part. Subcomponent is a fanin/fanout combination included in a component. There can be multiple such combinations due to different widths in inputs and outputs.

The subcomponent data is fetched from HDB by first fetching all subcomponent ids of the machine part by looking for entries named 'subsocket_reference' or 'subbus_reference'. The values of these entries are identifiers of subsocket entries in the cost table. Each subsocket entry has a string of name/value pairs as their value. The cost data is stored in the name/value string. The cost data string must be in the following format: 'throughput_delay=53 area=5.2 active_energy=3 idle_energy=3 control_delay=3'

Todo:
each socket may have own HDB associated to their implementation location object
Todo:
each bus may have own HDB associated to their implementation location object

Reimplemented from CostEstimator::ICDecoderEstimatorPlugin.

Definition at line 220 of file DefaultICDecoderPlugin.cc.

224 {
225 area = 0;
226
227//#define DEBUG_AREA_ESTIMATION
228
229 std::string socketName = "";
230 try {
231 /// @todo each socket may have own HDB associated to their
232 /// implementation location object
233 HDB::HDBManager& hdb =
234 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
237 for (int i = 0; i < socketNav.count(); ++i) {
238 const TTAMachine::Socket& socket = *socketNav.item(i);
239 socketName = "";
240 if (socket.direction() == TTAMachine::Socket::INPUT) {
241 socketName = "input_sub_socket";
242 } else if (socket.direction() == TTAMachine::Socket::OUTPUT) {
243 socketName = "output_sub_socket";
244 } else {
245 // Socket direction is unknown
246 // No need to estimate, since it will not be used.
247 continue;
248 }
249
250 FanInFanOutCombinationSet parameterSet =
251 socketParameters(socket);
252 // socket fanin, fanout and data width is added to name string
253 FanInFanOutCombinationSet::const_iterator iter =
254 parameterSet.begin();
255 std::string socketNameCopy = socketName;
256 for (; iter != parameterSet.end(); iter++) {
257 socketName = socketNameCopy + " " +
258 Conversion::toString((*iter).fanIn) + " " +
259 Conversion::toString((*iter).fanOut) + " " +
260 Conversion::toString((*iter).dataWidth);
261 try {
262 DataObject subsocketData =
263 hdb.costEstimationDataValue(socketName, name());
265 "area", subsocketData.stringValue()).doubleValue();
266 } catch (const KeyNotFound& e) {
267 std::set<std::string>::iterator iter =
268 missingComponents_.find("area" + socketName);
269 if (iter == missingComponents_.end()) {
270 std::cerr << "Warning: Could not get area data "
271 << "for '"
272 << socketName << "' from HDB: "
273 << hdb.fileName() << ". Area of this "
274 << "socket not counted to total."
275 << std::endl;
276 missingComponents_.insert("area" + socketName);
277 }
278 }
279 }
280 }
281 } catch (const Exception& e) {
282 HDB::HDBManager& hdb =
283 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
284 debugLog(
285 std::string("Could not get socket area data '") +
286 socketName + "' from HDB: " + hdb.fileName() +
287 e.errorMessage());
288 return false;
289 }
290
291 std::string busName = "";
292 try {
293 /// @todo each bus may have own HDB associated to their
294 /// implementation location object
295 HDB::HDBManager& hdb =
296 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
299 for (int i = 0; i < busNav.count(); ++i) {
300 const TTAMachine::Bus& bus = *busNav.item(i);
301
302 FanInFanOutCombinationSet parameterSet = busParameters(bus);
303 // bus fanin, fanout and data width is added to name string
304 FanInFanOutCombinationSet::const_iterator iter =
305 parameterSet.begin();
306 for (; iter != parameterSet.end(); iter++) {
307 busName = "sub_bus " +
308 Conversion::toString((*iter).fanIn) + " " +
309 Conversion::toString((*iter).fanOut) + " " +
310 Conversion::toString((*iter).dataWidth);
311 try {
312 DataObject subbusData =
313 hdb.costEstimationDataValue(busName, name());
315 "area", subbusData.stringValue()).doubleValue();
316 } catch (const KeyNotFound& e) {
317 std::set<std::string>::iterator iter =
318 missingComponents_.find("area" + busName);
319 if (iter == missingComponents_.end()) {
320 std::cerr << "Warning: Could not get area data "
321 << "for '"
322 << busName << "' from HDB: "
323 << hdb.fileName() << ". Area of this "
324 << "bus not counted to total."
325 << std::endl;
326 missingComponents_.insert("area" + busName);
327 }
328 }
329 }
330 }
331 } catch (const Exception& e) {
332 HDB::HDBManager& hdb =
333 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
334 debugLog(
335 std::string("Could not get bus area data '") +
336 busName + "' from HDB. " + hdb.fileName() +
337 e.errorMessage());
338 return false;
339 }
340
341 return true;
342 }
#define debugLog(text)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

References TTAMachine::Machine::busNavigator(), busParameters(), HDB::HDBManager::costEstimationDataValue(), TTAMachine::Machine::Navigator< ComponentType >::count(), debugLog, TTAMachine::Socket::direction(), DataObject::doubleValue(), Exception::errorMessage(), HDB::HDBManager::fileName(), HDB::HDBRegistry::hdb(), IDF::MachineImplementation::icDecoderHDB(), TTAMachine::Socket::INPUT, TTAMachine::Machine::Navigator< ComponentType >::item(), machine, missingComponents_, CostEstimator::CostEstimationPlugin::name(), TTAMachine::Socket::OUTPUT, TTAMachine::Machine::socketNavigator(), socketParameters(), DataObject::stringValue(), Conversion::toString(), and valueFromKeyValuePairString().

Here is the call graph for this function:

◆ estimateICDelayOfPath()

virtual bool DefaultICDecoderEstimator::estimateICDelayOfPath ( HDB::HDBRegistry hdbRegistry,
const TransportPath path,
const IDF::MachineImplementation machineImplementation,
const IDF::SocketImplementationLocation ,
const IDF::BusImplementationLocation ,
const IDF::SocketImplementationLocation ,
DelayInNanoSeconds delay 
)
inlinevirtual

Estimates the delay of an IC path.

The default implementation estimates the delays by summing up delays of the subcomponent of the machine part that is registered to be the 'delay component'. In practice, an entry named 'delay_subsocket_reference' or 'delay_subbus_reference' is first fetched from HDB. The entry pointed to by the fetched entry contains the delay data for the socket/bus at hand.

Parameters
pathTransport path of which delay is estimated.
machineImplementationImplementation of the machine.
sourceSocketImplementationNot used.
busImplementationNot used.
destinationSocketImplementationNot used.
delayResult delay of the transport path.
Returns
True if the estimation succeeded.

Reimplemented from CostEstimator::ICDecoderEstimatorPlugin.

Definition at line 163 of file DefaultICDecoderPlugin.cc.

170 {
171//#define DEBUG_DELAY_ESTIMATION
172 try {
173 HDB::HDBManager& hdb =
174 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
175 DelayInNanoSeconds sourceDelay =
176 delayOfSocket(hdb, path.sourceSocket());
177 DelayInNanoSeconds destinationDelay =
178 delayOfSocket(hdb, path.destinationSocket());
179 DelayInNanoSeconds busDelay = delayOfBus(hdb, path.bus());
180 delay = sourceDelay + busDelay + destinationDelay;
181
182#ifdef DEBUG_DELAY_ESTIMATION
183 std::cout
184 << "path: {" << path.sourceSocket().name()
185 << "," << path.bus().name() << ","
186 << path.destinationSocket().name() << "} "
187 << "delays={" << sourceDelay << "," << busDelay << ","
188 << destinationDelay << "} = " << delay << std::endl;
189#endif
190 return true;
191 } catch (const Exception& e) {
193 return false;
194 }
195
196 return false;
197 }
const TTAMachine::Bus & bus() const
const TTAMachine::Socket & sourceSocket() const
const TTAMachine::Socket & destinationSocket() const
DelayInNanoSeconds delayOfSocket(HDB::HDBManager &hdb, const TTAMachine::Socket &socket)
DelayInNanoSeconds delayOfBus(HDB::HDBManager &hdb, const TTAMachine::Bus &bus)
virtual TCEString name() const

References CostEstimator::TransportPath::bus(), debugLog, delayOfBus(), delayOfSocket(), CostEstimator::TransportPath::destinationSocket(), Exception::errorMessage(), HDB::HDBRegistry::hdb(), IDF::MachineImplementation::icDecoderHDB(), TTAMachine::Component::name(), and CostEstimator::TransportPath::sourceSocket().

Here is the call graph for this function:

◆ estimateICEnergy()

virtual bool DefaultICDecoderEstimator::estimateICEnergy ( HDB::HDBRegistry hdbRegistry,
const TTAMachine::Machine machine,
const IDF::MachineImplementation machineImplementation,
const TTAProgram::Program ,
const ExecutionTrace traceDB,
EnergyInMilliJoules energy 
)
inlinevirtual

Estimates the energy consumed by IC.

The default implementation estimates the area by summing up energies of of all subcomponents of sockets and buses. For more information, see the comment of the area estimation function.

Reimplemented from CostEstimator::ICDecoderEstimatorPlugin.

Definition at line 351 of file DefaultICDecoderPlugin.cc.

357 {
358
359//#define DEBUG_ENERGY_ESTIMATION
360
361 energy = 0.0;
362
363 ClockCycleCount totalCycles = traceDB.simulatedCycleCount();
364
365 std::string socketName = "";
366 try {
367 HDB::HDBManager& hdb =
368 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
371 for (int i = 0; i < socketNav.count(); ++i) {
372 const TTAMachine::Socket& socket = *socketNav.item(i);
373 socketName = "";
374 if (socket.direction() == TTAMachine::Socket::INPUT) {
375 socketName = "input_sub_socket";
376 } else if (socket.direction() == TTAMachine::Socket::OUTPUT) {
377 socketName = "output_sub_socket";
378 } else {
379 // Socket direction is unknown
380 // No need to estimate, since it will not be used.
381 continue;
382 }
383
384 FanInFanOutCombinationSet parameterSet =
385 socketParameters(socket);
386 // socket fanin, fanout and data width is added to name string
387 FanInFanOutCombinationSet::const_iterator iter =
388 parameterSet.begin();
389 std::string socketNameCopy = socketName;
390 for (; iter != parameterSet.end(); iter++) {
391 socketName = socketNameCopy + " " +
392 Conversion::toString((*iter).fanIn) + " " +
393 Conversion::toString((*iter).fanOut) + " " +
394 Conversion::toString((*iter).dataWidth);
395 DataObject subsocketData =
396 hdb.costEstimationDataValue(socketName, name());
397
398 // sum the active and idle energies of all subsockets
399 // multiplied with write and idle clock counts,
400 // respectively
401 EnergyInMilliJoules idleEnergy =
403 "idle_energy", subsocketData.stringValue()).
404 doubleValue();
405 EnergyInMilliJoules activeEnergy =
407 "active_energy", subsocketData.stringValue()).
408 doubleValue();
409
410 ClockCycleCount activeCycles =
411 traceDB.socketWriteCount(socket.name());
412
413 EnergyInMilliJoules totalActiveEnergy =
414 activeEnergy*activeCycles;
415
416 ClockCycleCount idleCycles = totalCycles - activeCycles;
417
418 EnergyInMilliJoules totalIdleEnergy =
419 idleEnergy*idleCycles;
420
421 EnergyInMilliJoules totalEnergy =
422 totalIdleEnergy + totalActiveEnergy;
423 energy += totalEnergy;
424#ifdef DEBUG_ENERGY_ESTIMATION
425 std::cout
426 << "socket " << socket.name() << ", subsocket "
427 << socketName << ": "
428 << "active energy = " << activeEnergy
429 << " mJ/cycle * " << activeCycles << " cycle = "
430 << totalActiveEnergy << ", "
431 << "idle energy = " << idleEnergy
432 << " mJ/cycle * " << idleCycles << " cycle = "
433 << totalIdleEnergy << " TOTAL = " << totalEnergy
434 << std::endl;
435#endif
436 }
437 }
438 } catch (const Exception& e) {
439 debugLog(
440 std::string("Could not get socket area data '") +
441 socketName + "' from HDB. " + e.errorMessage());
442 return false;
443 }
444 std::string busName = "";
445 try {
446 HDB::HDBManager& hdb =
447 hdbRegistry.hdb(machineImplementation.icDecoderHDB());
449 for (int i = 0; i < busNav.count(); ++i) {
450 const TTAMachine::Bus& bus = *busNav.item(i);
451
452 FanInFanOutCombinationSet parameterSet = busParameters(bus);
453 // bus fanin, fanout and data width is added to name string
454 FanInFanOutCombinationSet::const_iterator iter =
455 parameterSet.begin();
456 for (; iter != parameterSet.end(); iter++) {
457 busName = "sub_bus " +
458 Conversion::toString((*iter).fanIn) + " " +
459 Conversion::toString((*iter).fanOut) + " " +
460 Conversion::toString((*iter).dataWidth);
461 DataObject subbusData =
462 hdb.costEstimationDataValue(busName, name());
463
464 // sum the active and idle energies of all subbuses
465 // multiplied with write and idle clock counts,
466 // respectively
467 EnergyInMilliJoules idleEnergy =
469 "idle_energy", subbusData.stringValue()).
470 doubleValue();
471 EnergyInMilliJoules activeEnergy =
473 "active_energy", subbusData.stringValue()).
474 doubleValue();
475
476 ClockCycleCount activeCycles =
477 traceDB.busWriteCount(bus.name());
478
479 EnergyInMilliJoules totalActiveEnergy =
480 activeEnergy*activeCycles;
481
482 ClockCycleCount idleCycles = totalCycles - activeCycles;
483
484 EnergyInMilliJoules totalIdleEnergy =
485 idleEnergy*idleCycles;
486
487 EnergyInMilliJoules totalEnergy =
488 totalIdleEnergy + totalActiveEnergy;
489 energy += totalEnergy;
490#ifdef DEBUG_ENERGY_ESTIMATION
491 std::cout
492 << "bus " << bus.name() << ", subbus "
493 << busName << ": "
494 << "active energy = " << activeEnergy
495 << " mJ/cycle * " << activeCycles << " cycle = "
496 << totalActiveEnergy << ", "
497 << "idle energy = " << idleEnergy
498 << " mJ/cycle * " << idleCycles << " cycle = "
499 << totalIdleEnergy << " TOTAL = " << totalEnergy
500 << std::endl;
501#endif
502 }
503 }
504 } catch (const Exception& e) {
505 debugLog(
506 std::string("Could not get bus energy data '") + busName +
507 "' from HDB. " + e.errorMessage());
508 return false;
509 }
510 return true;
511 }
CycleCount ClockCycleCount
Alias for ClockCycleCount.
ClockCycleCount simulatedCycleCount() const
ClockCycleCount socketWriteCount(SocketID socket) const
ClockCycleCount busWriteCount(BusID bus) const
double EnergyInMilliJoules
type for consumed energy in milli joules

References TTAMachine::Machine::busNavigator(), busParameters(), ExecutionTrace::busWriteCount(), HDB::HDBManager::costEstimationDataValue(), TTAMachine::Machine::Navigator< ComponentType >::count(), debugLog, TTAMachine::Socket::direction(), Exception::errorMessage(), HDB::HDBRegistry::hdb(), IDF::MachineImplementation::icDecoderHDB(), TTAMachine::Socket::INPUT, TTAMachine::Machine::Navigator< ComponentType >::item(), machine, CostEstimator::CostEstimationPlugin::name(), TTAMachine::Component::name(), TTAMachine::Socket::OUTPUT, ExecutionTrace::simulatedCycleCount(), TTAMachine::Machine::socketNavigator(), socketParameters(), ExecutionTrace::socketWriteCount(), DataObject::stringValue(), Conversion::toString(), and valueFromKeyValuePairString().

Here is the call graph for this function:

◆ generateFanInFanOutCombinations()

FanInFanOutCombinationSet DefaultICDecoderEstimator::generateFanInFanOutCombinations ( std::vector< std::size_t > &  inputWidths,
std::vector< std::size_t > &  outputWidths 
)
inlineprivate

Generates all possible fanin/fanout/data width combinations (subcomponents) for given input and output widths.

Parameters
inputWidthsSet containing component's input widths.
outputWidthsSet containing component's output widths.
Returns
Set of fanin/fanout/data width combinations.

Definition at line 736 of file DefaultICDecoderPlugin.cc.

738 {
739
740 std::sort(inputWidths.begin(), inputWidths.end());
741 std::sort(outputWidths.begin(), outputWidths.end());
742
743 std::set<std::size_t> allWidthsTemp;
744 std::copy(
745 inputWidths.begin(), inputWidths.end(),
746 std::insert_iterator<std::set<std::size_t> >(
747 allWidthsTemp, allWidthsTemp.begin()));
748 std::copy(
749 outputWidths.begin(), outputWidths.end(),
750 std::insert_iterator<std::set<std::size_t> >(
751 allWidthsTemp, allWidthsTemp.begin()));
752 std::vector<std::size_t> allWidths;
753 std::copy(
754 allWidthsTemp.begin(), allWidthsTemp.end(),
755 std::insert_iterator<std::vector<std::size_t> >(
756 allWidths, allWidths.begin()));
757
758
759 FanInFanOutCombinationSet combinations;
760 for (std::vector<std::size_t>::iterator i = allWidths.begin();
761 i != allWidths.end(); ++i) {
762
763 const unsigned int width = *i;
764
765 // how many input widths fits in the current width?
766 std::size_t fanIn = 0;
767 for (unsigned int n = 0; n < inputWidths.size(); n++) {
768 // we can do a trick like this because the vector is ordered
769 if (width > inputWidths.at(n) && inputWidths.at(n) > 0)
770 break;
771 if (inputWidths.at(n) != 0) {
772 fanIn++;
773 }
774 }
775
776 // how many output widths fits in the current width?
777 std::size_t fanOut = 0;
778 for (unsigned int n = 0; n < outputWidths.size(); n++) {
779 // we can do a trick like this because the vector is ordered
780 if (width > outputWidths.at(n) && outputWidths.at(n) > 0)
781 break;
782 if (outputWidths.at(n) != 0) {
783 fanOut++;
784 }
785 }
786
787 if (fanIn == 0 || fanOut == 0)
788 return combinations; //continue;
789 ICParameters parameters;
790 parameters.fanIn = fanIn;
791 parameters.fanOut = fanOut;
792 parameters.dataWidth = width;
793 combinations.push_back(parameters);
794
795 for (unsigned int n = 0; n < inputWidths.size(); n++) {
796 if (inputWidths.at(n) > width) {
797 inputWidths.at(n) = inputWidths.at(n) - width;
798 } else {
799 inputWidths.at(n) = 0;
800 }
801 }
802 for (unsigned int n = 0; n < outputWidths.size(); n++) {
803 if (outputWidths.at(n) > width) {
804 outputWidths.at(n) = outputWidths.at(n) - width;
805 } else {
806 outputWidths.at(n) = 0;
807 }
808 }
809
810 for (unsigned int n = 0; n < allWidths.size(); n++) {
811 if (allWidths.at(n) > width) {
812 allWidths.at(n) = allWidths.at(n) - width;
813 } else {
814 allWidths.at(n) = 0;
815 }
816 }
817
818 }
819
820 return combinations;
821 }

References DefaultICDecoderEstimator::ICParameters::dataWidth, DefaultICDecoderEstimator::ICParameters::fanIn, and DefaultICDecoderEstimator::ICParameters::fanOut.

Referenced by busParameters(), and socketParameters().

◆ socketParameters()

FanInFanOutCombinationSet DefaultICDecoderEstimator::socketParameters ( const TTAMachine::Socket socket)
inlineprivate

Generates fanin/fanout/width combinations to a socket.

Parameters
socketSocket which parameters are generated.
Returns
Set of fanin/fanout/width combinations.

Definition at line 831 of file DefaultICDecoderPlugin.cc.

832 {
833
834 std::vector<std::size_t> inputWidths;
835 std::vector<std::size_t> outputWidths;
836
837 if (socket.direction() == TTAMachine::Socket::INPUT) {
838 for (int i = 0; i < socket.segmentCount(); i++) {
839 inputWidths.push_back(socket.segment(i)->parentBus()->width());
840 }
841 for (int i = 0; i < socket.portCount(); i++) {
842 outputWidths.push_back(socket.port(i)->width());
843 }
844 } else if (socket.direction() == TTAMachine::Socket::OUTPUT) {
845 for (int i = 0; i < socket.segmentCount(); i++) {
846 outputWidths.push_back(socket.segment(i)->parentBus()->width());
847 }
848 for (int i = 0; i < socket.portCount(); i++) {
849 inputWidths.push_back(socket.port(i)->width());
850 }
851 }
852 return generateFanInFanOutCombinations(inputWidths, outputWidths);
853 }
int width() const
Definition Bus.cc:149
Bus * parentBus() const
Segment * segment(int index) const
Definition Socket.cc:401
int segmentCount() const

References TTAMachine::Socket::direction(), generateFanInFanOutCombinations(), TTAMachine::Socket::INPUT, TTAMachine::Socket::OUTPUT, TTAMachine::Segment::parentBus(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), TTAMachine::Socket::segment(), TTAMachine::Socket::segmentCount(), TTAMachine::Bus::width(), and TTAMachine::Port::width().

Referenced by delayOfSocket(), estimateICArea(), and estimateICEnergy().

Here is the call graph for this function:

◆ valueFromKeyValuePairString()

DataObject DefaultICDecoderEstimator::valueFromKeyValuePairString ( const std::string &  keyName,
const std::string &  keyValuePairString 
)
inlineprivate

Parses a string of key-value pairs and returns a value with given key.

The string must be in format "key1=value1 key2=value2" etc. the value must not have spaces in it.

Parameters
keyNameThe key of the value to fetch from the string.
keyValuePairStringThe key-value pair string to parse.
Returns
The value.
Exceptions
KeyNotFoundIn case the key was not found in the string.

Definition at line 701 of file DefaultICDecoderPlugin.cc.

702 {
703 boost::smatch parsed;
704 boost::regex regexp(
705 (boost::format("(.*)(%s)=([^\\s]*)(.*)") % keyName).str());
706 if (!regex_match(keyValuePairString, parsed, regexp)) {
707 throw KeyNotFound(
708 __FILE__, __LINE__, __func__,
709 "Key not found in value string.");
710 } else {
711 if (parsed.size() < 3)
712 throw KeyNotFound(__FILE__, __LINE__, __func__);
713 DataObject data;
714 data.setString(parsed[3]);
715 return data;
716 }
717 }
virtual void setString(std::string value)

References __func__, and DataObject::setString().

Referenced by delayOfBus(), delayOfSocket(), delayOfSocket(), estimateICArea(), and estimateICEnergy().

Here is the call graph for this function:

Member Data Documentation

◆ missingComponents_

std::set<std::string> DefaultICDecoderEstimator::missingComponents_
private

Set for component names that are missing from HDB.

Definition at line 516 of file DefaultICDecoderPlugin.cc.

Referenced by delayOfBus(), delayOfSocket(), and estimateICArea().


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