From c13da3405c079f2c1498d89911ee46efb17c5c74 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Thu, 25 Jan 2024 22:14:54 -0300 Subject: [PATCH] grt: use vectors instead of array for large containers Signed-off-by: Eder Monteiro --- src/grt/src/fastroute/src/RSMT.cpp | 2 +- src/grt/src/fastroute/src/utility.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/grt/src/fastroute/src/RSMT.cpp b/src/grt/src/fastroute/src/RSMT.cpp index 4ce2fd26655..4ab2949bed3 100644 --- a/src/grt/src/fastroute/src/RSMT.cpp +++ b/src/grt/src/fastroute/src/RSMT.cpp @@ -93,7 +93,7 @@ void FastRouteCore::copyStTree(const int ind, const Tree& rsmt) // initialize the nbrcnt for treenodes const int sizeV = 2 * nets_[ind]->getNumPins(); - int nbrcnt[sizeV]; + std::vector nbrcnt(sizeV); for (int i = 0; i < numnodes; i++) nbrcnt[i] = 0; diff --git a/src/grt/src/fastroute/src/utility.cpp b/src/grt/src/fastroute/src/utility.cpp index 68c82644cb8..dc199486da1 100644 --- a/src/grt/src/fastroute/src/utility.cpp +++ b/src/grt/src/fastroute/src/utility.cpp @@ -1319,6 +1319,7 @@ float FastRouteCore::CalculatePartialSlack() auto partial_routes = getPlanarRoutes(); std::vector slacks; + slacks.reserve(netCount()); for (auto& net_route : partial_routes) { odb::dbNet* db_net = net_route.first; GRoute& route = net_route.second; @@ -2085,12 +2086,13 @@ int FastRouteCore::edgeShift(Tree& t, int net) // TODO: check this size const int sizeV = 2 * nets_[net]->getNumPins(); - int nbr[sizeV][3]; - int nbrCnt[sizeV]; - int pairN1[nets_[net]->getNumPins()]; - int pairN2[nets_[net]->getNumPins()]; - int costH[y_grid_]; - int costV[x_grid_]; + multi_array nbr; + nbr.resize(boost::extents[sizeV][3]); + std::vector nbrCnt(sizeV); + std::vector pairN1(nets_[net]->getNumPins()); + std::vector pairN2(nets_[net]->getNumPins()); + std::vector costH(y_grid_); + std::vector costV(x_grid_); deg = t.deg; // find root of the tree @@ -2422,8 +2424,8 @@ int FastRouteCore::edgeShiftNew(Tree& t, int net) deg = t.deg; const int sizeV = nets_[net]->getNumPins(); - int pairN1[sizeV]; - int pairN2[sizeV]; + std::vector pairN1(sizeV); + std::vector pairN2(sizeV); iter = 0; cur_pairN1 = cur_pairN2 = -1;