Skip to content

Commit

Permalink
sync with dac2020 version
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanpui committed Feb 11, 2020
1 parent 6e6d312 commit 3820a10
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 11 deletions.
Empty file modified scripts/run.py
100644 → 100755
Empty file.
24 changes: 15 additions & 9 deletions src/multi_net/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void Router::run() {
}
if (db::setting.multiNetVerbose >= +db::VerboseLevelT::MIDDLE) guideGenStat.print();

// congMap.printCrsnMap(1, {80, 1000}, {40, 70});
log() << std::endl;
log() << "################################################################" << std::endl;
database.setUnitVioCost(1); // set the cost back to without discount
Expand Down Expand Up @@ -104,7 +105,7 @@ void Router::updateCost() {
grDatabase.fadeHistCost();

grDatabase.setUnitViaMultiplier(
max(100 / pow(5, iter - 1), 4.0)); // note: enlarge unit via cost to avoid extra use of vias
max(100 / pow(5, iter - 1), 4.0)); // enlarge unit via cost to avoid extra use of vias
grDatabase.setLogisticSlope(db::setting.initLogisticSlope * pow(2, iter));
}

Expand All @@ -114,7 +115,7 @@ void Router::updateCost() {
}
}

vector<vector<int>> Router::getBatches(vector<SingleNetRouter>& routers, const vector<int>& netsToRoute) {
vector<vector<int>> Router::getBatches(vector<SingleNetRouter>& routers, const vector<int>& netsToRoute, bool seqEq) {
vector<int> batch(netsToRoute.size());
for (int i = 0; i < netsToRoute.size(); i++) batch[i] = i;

Expand All @@ -134,7 +135,7 @@ vector<vector<int>> Router::getBatches(vector<SingleNetRouter>& routers, const v
});

Scheduler scheduler(routers);
const vector<vector<int>>& batches = scheduler.schedule();
const vector<vector<int>>& batches = seqEq ? scheduler.scheduleOrderEq() : scheduler.schedule();

if (db::setting.multiNetVerbose >= +db::VerboseLevelT::MIDDLE) {
log() << "Finish multi-thread scheduling" << ((db::setting.numThreads == 0) ? " using simple mode" : "")
Expand All @@ -153,7 +154,7 @@ void Router::routeApprx(const vector<int>& netsToRoute) {
routers.reserve(netsToRoute.size());
for (auto id : netsToRoute) routers.emplace_back(grDatabase.nets[id]);

vector<vector<int>> batches = getBatches(routers, netsToRoute);
vector<vector<int>> batches = getBatches(routers, netsToRoute, false);

for (const vector<int>& batch : batches) {
runJobsMT(batch.size(), [&](int jobIdx) {
Expand Down Expand Up @@ -200,11 +201,16 @@ void Router::fluteAllAndRoute(const vector<int>& netsToRoute) {
if (router.grNet.needToRoute()) router.getRoutingOrder();
printlog("finish edge shifting");

for (int i = 0; i < routers.size(); i++) {
auto& router = routers[i];
router.initRoutePattern(initRouters[i]);
router.finish();
allNetStatus[netsToRoute[i]] = router.status;
vector<vector<int>> batches = getBatches(routers, netsToRoute, true);
for (const vector<int>& batch : batches) {
runJobsMT(batch.size(), [&](int jobIdx) {
int idx = batch[jobIdx];
auto& router = routers[idx];
router.initRoutePattern(initRouters[idx]);
router.finish();

allNetStatus[netsToRoute[idx]] = router.status;
});
}

printlog("finish pattern route");
Expand Down
2 changes: 1 addition & 1 deletion src/multi_net/Router.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Router {

vector<int> getNetsToRoute();
void sortNets(vector<int>& netsToRoute);
vector<vector<int>> getBatches(vector<SingleNetRouter>& routers, const vector<int>& netsToRoute);
vector<vector<int>> getBatches(vector<SingleNetRouter>& routers, const vector<int>& netsToRoute, bool seqEq);

void routeApprx(const vector<int>& netsToRoute);
void fluteAllAndRoute(const vector<int>& netsToRoute);
Expand Down
45 changes: 45 additions & 0 deletions src/multi_net/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,51 @@ vector<vector<int>> &Scheduler::schedule() {
return batches;
}

vector<vector<int>> &Scheduler::scheduleOrderEq() {
vector<int> routerIds;
for (int id = 0; id < routers.size(); ++id) routerIds.push_back(id);

if (db::setting.numThreads == 0) {
// simple case
for (int routerId : routerIds) batches.push_back({routerId});
} else {
// normal case
vector<bool> assigned(routers.size(), false);
int lastUnroute = 0;

while (lastUnroute < routerIds.size()) {
// create a new batch from a seed
batches.emplace_back();
initSet({});
vector<int> &batch = batches.back();
int lastMetric = INT_MAX; // Note: need to be change if sort metric changes

for (int i = lastUnroute; i < routerIds.size(); i++) {
int routerId = routerIds[i];

if (assigned[routerId]) continue;

int metric = routers[routerId].grNet.boundingBox.hp();
if (metric > lastMetric) break;

if (hasConflict(routerId)) {
lastMetric = metric;
} else {
batch.push_back(routerId);
assigned[routerId] = true;
updateSet(routerId);
}
}

// find the next seed
while (lastUnroute < routerIds.size() && assigned[routerIds[lastUnroute]]) {
++lastUnroute;
}
}
}
return batches;
}

void Scheduler::initSet(vector<int> jobIdxes) {
rtrees = RTrees(database.getLayerNum());
for (int jobIdx : jobIdxes) {
Expand Down
3 changes: 2 additions & 1 deletion src/multi_net/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Scheduler {
public:
Scheduler(const vector<SingleNetRouter>& routersToExec) : routers(routersToExec){};
vector<vector<int>>& schedule();
vector<vector<int>>& scheduleOrderEq();

private:
const vector<SingleNetRouter>& routers;
Expand All @@ -16,4 +17,4 @@ class Scheduler {
void initSet(vector<int> jobIdxes);
void updateSet(int jobIdx);
bool hasConflict(int jobIdx);
};
};

0 comments on commit 3820a10

Please sign in to comment.