Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#864 from eder-matheus/grt_revert
Browse files Browse the repository at this point in the history
Revert "Merge pull request The-OpenROAD-Project#857 from eder-matheus/grt_layer_restriction"
  • Loading branch information
maliberty authored Jul 16, 2021
2 parents 1ad7ce2 + af6bf4a commit a5a5658
Show file tree
Hide file tree
Showing 26 changed files with 1,126 additions and 1,633 deletions.
2 changes: 2 additions & 0 deletions src/grt/include/grt/GlobalRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class GlobalRouter
void writeGuides(const char* file_name);
std::vector<Net*> startFastRoute(int min_routing_layer, int max_routing_layer, NetType type);
void estimateRC();
void run();
void globalRouteClocksSeparately();
void globalRoute();
NetRouteMap& getRoutes() { return routes_; }
bool haveRoutes() const { return !routes_.empty(); }
Expand Down
81 changes: 56 additions & 25 deletions src/grt/src/GlobalRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,38 @@ void GlobalRouter::applyAdjustments(int min_routing_layer, int max_routing_layer
fastroute_->initAuxVar();
}

void GlobalRouter::globalRouteClocksSeparately()
{
// route clock nets
std::vector<Net*> clock_nets
= startFastRoute(min_layer_for_clock_, max_layer_for_clock_, NetType::Clock);
reportResources();

logger_->report("Routing clock nets...");
routes_ = findRouting(clock_nets, min_layer_for_clock_, max_layer_for_clock_);
Capacities clk_capacities
= saveCapacities(min_layer_for_clock_, max_layer_for_clock_);
clearObjects();
logger_->info(GRT, 10, "Routed clock nets: {}", routes_.size());

if (max_routing_layer_ == -1) {
max_routing_layer_ = computeMaxRoutingLayer();
}
// route signal nets
std::vector<Net*> signalNets
= startFastRoute(min_routing_layer_, max_routing_layer_, NetType::Signal);
restoreCapacities(clk_capacities, min_layer_for_clock_, max_layer_for_clock_);
reportResources();

// Store results in a temporary map, allowing to keep previous
// routing result from clock nets
NetRouteMap result
= findRouting(signalNets, min_routing_layer_, max_routing_layer_);
routes_.insert(result.begin(), result.end());
}

void GlobalRouter::globalRoute()
{
clear();
if (max_routing_layer_ == -1) {
max_routing_layer_ = computeMaxRoutingLayer();
}
Expand All @@ -195,6 +224,19 @@ void GlobalRouter::globalRoute()
reportResources();

routes_ = findRouting(nets, min_routing_layer_, max_routing_layer_);
}

