Skip to content

Commit eee505c

Browse files
authored
Merge pull request #2759 from The-OpenROAD-Project-staging/gpl-index
gpl: ensure index in BinGrid::getDensityMinMaxIdx[XY] is valid
2 parents 5e7c6c4 + 402c5cf commit eee505c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/gpl/src/nesterovBase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,8 @@ std::pair<int, int> BinGrid::getDensityMinMaxIdxX(const GCell* gcell) const
921921
int upperIdx = (fastModulo((gcell->dUx() - lx()), binSizeX_) == 0)
922922
? (gcell->dUx() - lx()) / binSizeX_
923923
: (gcell->dUx() - lx()) / binSizeX_ + 1;
924+
925+
upperIdx = std::min(upperIdx, binCntX_);
924926
return std::make_pair(lowerIdx, upperIdx);
925927
}
926928

@@ -931,6 +933,7 @@ std::pair<int, int> BinGrid::getDensityMinMaxIdxY(const GCell* gcell) const
931933
? (gcell->dUy() - ly()) / binSizeY_
932934
: (gcell->dUy() - ly()) / binSizeY_ + 1;
933935

936+
upperIdx = std::min(upperIdx, binCntY_);
934937
return std::make_pair(lowerIdx, upperIdx);
935938
}
936939

0 commit comments

Comments
 (0)