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.");
102 addParameter(ccWorseningThresholdPN_,
UINT,
false,
"50",
103 "Limit the reduction when the cycle count "
104 "drops more than this limit (%).");
105 addParameter(allOrNothingPN_,
BOOL,
false,
"true",
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: ";
149 s << origCycles_[appID] <<
" total connections: "
154 std::vector<RowID> result;
159 const int thresholdStep =
160 std::max(maxCcWorseningThreshold_ / 4, (
unsigned)1);
161 for (ccWorseningThreshold_ = maxCcWorseningThreshold_;
162 ccWorseningThreshold_ > 0;
163 ccWorseningThreshold_ =
164 std::max(0, (
int)ccWorseningThreshold_ - thresholdStep)) {
166 s <<
"### Testing max worsening threshold "
167 << ccWorseningThreshold_ <<
"% of "
168 << maxCcWorseningThreshold_ <<
"%";
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 =
185 sweepBypasses(bestFromRFSweep);
186 if (bypassSweepResults.size() == 0)
break;
188 RowID bestFromBPSweep = rfSweepResults.front();
189 result.insert(result.begin(), bestFromBPSweep);
201 db().configuration(startPointConfigurationID);
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);
254 std::list<RowID> newConfs = removeAllConnections(connections, bestConf);
256 if (!allOrNothing_ && newConfs.size() == 0) {
257 verboseLog(
"trying the connections one-by-one\n");
258 removeLeastNecessaryConnections(connections, bestConf);
261 if (newConfs.size() > 0) {
262 bestConf = db().configuration(newConfs.front());
263 for (std::list<RowID>::reverse_iterator i = newConfs.rbegin();
264 i != newConfs.rend(); ++i) {
265 result.insert(result.begin(), *i);
280 db().configuration(startPointConfigurationID);
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);
336 std::list<RowID> newConfs = removeAllConnections(connections, bestConf);
338 if (!allOrNothing_ && newConfs.size() == 0) {
339 verboseLog(
"trying the connections one-by-one\n");
340 removeLeastNecessaryConnections(connections, bestConf);
343 if (newConfs.size() > 0) {
344 bestConf = db().configuration(newConfs.front());
345 for (std::list<RowID>::reverse_iterator i = newConfs.rbegin();
346 i != newConfs.rend(); ++i) {
347 result.insert(result.begin(), *i);
375 readOptionalParameter(
376 ccWorseningThresholdPN_, maxCcWorseningThreshold_);
377 readOptionalParameter(
378 allOrNothingPN_, allOrNothing_);
387 float worsenings = 0.0f;
388 std::set<RowID> appIds = db().applicationIDs();
389 for (std::set<RowID>::const_iterator appI = appIds.begin();
390 appI != appIds.end(); ++appI) {
393 db().configuration(confId);
397 int origCycles = origCycles_[appID];
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();
426 removeConnection(*currentMachine, *conn);
431 RowID confId = db().addConfiguration(conf);
432 conf = db().configuration(confId);
434 bool success = evaluate(conf, estimates,
false);
435 float worsening = averageWorsening(confId);
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));
448 if (worsening <= ccWorseningThreshold_) {
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();
511 removeConnection(mach, *conn);
515 RowID confId = db().addConfiguration(conf);
516 bool success = evaluate(db().configuration(confId));
519 unsigned int avgWorsening =
520 (unsigned)averageWorsening(confId);
521 if (avgWorsening <= ccWorseningThreshold_ &&
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: "
534 db().configuration(confId).architectureID));
539 s <<
"new config: #" << confId <<
" is unschedulable";
543 if (mostUnneededConn != NULL) {
546 bestConf = db().configuration(bestConfInThisIteration);
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: "