gpl: accumulate nonPlaceArea before multiplying density - #11123
gpl: accumulate nonPlaceArea before multiplying density#11123LucasYuki wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors BinGrid::updateBinsNonPlaceArea in nesterovBase.cpp to accumulate raw non-place areas in a temporary vector before scaling and adding them to the bins, and updates getOverlapArea to return int64_t instead of float. The review feedback suggests wrapping this new accumulation logic in a check to ensure pb_->nonPlaceInsts() is not empty, which avoids unnecessary memory allocation and loop overhead when there are no non-placeable instances.
| std::vector<int64_t> nonPlaceAreaRaw(bins_.size(), 0); | ||
| for (auto& inst : pb_->nonPlaceInsts()) { | ||
| std::pair<int, int> pairX = getMinMaxIdxX(inst); | ||
| std::pair<int, int> pairY = getMinMaxIdxY(inst); | ||
| for (int y = pairY.first; y < pairY.second; y++) { | ||
| for (int x = pairX.first; x < pairX.second; x++) { | ||
| Bin& bin = bins_[y * binCntX_ + x]; | ||
| bin.addNonPlaceArea(getOverlapArea(&bin, inst, dbu_per_micron) | ||
| * bin.getTargetDensity()); | ||
| nonPlaceAreaRaw[y * binCntX_ + x] | ||
| += getOverlapArea(&bin, inst, dbu_per_micron); | ||
| } | ||
| } | ||
| } | ||
| for (size_t i = 0; i < bins_.size(); ++i) { | ||
| if (nonPlaceAreaRaw[i] == 0) { | ||
| continue; | ||
| } | ||
| bins_[i].addNonPlaceArea( | ||
| static_cast<int64_t>(nonPlaceAreaRaw[i] * bins_[i].getTargetDensity())); | ||
| } |
There was a problem hiding this comment.
If pb_->nonPlaceInsts() is empty, allocating nonPlaceAreaRaw with the size of bins_ and then iterating over all bins is an unnecessary pb_->nonPlaceInsts() is not empty avoids this allocation and loop entirely, keeping the complexity at
if (!pb_->nonPlaceInsts().empty()) {
std::vector<int64_t> nonPlaceAreaRaw(bins_.size(), 0);
for (auto& inst : pb_->nonPlaceInsts()) {
std::pair<int, int> pairX = getMinMaxIdxX(inst);
std::pair<int, int> pairY = getMinMaxIdxY(inst);
for (int y = pairY.first; y < pairY.second; y++) {
for (int x = pairX.first; x < pairX.second; x++) {
Bin& bin = bins_[y * binCntX_ + x];
nonPlaceAreaRaw[y * binCntX_ + x]
+= getOverlapArea(&bin, inst, dbu_per_micron);
}
}
}
for (size_t i = 0; i < bins_.size(); ++i) {
if (nonPlaceAreaRaw[i] == 0) {
continue;
}
bins_[i].addNonPlaceArea(
static_cast<int64_t>(nonPlaceAreaRaw[i] * bins_[i].getTargetDensity()));
}
}Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
93a8da1 to
84e99b1
Compare
Summary
Accumulate the non-place area before multiplying the density to reduce rounding errors.
This PR should generate the same results as #11085.
Type of Change
Impact
This slightly changes some test results.
Verification
./etc/Build.sh).Related Issues
#11085