void GlobalRouter::run()
{
clear();

bool route_clocks = min_layer_for_clock_ > 0 && max_layer_for_clock_ > 0;

if (route_clocks) {
globalRouteClocksSeparately();
} else {
globalRoute();
}

reportCongestion();
computeWirelength();
Expand Down Expand Up @@ -687,23 +729,12 @@ void GlobalRouter::initializeNets(std::vector<Net*>& nets)
std::vector<int> edge_cost_per_layer(num_layers + 1, 1);
int edge_cost_for_net = computeTrackConsumption(net, edge_cost_per_layer);

// set layer restriction only to clock nets that are not connected to leaf iterms
bool has_leaf = clockHasLeafITerm(net->getDbNet());
int min_layer = (is_clock && min_layer_for_clock_ > 0 &&
!has_leaf) ?
min_layer_for_clock_ : min_routing_layer_;
int max_layer = (is_clock && max_layer_for_clock_ > 0 &&
!has_leaf) ?
max_layer_for_clock_ : max_routing_layer_;

int netID = fastroute_->addNet(net->getDbNet(),
pins_on_grid.size(),
net_alpha,
is_clock,
root_idx,
edge_cost_for_net,
min_layer-1,
max_layer-1,
edge_cost_per_layer);
for (RoutePt& pin_pos : pins_on_grid) {
fastroute_->addPin(netID, pin_pos.x(), pin_pos.y(), pin_pos.layer()-1);
Expand Down Expand Up @@ -2545,24 +2576,24 @@ Net* GlobalRouter::getNet(odb::dbNet* db_net)

void GlobalRouter::getNetsByType(NetType type, std::vector<Net*>& nets)
{
if (type == NetType::Antenna) {
for (odb::dbNet* db_net : dirty_nets_) {
nets.push_back(db_net_map_[db_net]);
}
} else {
// add clock nets not connected to a leaf first
if (type == NetType::Clock || type == NetType::Signal) {
bool get_clock = type == NetType::Clock;
for (Net net : *nets_) {
bool has_leaf = clockHasLeafITerm(net.getDbNet());
if ((net.getSignalType() == odb::dbSigType::CLOCK && !has_leaf)) {
if ((get_clock && net.getSignalType() == odb::dbSigType::CLOCK
&& !clockHasLeafITerm(net.getDbNet()))
|| (!get_clock
&& (net.getSignalType() != odb::dbSigType::CLOCK
|| clockHasLeafITerm(net.getDbNet())))) {
nets.push_back(db_net_map_[net.getDbNet()]);
}
}

} else if (type == NetType::Antenna) {
for (odb::dbNet* db_net : dirty_nets_) {
nets.push_back(db_net_map_[db_net]);
}
} else {
for (Net net : *nets_) {
bool has_leaf = clockHasLeafITerm(net.getDbNet());
if ((net.getSignalType() != odb::dbSigType::CLOCK || has_leaf)) {
nets.push_back(db_net_map_[net.getDbNet()]);
}
nets.push_back(db_net_map_[net.getDbNet()]);
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/grt/src/GlobalRouter.i
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,23 @@ set_perturbation_amount(int perturbation)
}

void
run()
global_route()
{
getGlobalRouter()->globalRoute();
}

void
global_route_clocks_separately()
{
getGlobalRouter()->globalRouteClocksSeparately();
}

void
run()
{
getGlobalRouter()->run();
}

void
estimate_rc()
{
Expand Down
2 changes: 0 additions & 2 deletions src/grt/src/fastroute/include/DataType.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ typedef struct
bool is_clock; // flag that indicates if net is a clock net
int driver_idx;
int edgeCost;
int minLayer;
int maxLayer;
std::vector<int> edge_cost_per_layer;
} FrNet; // A Net is a set of connected MazePoints

Expand Down
2 changes: 0 additions & 2 deletions src/grt/src/fastroute/include/FastRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ class FastRouteCore
bool is_clock,
int driver_idx,
int cost,
int min_layer,
int max_layer,
std::vector<int> edge_cost_per_layer);
void initEdges();
void setNumAdjustments(int nAdjustements);
Expand Down
4 changes: 0 additions & 4 deletions src/grt/src/fastroute/src/FastRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ int FastRouteCore::addNet(odb::dbNet* db_net,
bool is_clock,
int driver_idx,
int cost,
int min_layer,
int max_layer,
std::vector<int> edge_cost_per_layer)
{
int netID = new_net_id_;
Expand All @@ -324,8 +322,6 @@ int FastRouteCore::addNet(odb::dbNet* db_net,
net->is_clock = is_clock;
net->driver_idx = driver_idx;
net->edgeCost = cost;
net->minLayer = min_layer;
net->maxLayer = max_layer;
net->edge_cost_per_layer = edge_cost_per_layer;

seglist_index_[new_net_id_] = seg_count_;
Expand Down
13 changes: 4 additions & 9 deletions src/grt/src/fastroute/src/maze3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHu

for (orderIndex = 0; orderIndex < endIND; orderIndex++) {
netID = tree_order_pv_[orderIndex].treeIndex;
FrNet* net = nets_[netID];

std::vector<int> edge_cost_per_layer = nets_[netID]->edge_cost_per_layer;

Expand Down Expand Up @@ -1041,8 +1040,7 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHu
if (curX > regionX1 && directions_3D_[curL][curY][curX] != EAST) {
grid = grid_hs_[curL] + curY * (x_grid_ - 1) + curX - 1;
tmp = d1_3D_[curL][curY][curX] + 1;
if (h_edges_3D_[grid].usage < h_edges_3D_[grid].cap &&
net->minLayer <= curL && curL <= net->maxLayer) {
if (h_edges_3D_[grid].usage < h_edges_3D_[grid].cap) {
tmpX = curX - 1; // the left neighbor

if (d1_3D_[curL][curY][tmpX]
Expand Down Expand Up @@ -1081,8 +1079,7 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHu
tmp = d1_3D_[curL][curY][curX] + 1;
tmpX = curX + 1; // the right neighbor

if (h_edges_3D_[grid].usage < h_edges_3D_[grid].cap &&
net->minLayer <= curL && curL <= net->maxLayer) {
if (h_edges_3D_[grid].usage < h_edges_3D_[grid].cap) {
if (d1_3D_[curL][curY][tmpX]
>= BIG_INT) // right neighbor not been put into heap1_3D_
{
Expand Down Expand Up @@ -1118,8 +1115,7 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHu
grid = grid_vs_[curL] + (curY - 1) * x_grid_ + curX;
tmp = d1_3D_[curL][curY][curX] + 1;
tmpY = curY - 1; // the bottom neighbor
if (v_edges_3D_[grid].usage < v_edges_3D_[grid].cap &&
net->minLayer <= curL && curL <= net->maxLayer) {
if (v_edges_3D_[grid].usage < v_edges_3D_[grid].cap) {
if (d1_3D_[curL][tmpY][curX]
>= BIG_INT) // bottom neighbor not been put into heap1_3D_
{
Expand Down Expand Up @@ -1154,8 +1150,7 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHu
grid = grid_vs_[curL] + curY * x_grid_ + curX;
tmp = d1_3D_[curL][curY][curX] + 1;
tmpY = curY + 1; // the top neighbor
if (v_edges_3D_[grid].usage < v_edges_3D_[grid].cap &&
net->minLayer <= curL && curL <= net->maxLayer) {
if (v_edges_3D_[grid].usage < v_edges_3D_[grid].cap) {
if (d1_3D_[curL][tmpY][curX]
>= BIG_INT) // top neighbor not been put into heap1_3D_
{
Expand Down
27 changes: 2 additions & 25 deletions src/grt/src/fastroute/src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
TreeEdge *treeedges, *treeedge;
TreeNode* treenodes;

FrNet* net = nets_[netID];
treeedges = sttrees_[netID].edges;
treenodes = sttrees_[netID].nodes;
treeedge = &(treeedges[edgeID]);
Expand Down Expand Up @@ -358,26 +357,14 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
if (gridsX[k] == gridsX[k + 1]) {
min_y = std::min(gridsY[k], gridsY[k + 1]);
for (l = 0; l < num_layers_; l++) {
// check if the current layer is vertical to match the edge orientation
bool is_vertical = ((l % 2) - layer_orientation_) != 0;
grid = l * grid_v_ + min_y * x_grid_ + gridsX[k];
if (l >= net->minLayer && l <= net->maxLayer && is_vertical) {
layer_grid_[l][k] = v_edges_3D_[grid].cap - v_edges_3D_[grid].usage;
} else {
layer_grid_[l][k] = std::numeric_limits<int>::min();
}
layer_grid_[l][k] = v_edges_3D_[grid].cap - v_edges_3D_[grid].usage;
}
} else {
min_x = std::min(gridsX[k], gridsX[k + 1]);
for (l = 0; l < num_layers_; l++) {
// check if the current layer is horizontal to match the edge orientation
bool is_horizontal = ((l % 2) - layer_orientation_) == 0;
grid = l * grid_h_ + gridsY[k] * (x_grid_ - 1) + min_x;
if (l >= net->minLayer && l <= net->maxLayer && is_horizontal) {
layer_grid_[l][k] = h_edges_3D_[grid].cap - h_edges_3D_[grid].usage;
} else {
layer_grid_[l][k] = std::numeric_limits<int>::min();
}
layer_grid_[l][k] = h_edges_3D_[grid].cap - h_edges_3D_[grid].usage;
}
}
}
Expand Down Expand Up @@ -415,11 +402,6 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
for (l = 0; l < num_layers_; l++) {
if (layer_grid_[l][k] > 0) {
gridD[l][k + 1] = gridD[l][k] + 1;
} else if (layer_grid_[l][k] == std::numeric_limits<int>::min()) {
// when the layer orientation doesn't match the edge orientation,
// set a larger weight to avoid assigning to this layer when the routing
// has 3D overflow
gridD[l][k + 1] = gridD[l][k] + 2*BIG_INT;
} else {
gridD[l][k + 1] = gridD[l][k] + BIG_INT;
}
Expand Down Expand Up @@ -537,11 +519,6 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
for (l = 0; l < num_layers_; l++) {
if (layer_grid_[l][k - 1] > 0) {
gridD[l][k - 1] = gridD[l][k] + 1;
} else if (layer_grid_[l][k] == std::numeric_limits<int>::min()) {
// when the layer orientation doesn't match the edge orientation,
// set a larger weight to avoid assigning to this layer when the routing
// has 3D overflow
gridD[l][k - 1] = gridD[l][k] + 2*BIG_INT;
} else {
gridD[l][k - 1] = gridD[l][k] + BIG_INT;
}
Expand Down
55 changes: 28 additions & 27 deletions src/grt/test/clock_route.guideok
Original file line number Diff line number Diff line change
Expand Up @@ -125,45 +125,46 @@ clknet_2_2__leaf_clk
)
clknet_2_3__leaf_clk
(
144000 151200 151200 158400 li1
144000 151200 158400 158400 met1
136800 201600 144000 208800 li1
136800 201600 151200 208800 met1
144000 194400 151200 208800 met2
144000 194400 151200 201600 met1
122400 194400 129600 201600 li1
122400 194400 151200 201600 met1
187200 172800 194400 180000 met1
187200 165600 194400 180000 met2
187200 165600 201600 172800 met1
122400 194400 144000 201600 met1
136800 194400 144000 208800 met2
136800 201600 144000 208800 met1
136800 201600 144000 208800 li1
158400 151200 165600 158400 li1
158400 151200 201600 158400 met1
194400 151200 201600 172800 met2
194400 165600 201600 172800 met1
194400 165600 201600 172800 li1
158400 194400 165600 201600 li1
158400 194400 165600 201600 met1
158400 194400 165600 216000 met2
158400 208800 165600 216000 met1
158400 208800 165600 216000 li1
136800 158400 144000 165600 li1
136800 158400 158400 165600 met1
151200 172800 194400 180000 met1
158400 151200 165600 158400 li1
151200 151200 165600 158400 met1
144000 187200 151200 194400 li1
136800 158400 151200 165600 met1
144000 151200 151200 165600 met2
144000 151200 151200 158400 met1
144000 151200 151200 158400 li1
165600 187200 194400 194400 met1
187200 187200 194400 208800 met2
187200 201600 194400 208800 met1
187200 201600 194400 208800 li1
136800 201600 151200 208800 met1
144000 187200 151200 208800 met2
144000 187200 151200 194400 met1
144000 187200 151200 201600 met2
151200 172800 158400 180000 li1
144000 187200 151200 194400 li1
144000 151200 158400 158400 met1
151200 151200 158400 180000 met2
151200 172800 158400 180000 met1
151200 158400 158400 180000 met2
151200 158400 158400 165600 met1
151200 187200 172800 194400 met1
151200 172800 158400 180000 li1
158400 194400 172800 201600 met1
165600 187200 172800 201600 met2
165600 187200 172800 194400 met1
165600 187200 172800 194400 li1
187200 172800 194400 208800 met2
187200 201600 194400 208800 met1
187200 201600 194400 208800 li1
144000 194400 165600 201600 met1
144000 151200 165600 158400 met1
151200 172800 172800 180000 met1
165600 172800 172800 194400 met2
144000 187200 158400 194400 met1
151200 151200 158400 165600 met2
151200 151200 158400 158400 met1
151200 187200 158400 194400 met1
151200 172800 158400 194400 met2
)
net55
Expand Down
Loading

0 comments on commit a5a5658

Please sign in to comment.