Skip to content

Commit f8ce580

Browse files
authored
Merge pull request #7982 from The-OpenROAD-Project-staging/grt-mem-opt
gui: save memory in Segment
2 parents 84b5e27 + 1a168dd commit f8ce580

File tree

8 files changed

+29
-23
lines changed

8 files changed

+29
-23
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class GlobalRouter
333333
std::vector<Pin*> getAllPorts();
334334
void computeTrackConsumption(const Net* net,
335335
int& track_consumption,
336-
std::vector<int>*& edge_costs_per_layer);
336+
std::vector<int8_t>*& edge_costs_per_layer);
337337

338338
// aux functions
339339
std::vector<odb::Point> findOnGridPositions(const Pin& pin,

src/grt/src/GlobalRouter.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ void GlobalRouter::makeFastrouteNet(Net* net)
11621162
findFastRoutePins(net, pins_on_grid, root_idx);
11631163

11641164
bool is_clock = (net->getSignalType() == odb::dbSigType::CLOCK);
1165-
std::vector<int>* edge_cost_per_layer;
1165+
std::vector<int8_t>* edge_cost_per_layer;
11661166
int edge_cost_for_net;
11671167
computeTrackConsumption(net, edge_cost_for_net, edge_cost_per_layer);
11681168

@@ -1250,7 +1250,7 @@ void GlobalRouter::getCapacityReductionData(CapacityReductionData& cap_red_data)
12501250
void GlobalRouter::computeTrackConsumption(
12511251
const Net* net,
12521252
int& track_consumption,
1253-
std::vector<int>*& edge_costs_per_layer)
1253+
std::vector<int8_t>*& edge_costs_per_layer)
12541254
{
12551255
edge_costs_per_layer = nullptr;
12561256
track_consumption = 1;
@@ -1262,7 +1262,7 @@ void GlobalRouter::computeTrackConsumption(
12621262
odb::dbTechNonDefaultRule* ndr = db_net->getNonDefaultRule();
12631263
if (ndr) {
12641264
int num_layers = grid_->getNumLayers();
1265-
edge_costs_per_layer = new std::vector<int>(num_layers + 1, 1);
1265+
edge_costs_per_layer = new std::vector<int8_t>(num_layers + 1, 1);
12661266
std::vector<odb::dbTechLayerRule*> layer_rules;
12671267
ndr->getLayerRules(layer_rules);
12681268

@@ -1280,6 +1280,13 @@ void GlobalRouter::computeTrackConsumption(
12801280
int ndr_pitch = ndr_width / 2 + ndr_spacing + default_width / 2;
12811281

12821282
int consumption = std::ceil((float) ndr_pitch / default_pitch);
1283+
if (consumption > std::numeric_limits<int8_t>::max()) {
1284+
logger_->error(GRT,
1285+
272,
1286+
"NDR consumption {} exceeds {} and is unsupported",
1287+
consumption,
1288+
std::numeric_limits<int8_t>::max());
1289+
}
12831290
(*edge_costs_per_layer)[layerIdx - 1] = consumption;
12841291

12851292
track_consumption = std::max(track_consumption, consumption);

src/grt/src/fastroute/include/DataType.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ enum class EdgeDirection
4747

4848
struct Segment // A Segment is a 2-pin connection
4949
{
50-
bool xFirst; // route x-direction first (only for L route)
51-
bool HVH; // TRUE = HVH or false = VHV (only for Z route)
52-
5350
int16_t x1, y1, x2, y2; // coordinates of two endpoints
54-
int netID; // the netID of the net this segment belonging to
55-
int16_t Zpoint; // The coordinates of Z point (x for HVH and y for VHV)
51+
int16_t Zpoint; // The coordinates of Z point (x for HVH and y for VHV)
52+
int8_t cost; // the netID of the net this segment belonging to
53+
bool xFirst : 1; // route x-direction first (only for L route)
54+
bool HVH : 1; // TRUE = HVH or false = VHV (only for Z route)
5655
};
5756

5857
struct FrNet // A Net is a set of connected MazePoints
@@ -67,7 +66,7 @@ struct FrNet // A Net is a set of connected MazePoints
6766
int getMaxLayer() const { return max_layer_; }
6867
int getMinLayer() const { return min_layer_; }
6968
int getNumPins() const { return pin_x_.size(); }
70-
int getLayerEdgeCost(int layer) const;
69+
int8_t getLayerEdgeCost(int layer) const;
7170

7271
int getPinX(int idx) const { return pin_x_[idx]; }
7372
int getPinY(int idx) const { return pin_y_[idx]; }
@@ -84,7 +83,7 @@ struct FrNet // A Net is a set of connected MazePoints
8483
int min_layer,
8584
int max_layer,
8685
float slack,
87-
std::vector<int>* edge_cost_per_layer);
86+
std::vector<int8_t>* edge_cost_per_layer);
8887
void setMaxLayer(int max_layer) { max_layer_ = max_layer; }
8988
void setMinLayer(int min_layer) { min_layer_ = min_layer; }
9089
void setSlack(float slack) { slack_ = slack; }
@@ -103,7 +102,7 @@ struct FrNet // A Net is a set of connected MazePoints
103102
int max_layer_;
104103
float slack_;
105104
// Non-null when an NDR has been applied to the net.
106-
std::unique_ptr<std::vector<int>> edge_cost_per_layer_;
105+
std::unique_ptr<std::vector<int8_t>> edge_cost_per_layer_;
107106
};
108107

109108
struct Edge // An Edge is the routing track holder between two adjacent

src/grt/src/fastroute/include/FastRoute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class FastRouteCore
108108
int min_layer,
109109
int max_layer,
110110
float slack,
111-
std::vector<int>* edge_cost_per_layer);
111+
std::vector<int8_t>* edge_cost_per_layer);
112112
void deleteNet(odb::dbNet* db_net);
113113
void removeNet(odb::dbNet* db_net);
114114
void mergeNet(odb::dbNet* removed_net, odb::dbNet* preserved_net);

