Skip to content

Commit aa1df84

Browse files
committed
grt: disable multiple NDR nets at once if there is too much congestion
Signed-off-by: Jonas Gava <[email protected]>
1 parent 19acdf7 commit aa1df84

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ class FastRouteCore
253253
void computeCongestedNDRnets();
254254
void updateSoftNDRNetUsage(int net_id, int edge_cost);
255255
void setSoftNDR(int net_id);
256+
void applySoftNDR(const std::vector<int>& net_ids);
256257

257258
int x_corner() const { return x_corner_; }
258259
int y_corner() const { return y_corner_; }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <set>
99
#include <string>
1010
#include <utility>
11-
#include <vector>
1211

1312
#include "DataType.h"
1413
#include "boost/multi_array.hpp"
@@ -35,7 +34,7 @@ class Graph2D
3534

3635
struct NDRCongestion
3736
{
38-
int net_id; // NDR net id
37+
int net_id; // NDR net id
3938
uint16_t num_edges; // number of congested edges
4039
};
4140

@@ -119,6 +118,7 @@ class Graph2D
119118
void addCongestedNDRnet(int net_id, uint16_t num_edges);
120119
void sortCongestedNDRnets();
121120
int getOneCongestedNDRnet();
121+
std::vector<int> getMultipleCongestedNDRnet();
122122

123123
private:
124124
int x_grid_;

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

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ NetRouteMap FastRouteCore::run()
11941194
float logistic_coef = 0;
11951195
int slope;
11961196
int max_adj;
1197-
const int long_edge_len = BIG_INT;
1197+
int long_edge_len = 40;
11981198
const int short_edge_len = 12;
11991199

12001200
// call FLUTE to generate RSMT and break the nets into segments (2-pin nets)
@@ -1348,9 +1348,6 @@ NetRouteMap FastRouteCore::run()
13481348
if (i % 2 == 0) {
13491349
logistic_coef += 0.5;
13501350
}
1351-
// if (i > 40) {
1352-
// break;
1353-
// }
13541351
}
13551352
if (i > 10) {
13561353
ripup_threshold = 0;
@@ -1541,27 +1538,32 @@ NetRouteMap FastRouteCore::run()
15411538
// Compute all the NDR nets involved in congestion
15421539
computeCongestedNDRnets();
15431540

1544-
// Select one NDR net to be disabled
1545-
int net_id = graph2d_.getOneCongestedNDRnet();
1541+
std::vector<int> net_ids;
15461542

1547-
// If net_id == -1, there is no NDR net involved in congestion
1548-
if (net_id != -1) {
1549-
logger_->warn(
1550-
GRT, 273, "Disabling NDR net {}", nets_[net_id]->getName());
1551-
1552-
// Remove the usage of all the edges involved with this net
1553-
updateSoftNDRNetUsage(net_id, -nets_[net_id]->getEdgeCost());
1554-
1555-
// Reset the edge cost and layer edge cost to 1
1556-
setSoftNDR(net_id);
1543+
// If the congestion is not that high (note that the overflow is inflated
1544+
// by 100x when there is no capacity available for a NDR net in a specific
1545+
// edge)
1546+
if (total_overflow_ < 10000) {
1547+
// Select one NDR net to be disabled
1548+
int net_id = graph2d_.getOneCongestedNDRnet();
1549+
if (net_id != -1) {
1550+
net_ids.push_back(net_id);
1551+
}
1552+
} else { // Select multiple NDR nets
1553+
net_ids = graph2d_.getMultipleCongestedNDRnet();
1554+
}
15571555

1558-
// Update the usage of all the edges involved with this net considering
1559-
// the new edge cost
1560-
updateSoftNDRNetUsage(net_id, nets_[net_id]->getEdgeCost());
1556+
// Only apply soft NDR if there is NDR nets involved in congestion
1557+
if (!net_ids.empty()) {
1558+
// Apply the soft NDR to the selected list of nets
1559+
applySoftNDR(net_ids);
15611560

15621561
// Reset loop parameters
15631562
overflow_increases = 0;
15641563
i = 0;
1564+
1565+
// Increase maze route 3D threshold to fix bad routes
1566+
long_edge_len = BIG_INT;
15651567
}
15661568
}
15671569

@@ -1657,6 +1659,23 @@ NetRouteMap FastRouteCore::run()
16571659
return routes;
16581660
}
16591661

1662+
void FastRouteCore::applySoftNDR(const std::vector<int>& net_ids)
1663+
{
1664+
for (auto net_id : net_ids) {
1665+
logger_->warn(GRT, 273, "Disabling NDR net {}", nets_[net_id]->getName());
1666+
1667+
// Remove the usage of all the edges involved with this net
1668+
updateSoftNDRNetUsage(net_id, -nets_[net_id]->getEdgeCost());
1669+
1670+
// Reset the edge cost and layer edge cost to 1
1671+
setSoftNDR(net_id);
1672+
1673+
// Update the usage of all the edges involved with this net considering
1674+
// the new edge cost
1675+
updateSoftNDRNetUsage(net_id, nets_[net_id]->getEdgeCost());
1676+
}
1677+
}
1678+
16601679
void FastRouteCore::setSoftNDR(const int net_id)
16611680
{
16621681
nets_[net_id]->setIsSoftNDR(true);

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <set>
1111
#include <string>
1212
#include <utility>
13+
#include <vector>
1314

1415
#include "DataType.h"
1516
#include "FastRoute.h"
@@ -511,12 +512,24 @@ void Graph2D::sortCongestedNDRnets()
511512

512513
int Graph2D::getOneCongestedNDRnet()
513514
{
514-
if (!congested_ndrs_.empty() && congested_ndrs_[0].num_edges > 0) {
515+
if (!congested_ndrs_.empty()) {
515516
return congested_ndrs_[0].net_id;
516517
}
517518
return -1;
518519
}
519520

521+
// Get 10% of the NDR nets more involved in congestion
522+
std::vector<int> Graph2D::getMultipleCongestedNDRnet()
523+
{
524+
std::vector<int> net_ids;
525+
if (!congested_ndrs_.empty()) {
526+
for (int i = 0; i < ceil((double)congested_ndrs_.size() / 10); i++) {
527+
net_ids.push_back(congested_ndrs_[i].net_id);
528+
}
529+
}
530+
return net_ids;
531+
}
532+
520533
// Initializes the 3D capacity of the graph.
521534
void Graph2D::initCap3D()
522535
{

0 commit comments

Comments
 (0)