Skip to content

Commit 69c3701

Browse files
authored
Merge pull request #8228 from luis201420/grt_suggest_layer_adjustment
GRT: Suggest adjustment value when having congestion problems
2 parents 8349d33 + 4b3ed5e commit 69c3701

File tree

10 files changed

+181
-3
lines changed

10 files changed

+181
-3
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ class GlobalRouter
362362
Pin& pin,
363363
odb::Point& pos_on_grid,
364364
bool has_access_points);
365+
void suggestAdjustment();
365366
void findFastRoutePins(Net* net,
366367
std::vector<RoutePt>& pins_on_grid,
367368
int& root_idx);

src/grt/src/GlobalRouter.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ void GlobalRouter::applyAdjustments(int min_routing_layer,
189189
computeObstructionsAdjustments();
190190
std::vector<int> track_space = grid_->getTrackPitches();
191191
fastroute_->initBlockedIntervals(track_space);
192+
// Save global resources before add adjustment by layer
193+
fastroute_->saveResourcesBeforeAdjustments();
192194
computeUserGlobalAdjustments(min_routing_layer, max_routing_layer);
193195
computeUserLayerAdjustments(max_routing_layer);
194196

@@ -368,6 +370,8 @@ void GlobalRouter::globalRoute(bool save_guides,
368370
}
369371

370372
if (is_congested_) {
373+
// Suggest adjustment value
374+
suggestAdjustment();
371375
if (allow_congestion_) {
372376
logger_->warn(GRT,
373377
115,
@@ -382,6 +386,32 @@ void GlobalRouter::globalRoute(bool save_guides,
382386
}
383387
}
384388

389+
void GlobalRouter::suggestAdjustment()
390+
{
391+
// Get min adjustment apply to layers
392+
int min_routing_layer, max_routing_layer;
393+
getMinMaxLayer(min_routing_layer, max_routing_layer);
394+
float min_adjustment = 100;
395+
for (int l = min_routing_layer; l <= max_routing_layer; l++) {
396+
odb::dbTechLayer* tech_layer = db_->getTech()->findRoutingLayer(l);
397+
if (tech_layer->getLayerAdjustment() != 0.0) {
398+
min_adjustment
399+
= std::min(min_adjustment, tech_layer->getLayerAdjustment());
400+
}
401+
}
402+
min_adjustment *= 100;
403+
// Suggest new adjustment value
404+
int suggest_adjustment;
405+
bool has_sug_adj = fastroute_->computeSuggestedAdjustment(suggest_adjustment);
406+
if (has_sug_adj && min_adjustment > suggest_adjustment) {
407+
logger_->warn(GRT,
408+
704,
409+
"Try reduce the layer adjustment from {}% to {}%",
410+
min_adjustment,
411+
suggest_adjustment);
412+
}
413+
}
414+
385415
void GlobalRouter::updateDbCongestion()
386416
{
387417
int min_layer, max_layer;
@@ -5116,6 +5146,8 @@ std::vector<Net*> GlobalRouter::updateDirtyRoutes(bool save_guides)
51165146
is_congested_ = true;
51175147
updateDbCongestion();
51185148
saveCongestion();
5149+
// Suggest adjustment value
5150+
suggestAdjustment();
51195151
logger_->error(GRT,
51205152
232,
51215153
"Routing congestion too high. Check the congestion "

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct Edge // An Edge is the routing track holder between two adjacent
130130
uint16_t cap; // the capacity of the edge
131131
uint16_t usage; // the usage of the edge
132132
uint16_t red;
133+
uint16_t real_cap; // the real capacity without user adjustment
133134
int16_t last_usage;
134135
uint16_t ndr_overflow; // number of NDR nets in congestion
135136
double est_usage; // the estimated usage of the edge
@@ -140,9 +141,10 @@ struct Edge // An Edge is the routing track holder between two adjacent
140141

141142
struct Edge3D
142143
{
143-
uint16_t cap; // the capacity of the edge
144-
uint16_t usage; // the usage of the edge
145-
uint16_t red; // the reduction of capacity of the edge
144+
uint16_t cap; // the capacity of the edge
145+
uint16_t usage; // the usage of the edge
146+
uint16_t red; // the reduction of capacity of the edge
147+
uint16_t real_cap; // the real capacity without user adjustment
146148
};
147149

148150
struct TreeNode

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ class FastRouteCore
153153
const interval<int>::type& last_tile_reduce_interval,
154154
const std::vector<int>& track_space,
155155
bool release = false);
156+
void saveResourcesBeforeAdjustments();
157+
bool computeSuggestedAdjustment(int& suggested_adjustment);
158+
void getPrecisionAdjustment(int x,
159+
int y,
160+
bool is_horizontal,
161+
int& adjustment);
156162
void initBlockedIntervals(std::vector<int>& track_space);
157163
void initAuxVar();
158164
NetRouteMap run();

src/grt/src/fastroute/include/Graph2D.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class Graph2D
7878
bool stop_decreasing,
7979
int& max_adj);
8080
void str_accu(int rnd);
81+
void saveResources(int x, int y, bool is_horizontal);
82+
bool computeSuggestedAdjustment(int x,
83+
int y,
84+
bool is_horizontal,
85+
int& adjustment);
8186

8287
void updateEstUsageH(const Interval& xi, int y, FrNet* net, double usage);
8388
void updateEstUsageH(int x, int y, FrNet* net, double usage);

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,28 @@ void FastRouteCore::addAdjustment(int x1,
524524
}
525525
}
526526

527+
void FastRouteCore::saveResourcesBeforeAdjustments()
528+
{
529+
// Save real horizontal resources
530+
for (int x = 0; x < x_grid_ - 1; x++) {
531+
for (int y = 0; y < y_grid_; y++) {
532+
graph2d_.saveResources(x, y, true);
533+
for (int l = 0; l < num_layers_; l++) {
534+
h_edges_3D_[l][y][x].real_cap = h_edges_3D_[l][y][x].cap;
535+
}
536+
}
537+
}
538+
// Save real vertical resources
539+
for (int x = 0; x < x_grid_; x++) {
540+
for (int y = 0; y < y_grid_ - 1; y++) {
541+
graph2d_.saveResources(x, y, false);
542+
for (int l = 0; l < num_layers_; l++) {
543+
v_edges_3D_[l][y][x].real_cap = v_edges_3D_[l][y][x].cap;
544+
}
545+
}
546+
}
547+
}
548+
527549
void FastRouteCore::releaseResourcesOnInterval(
528550
int x,
529551
int y,

src/grt/src/fastroute/src/graph2d.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,35 @@ void Graph2D::foreachEdge(const std::function<void(Edge&)>& func)
456456
inner(v_edges_);
457457
}
458458

459+
void Graph2D::saveResources(const int x, const int y, bool is_horizontal)
460+
{
461+
if (is_horizontal) {
462+
h_edges_[x][y].real_cap = h_edges_[x][y].cap;
463+
} else {
464+
v_edges_[x][y].real_cap = v_edges_[x][y].cap;
465+
}
466+
}
467+
468+
bool Graph2D::computeSuggestedAdjustment(const int x,
469+
const int y,
470+
bool is_horizontal,
471+
int& adjustment)
472+
{
473+
float real_capacity, usage;
474+
if (is_horizontal) {
475+
real_capacity = h_edges_[x][y].real_cap;
476+
usage = h_edges_[x][y].usage;
477+
} else {
478+
real_capacity = v_edges_[x][y].real_cap;
479+
usage = v_edges_[x][y].usage;
480+
}
481+
if (real_capacity >= usage) {
482+
adjustment = (1.0 - (usage / real_capacity)) * 100;
483+
return true;
484+
}
485+
return false;
486+
}
487+
459488
// Initializes the 3D capacity of the graph.
460489
void Graph2D::initCap3D()
461490
{

src/grt/src/fastroute/src/maze.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,81 @@ void FastRouteCore::getOverflowPositions(
18891889
}
18901890
}
18911891

1892+
// Search in range of 5 the correct adjustment to fix the overflow
1893+
void FastRouteCore::getPrecisionAdjustment(const int x,
1894+
const int y,
1895+
bool is_horizontal,
1896+
int& adjustment)
1897+
{
1898+
int new_2D_cap, usage_2D, range = 5;
1899+
if (is_horizontal) {
1900+
usage_2D = graph2d_.getUsageH(x, y);
1901+
} else {
1902+
usage_2D = graph2d_.getUsageV(x, y);
1903+
}
1904+
1905+
new_2D_cap = 0;
1906+
while (range > 0 && new_2D_cap < usage_2D) {
1907+
// calculate new capacity with adjustment
1908+
for (int l = 0; l < num_layers_; l++) {
1909+
if (is_horizontal) {
1910+
new_2D_cap
1911+
+= (1.0 - (adjustment / 100.0)) * h_edges_3D_[l][y][x].real_cap;
1912+
} else {
1913+
new_2D_cap
1914+
+= (1.0 - (adjustment / 100.0)) * v_edges_3D_[l][y][x].real_cap;
1915+
}
1916+
}
1917+
// Reduce adjustment to increase capacity
1918+
if (usage_2D > new_2D_cap) {
1919+
adjustment--;
1920+
new_2D_cap = 0;
1921+
}
1922+
range--;
1923+
}
1924+
}
1925+
1926+
// For each edge with overflow, calculate the ideal adjustment
1927+
// Return the minimum value of all or -1 if no value can be found
1928+
bool FastRouteCore::computeSuggestedAdjustment(int& suggested_adjustment)
1929+
{
1930+
int horizontal_suggest = 100, local_suggest;
1931+
bool has_new_adj;
1932+
// Find horizontal ggrids with congestion
1933+
for (const auto& [x, y] : graph2d_.getUsedGridsH()) {
1934+
const int overflow = graph2d_.getOverflowH(x, y);
1935+
if (overflow > 0) {
1936+
has_new_adj
1937+
= graph2d_.computeSuggestedAdjustment(x, y, true, local_suggest);
1938+
if (has_new_adj) {
1939+
// modify the value to resolve the congestion at the position
1940+
getPrecisionAdjustment(x, y, true, local_suggest);
1941+
horizontal_suggest = std::min(horizontal_suggest, local_suggest);
1942+
} else {
1943+
return false;
1944+
}
1945+
}
1946+
}
1947+
int vertical_suggest = 100;
1948+
// Find vertical ggrids with congestion
1949+
for (const auto& [x, y] : graph2d_.getUsedGridsV()) {
1950+
const int overflow = graph2d_.getOverflowV(x, y);
1951+
if (overflow > 0) {
1952+
has_new_adj
1953+
= graph2d_.computeSuggestedAdjustment(x, y, false, local_suggest);
1954+
if (has_new_adj) {
1955+
// modify the value to resolve the congestion at the position
1956+
getPrecisionAdjustment(x, y, false, local_suggest);
1957+
vertical_suggest = std::min(vertical_suggest, local_suggest);
1958+
} else {
1959+
return false;
1960+
}
1961+
}
1962+
}
1963+
suggested_adjustment = std::min(horizontal_suggest, vertical_suggest);
1964+
return true;
1965+
}
1966+
18921967
// The function will add the new nets to the congestion_nets set
18931968
void FastRouteCore::getCongestionNets(std::set<odb::dbNet*>& congestion_nets)
18941969
{

test/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ def make_design(tech):
7272
# suppress ord message with number of threads
7373
logger.suppressMessage(utl.ORD, 30)
7474

75+
# suppress grt message with the suggested adjustment
76+
logger.suppressMessage(utl.GRT, 704)
77+
7578
return design

test/helpers.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,6 @@ suppress_message PAR 38
210210

211211
# suppress ord message with number of threads
212212
suppress_message ORD 30
213+
214+
# suppress grt message with the suggested adjustment
215+
suppress_message GRT 704

0 commit comments

Comments
 (0)