Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
qutong20 committed Feb 22, 2020
1 parent e8793e6 commit 1b02d84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions dr-cu/src/multi_net/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ vector<vector<int>> Router::get_nets_feature() {
Scheduler scheduler(_routers);
vector<int> degree = scheduler.get_net_degree();

auto reset_mt = runJobsMT(_feature.size(), [&](int i) {
_feature.at(i).at(ROUTED) = 0;
});

auto feature_mt = runJobsMT(_routers.size(), [&](int i) {
auto net_id = _routers.at(i).dbNet.idx;
_feature.at(net_id).at(ROUTED) = 1;
Expand Down
16 changes: 8 additions & 8 deletions dr-cu/src/multi_net/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ vector<vector<int>> &Scheduler::schedule() {
for (int id = 0; id < routers.size(); ++id) {
routerIds.push_back(id);
}
if (db::setting.multiNetScheduleSortAll) {
std::sort(routerIds.begin(), routerIds.end(), [&](int lhs, int rhs) {
return routers[lhs].localNet.estimatedNumOfVertices > routers[rhs].localNet.estimatedNumOfVertices;
});
}
if (db::setting.multiNetScheduleSortAll) {
std::stable_sort(routerIds.begin(), routerIds.end(), [&](int lhs, int rhs) {
return routers[lhs].localNet.estimatedNumOfVertices > routers[rhs].localNet.estimatedNumOfVertices;
});
}

if (db::setting.numThreads == 0) {
// simple case
Expand Down Expand Up @@ -52,7 +52,7 @@ vector<vector<int>> &Scheduler::schedule() {
// sort within batches by NumOfVertices
if (db::setting.multiNetScheduleSort) {
for (auto &batch : batches) {
std::sort(batch.begin(), batch.end(), [&](int lhs, int rhs) {
std::stable_sort(batch.begin(), batch.end(), [&](int lhs, int rhs) {
return routers[lhs].localNet.estimatedNumOfVertices > routers[rhs].localNet.estimatedNumOfVertices;
});
}
Expand Down Expand Up @@ -133,7 +133,7 @@ vector<vector<int>> &Scheduler::schedule(vector<double> rank_score) {
routerIds.push_back(id);
}
if (db::setting.multiNetScheduleSortAll) {
std::sort(routerIds.begin(), routerIds.end(), [&](int lhs, int rhs) {
std::stable_sort(routerIds.begin(), routerIds.end(), [&](int lhs, int rhs) {
return rank_score.at(lhs) > rank_score.at(rhs) ;
});
}
Expand Down Expand Up @@ -170,7 +170,7 @@ vector<vector<int>> &Scheduler::schedule(vector<double> rank_score) {
// sort within batches by NumOfVertices
if (db::setting.multiNetScheduleSort) {
for (auto &batch : batches) {
std::sort(batch.begin(), batch.end(), [&](int lhs, int rhs) {
std::stable_sort(batch.begin(), batch.end(), [&](int lhs, int rhs) {
return rank_score.at(lhs) > rank_score.at(rhs);
});
}
Expand Down
2 changes: 2 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ int main(int argc, char *argv[]) {
spdlog::debug("take a step, took {:03.2f}s",
std::chrono::duration_cast<std::chrono::milliseconds>(step_run_time).count() / 1000.0);
if (res.done.at(0)) {
vios = envs.get_all_vio();
spdlog::info("total score: {}, vios[{}, {}, {}, {}]", res.reward, vios[0], vios[1], vios[2], vios[3]);
auto reset_start_time = std::chrono::high_resolution_clock::now();
auto reset_res = envs.reset();
res.feature = reset_res.feature;
Expand Down

0 comments on commit 1b02d84

Please sign in to comment.