70#include "tce_config.h"
97 "Optimizes the IC of the given configuration by removing bus "
98 "connections with least effect to the cycle count first.");
103 "Limit the reduction when the cycle count "
104 "drops more than this limit (%).");
106 "Do not consider single connections. Just try to remove "
107 "all of the bypass or RF connections at once. If fails, "
108 "leave them all. Leads quicker to symmetric reduced "
109 "connectivity machines.");
117 virtual std::vector<RowID>
132 for (std::set<RowID>::const_iterator appI = appIds.begin();
133 appI != appIds.end(); ++appI) {
137 bool success =
evaluate(startConf, estimates,
false);
141 "Could not evaluate the starting point arch.");
148 s <<
"app: " << appID <<
" original cycles: ";
154 std::vector<RowID> result;
159 const int thresholdStep =
166 s <<
"### Testing max worsening threshold "
171 s =
"### Reducing register file and immediate unit connections.";
173 std::list<RowID> rfSweepResults =
174 sweepRFs(startPointConfigurationID);
176 if (rfSweepResults.size() == 0)
break;
178 RowID bestFromRFSweep = rfSweepResults.front();
179 result.insert(result.begin(), bestFromRFSweep);
181 s =
"### Reducing bypass connections.";
184 std::list<RowID> bypassSweepResults =
186 if (bypassSweepResults.size() == 0)
break;
188 RowID bestFromBPSweep = rfSweepResults.front();
189 result.insert(result.begin(), bestFromBPSweep);
208 std::list<RowID> result;
215 std::vector<const TTAMachine::Connection*> connections;
225 for (
int portI = 0; portI < conn.
socket()->portCount();
230 connections.push_back(&conn);
243 for (
int portI = 0; portI < conn.
socket()->portCount();
248 connections.push_back(&conn);
257 verboseLog(
"trying the connections one-by-one\n");
261 if (newConfs.size() > 0) {
263 for (std::list<RowID>::reverse_iterator i = newConfs.rbegin();
264 i != newConfs.rend(); ++i) {
265 result.insert(result.begin(), *i);
286 std::list<RowID> result;
293 std::vector<const TTAMachine::Connection*> connections;
300 bool rfConnection =
false;
305 for (
int portI = 0; portI < conn.
socket()->portCount();
322 for (
int portI = 0; portI < conn.
socket()->portCount();
332 if (!rfConnection) connections.push_back(&conn);
339 verboseLog(
"trying the connections one-by-one\n");
343 if (newConfs.size() > 0) {
345 for (std::list<RowID>::reverse_iterator i = newConfs.rbegin();
346 i != newConfs.rend(); ++i) {
347 result.insert(result.begin(), *i);
387 float worsenings = 0.0f;
389 for (std::set<RowID>::const_iterator appI = appIds.begin();
390 appI != appIds.end(); ++appI) {
400 worsenings += 100.0*(newCycles - origCycles) / origCycles;
402 float avgWorsening = worsenings / appIds.size();
409 std::vector<const TTAMachine::Connection*> connections,
412 std::list<RowID> results;
414#if (!defined(HAVE_CXX11) && !defined(HAVE_CXX0X))
415 std::auto_ptr<TTAMachine::Machine> currentMachine(
418 std::unique_ptr<TTAMachine::Machine> currentMachine(
422 for (std::vector<const TTAMachine::Connection*>::iterator
423 connI = connections.begin(); connI != connections.end();
434 bool success =
evaluate(conf, estimates,
false);
437#if (!defined(HAVE_CXX11) && !defined(HAVE_CXX0X))
438 std::auto_ptr<TTAMachine::Machine> arch
440 db().configuration(confId).architectureID));
442 std::unique_ptr<TTAMachine::Machine> arch
444 db().configuration(confId).architectureID));
449 results.push_back(confId);
451 s <<
"removing all connections was within threshold: #"
452 << confId <<
" avg worsening: ";
453 s << (int)worsening <<
"% " <<
" total connections: "
458 s <<
"removing all connections was not within the "
460 << confId <<
" avg worsening: ";
461 s << (int)worsening <<
"% " <<
" total connections: "
468 s <<
"removing all connections led to unschedulable program\n";
485 std::vector<const TTAMachine::Connection*> connections,
488 std::list<RowID> results;
491 bool couldRemove =
true;
492 while (couldRemove) {
495 float bestAvgccWorsening = 100.0;
498 RowID bestConfInThisIteration = -1;
499 std::vector<const TTAMachine::Connection*>::iterator unneededPos =
502 for (std::vector<const TTAMachine::Connection*>::iterator
503 connI = connections.begin(); connI != connections.end();
516 bool success =
evaluate(
db().configuration(confId));
519 unsigned int avgWorsening =
522 avgWorsening < bestAvgccWorsening) {
523 mostUnneededConn = conn;
524 bestConfInThisIteration = confId;
526 bestAvgccWorsening = avgWorsening;
528 s <<
"new config: #" << bestConfInThisIteration
529 <<
" avg worsening: ";
530 s << (int)bestAvgccWorsening <<
"% "
531 <<
" total connections: "
539 s <<
"new config: #" << confId <<
" is unschedulable";
543 if (mostUnneededConn != NULL) {
548 connections.erase(unneededPos);
549 results.push_front(bestConfInThisIteration);
551 s <<
"best config from this bus sweep: #"
552 << bestConfInThisIteration <<
" avg worsening: ";
553 s << (int)bestAvgccWorsening <<
"% " <<
" total connections: "
#define assert(condition)
int RowID
Type definition of row ID in relational databases.
#define EXPORT_DESIGN_SPACE_EXPLORER_PLUGIN(PLUGIN_NAME__)
std::list< RowID > removeLeastNecessaryConnections(std::vector< const TTAMachine::Connection * > connections, const DSDBManager::MachineConfiguration &startConf)
virtual bool requiresHDB() const
std::list< RowID > sweepBypasses(RowID startPointConfigurationID)
static const std::string ccWorseningThresholdPN_
static const std::string allOrNothingPN_
PLUGIN_DESCRIPTION("Optimizes the IC of the given configuration by removing bus " "connections with least effect to the cycle count first.")
void removeConnection(TTAMachine::Machine &mach, const TTAMachine::Connection &connection)
unsigned int ccWorseningThreshold_
std::list< RowID > sweepRFs(RowID startPointConfigurationID)
virtual bool producesArchitecture() const
std::map< RowID, ClockCycleCount > origCycles_
float averageWorsening(RowID confId)
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &)
std::list< RowID > removeAllConnections(std::vector< const TTAMachine::Connection * > connections, const DSDBManager::MachineConfiguration &startConf)
unsigned int maxCcWorseningThreshold_
virtual bool requiresStartingPointArchitecture() const
virtual bool requiresSimulationData() const
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
ClockCycleCount cycleCount(RowID application, RowID architecture) const
std::set< RowID > applicationIDs() const
MachineConfiguration configuration(RowID id) const
bool hasCycleCount(RowID application, RowID architecture) const
RowID addConfiguration(const MachineConfiguration &conf)
void readOptionalParameter(const std::string paramName, T ¶m) const
void addParameter(TCEString name, ExplorerPluginParameterType type, bool compulsory=true, TCEString defaultValue="", TCEString description="")
virtual DSDBManager & db()
virtual bool evaluate(const DSDBManager::MachineConfiguration &configuration, CostEstimates &results=dummyEstimate_, bool estimate=false)
static int totalConnectionCount(const TTAMachine::Machine &mach)
virtual Segment * segment(int index) const
virtual TCEString name() const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
virtual SocketNavigator socketNavigator() const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
virtual BusNavigator busNavigator() const
Unit * parentUnit() const
void detachSocket(Socket &socket)
const Connection & connection(const Socket &socket) const
int connectionCount() const
Port * port(int index) const