src/grt/src/fastroute/src/FastRoute.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ FrNet* FastRouteCore::addNet(odb::dbNet* db_net,
235235
int min_layer,
236236
int max_layer,
237237
float slack,
238-
std::vector<int>* edge_cost_per_layer)
238+
std::vector<int8_t>* edge_cost_per_layer)
239239
{
240240
int netID;
241241
bool exists;
@@ -1582,7 +1582,7 @@ void FastRouteCore::StTreeVisualization(const StTree& stree,
15821582

15831583
////////////////////////////////////////////////////////////////
15841584

1585-
int FrNet::getLayerEdgeCost(int layer) const
1585+
int8_t FrNet::getLayerEdgeCost(int layer) const
15861586
{
15871587
if (edge_cost_per_layer_) {
15881588
return (*edge_cost_per_layer_)[layer];
@@ -1605,7 +1605,7 @@ void FrNet::reset(odb::dbNet* db_net,
16051605
int min_layer,
16061606
int max_layer,
16071607
float slack,
1608-
std::vector<int>* edge_cost_per_layer)
1608+
std::vector<int8_t>* edge_cost_per_layer)
16091609
{
16101610
db_net_ = db_net;
16111611
is_critical_ = false;

src/grt/src/fastroute/src/RSMT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void FastRouteCore::gen_brk_RSMT(const bool congestionDriven,
732732
seg.y2 = y1;
733733
}
734734

735-
seg.netID = netID;
735+
seg.cost = nets_[netID]->getEdgeCost();
736736
}
737737
} // loop j
738738

src/grt/src/fastroute/src/RipUp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using utl::GRT;
1717
// rip-up a L segment
1818
void FastRouteCore::ripupSegL(const Segment* seg)
1919
{
20-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
20+
const int8_t edgeCost = seg->cost;
2121

2222
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
2323

src/grt/src/fastroute/src/route.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using utl::GRT;
1919
// possible L for L segments
2020
void FastRouteCore::estimateOneSeg(const Segment* seg)
2121
{
22-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
22+
const int8_t edgeCost = seg->cost;
2323

2424
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
2525

@@ -39,7 +39,7 @@ void FastRouteCore::estimateOneSeg(const Segment* seg)
3939

4040
void FastRouteCore::routeSegV(const Segment* seg)
4141
{
42-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
42+
const int8_t edgeCost = seg->cost;
4343

4444
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
4545

@@ -48,15 +48,15 @@ void FastRouteCore::routeSegV(const Segment* seg)
4848

4949
void FastRouteCore::routeSegH(const Segment* seg)
5050
{
51-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
51+
const int8_t edgeCost = seg->cost;
5252

5353
graph2d_.addEstUsageH({seg->x1, seg->x2}, seg->y1, edgeCost);
5454
}
5555

5656
// L-route, based on previous L route
5757
void FastRouteCore::routeSegL(Segment* seg)
5858
{
59-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
59+
const int8_t edgeCost = seg->cost;
6060

6161
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
6262

@@ -137,7 +137,7 @@ void FastRouteCore::routeSegLFirstTime(Segment* seg)
137137
}
138138
}
139139

140-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
140+
const int8_t edgeCost = seg->cost;
141141

142142
if (costL1 < costL2) {
143143
// two parts (x1, y1)-(x1, y2) and (x1, y2)-(x2, y2)

0 commit comments

Comments
 (0)