-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gpl: revert if diverge #6561
gpl: revert if diverge #6561
Changes from 9 commits
1b72d58
7f91020
60fd26c
bacb646
99a5025
c0e0f78
3432b5e
e43a0b7
f3dfd6d
492e7f0
1442c07
5879308
ea3dc03
170fa4b
b1272df
f01415c
a9a9d73
76bba71
a3baff2
b273e56
7236b71
cf2e9d9
53397c4
4893563
4d54af6
3a40747
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,14 +318,16 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
graphics_->cellPlot(true); | ||
} | ||
|
||
// snapshot saving detection | ||
bool isSnapshotSaved = false; | ||
|
||
// snapshot info | ||
float snapshotA = 0; | ||
float snapshotWlCoefX = 0, snapshotWlCoefY = 0; | ||
// routability snapshot info | ||
bool is_routability_snapshot_saved = false; | ||
float route_snapshotA = 0; | ||
float route_snapshotWlCoefX = 0, route_snapshotWlCoefY = 0; | ||
bool isDivergeTriedRevert = false; | ||
|
||
// divergence snapshot info | ||
float diverge_snapshotA = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'diverge_snapshotA' set but not used [clang-diagnostic-unused-but-set-variable] float diverge_snapshotA = 0;
^ |
||
float diverge_snapshotWlCoefX = 0, diverge_snapshotWlCoefY = 0; | ||
|
||
// backTracking variable. | ||
float curA = 1.0; | ||
|
||
|
@@ -342,7 +344,6 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
|
||
// here, prevA is a_(k), curA is a_(k+1) | ||
// See, the ePlace-MS paper's Algorithm 1 | ||
// | ||
curA = (1.0 + sqrt(4.0 * prevA * prevA + 1.0)) * 0.5; | ||
|
||
// coeff is (a_k - 1) / ( a_(k+1) ) in paper. | ||
|
@@ -412,9 +413,21 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
|
||
updateNextIter(iter); | ||
|
||
if (npVars_.allowRevertIfDiverge) { | ||
if (is_min_hpwl_) { | ||
diverge_snapshotWlCoefX = wireLengthCoefX_; | ||
diverge_snapshotWlCoefY = wireLengthCoefY_; | ||
diverge_snapshotA = curA; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: Value stored to 'diverge_snapshotA' is never read [clang-analyzer-deadcode.DeadStores] diverge_snapshotA = curA;
^ Additional contextsrc/gpl/src/nesterovPlace.cpp:419: Value stored to 'diverge_snapshotA' is never read diverge_snapshotA = curA;
^ |
||
for (auto& nb : nbVec_) { | ||
nb->snapshot(); | ||
} | ||
// log_->report("[NesterovSolve] Snapshot for divergence saved at iter = | ||
// {}", iter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented code. |
||
} | ||
} | ||
|
||
// For JPEG Saving | ||
// debug | ||
|
||
const int debug_start_iter = npVars_.debug_start_iter; | ||
if (graphics_ && (debug_start_iter == 0 || iter + 1 >= debug_start_iter)) { | ||
bool update | ||
|
@@ -531,13 +544,10 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
if (!isDivergeTriedRevert && rb_->numCall() >= 1) { | ||
// get back to the working rc size | ||
rb_->revertGCellSizeToMinRc(); | ||
|
||
curA = snapshotA; | ||
wireLengthCoefX_ = snapshotWlCoefX; | ||
wireLengthCoefY_ = snapshotWlCoefY; | ||
|
||
curA = route_snapshotA; | ||
wireLengthCoefX_ = route_snapshotWlCoefX; | ||
wireLengthCoefY_ = route_snapshotWlCoefY; | ||
nbc_->updateWireLengthForceWA(wireLengthCoefX_, wireLengthCoefY_); | ||
|
||
for (auto& nb : nbVec_) { | ||
nb->revertDivergence(); | ||
} | ||
|
@@ -548,27 +558,47 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
isDivergeTriedRevert = true; | ||
// turn off the RD forcely | ||
isRoutabilityNeed_ = false; | ||
} else if (npVars_.allowRevertIfDiverge) { | ||
// In case diverged and not in routability mode, finish with min hpwl | ||
// stored since overflow below 0.25 | ||
log_->warn(GPL, | ||
90, | ||
"Divergence detected, reverting to snapshot with min hpwl."); | ||
log_->warn(GPL, | ||
91, | ||
"Revert to iter: {:4d} overflow: {:.3f} HPWL: {}", | ||
diverge_snapshot_iter_, | ||
diverge_snapshot_average_overflow_unscaled_, | ||
min_hpwl_); | ||
curA = diverge_snapshotA; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: Value stored to 'curA' is never read [clang-analyzer-deadcode.DeadStores] curA = diverge_snapshotA;
^ Additional contextsrc/gpl/src/nesterovPlace.cpp:572: Value stored to 'curA' is never read curA = diverge_snapshotA;
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: Value stored to 'curA' is never read [clang-analyzer-deadcode.DeadStores] curA = diverge_snapshotA;
^ Additional contextsrc/gpl/src/nesterovPlace.cpp:570: Value stored to 'curA' is never read curA = diverge_snapshotA;
^ |
||
wireLengthCoefX_ = diverge_snapshotWlCoefX; | ||
wireLengthCoefY_ = diverge_snapshotWlCoefY; | ||
nbc_->updateWireLengthForceWA(wireLengthCoefX_, wireLengthCoefY_); | ||
for (auto& nb : nbVec_) { | ||
nb->revertDivergence(); | ||
} | ||
isDiverged_ = false; | ||
break; | ||
} else { | ||
// no way to revert | ||
break; | ||
} | ||
} | ||
|
||
if (!isSnapshotSaved && npVars_.routabilityDrivenMode | ||
if (!is_routability_snapshot_saved && npVars_.routabilityDrivenMode | ||
&& 0.6 >= average_overflow_unscaled_) { | ||
snapshotWlCoefX = wireLengthCoefX_; | ||
snapshotWlCoefY = wireLengthCoefY_; | ||
snapshotA = curA; | ||
isSnapshotSaved = true; | ||
route_snapshotWlCoefX = wireLengthCoefX_; | ||
route_snapshotWlCoefY = wireLengthCoefY_; | ||
route_snapshotA = curA; | ||
is_routability_snapshot_saved = true; | ||
|
||
for (auto& nb : nbVec_) { | ||
nb->snapshot(); | ||
} | ||
|
||
log_->report("[NesterovSolve] Snapshot saved at iter = {}", iter); | ||
log_->info(GPL, 88, "Routability snapshot saved at iter = {}", iter); | ||
} | ||
|
||
// check routability using GR | ||
// check routability using RUDY or GR | ||
if (npVars_.routabilityDrivenMode && isRoutabilityNeed_ | ||
&& npVars_.routabilityCheckOverflow >= average_overflow_unscaled_) { | ||
// recover the densityPenalty values | ||
|
@@ -582,17 +612,17 @@ int NesterovPlace::doNesterovPlace(int start_iter) | |
// cutFillerCoordinates(); | ||
|
||
// revert back the current density penality | ||
curA = snapshotA; | ||
wireLengthCoefX_ = snapshotWlCoefX; | ||
wireLengthCoefY_ = snapshotWlCoefY; | ||
curA = route_snapshotA; | ||
wireLengthCoefX_ = route_snapshotWlCoefX; | ||
wireLengthCoefY_ = route_snapshotWlCoefY; | ||
|
||
nbc_->updateWireLengthForceWA(wireLengthCoefX_, wireLengthCoefY_); | ||
|
||
for (auto& nb : nbVec_) { | ||
nb->revertDivergence(); | ||
nb->resetMinSumOverflow(); | ||
} | ||
log_->report("[NesterovSolve] Revert back to snapshot coordi"); | ||
log_->info(GPL, 89, "Routability: revert back to snapshot"); | ||
} | ||
} | ||
|
||
|
@@ -658,6 +688,19 @@ void NesterovPlace::updateNextIter(const int iter) | |
|
||
// For coefficient, using average regions' overflow | ||
updateWireLengthCoef(average_overflow_); | ||
|
||
// Update divergence snapshot | ||
if (npVars_.allowRevertIfDiverge) { | ||
int64_t hpwl = nbc_->getHpwl(); | ||
if (hpwl < min_hpwl_ && average_overflow_unscaled_ <= 0.25) { | ||
min_hpwl_ = hpwl; | ||
diverge_snapshot_average_overflow_unscaled_ = average_overflow_unscaled_; | ||
diverge_snapshot_iter_ = iter; | ||
is_min_hpwl_ = true; | ||
} else { | ||
is_min_hpwl_ = false; | ||
} | ||
} | ||
} | ||
|
||
void NesterovPlace::updateDb() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,7 @@ void Replace::reset() | |
routabilityUseRudy_ = true; | ||
uniformTargetDensityMode_ = false; | ||
skipIoMode_ = false; | ||
allowRevertIfDiverge_ = false; | ||
|
||
padLeft_ = padRight_ = 0; | ||
|
||
|
@@ -198,7 +199,7 @@ void Replace::doIncrementalPlace(int threads) | |
int iter = doNesterovPlace(threads); | ||
setNesterovPlaceMaxIter(previous_max_iter); | ||
|
||
// Finish the overflow resolution from the rough placement | ||
// Finish' the overflow resolution from the rough placement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stray character There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo? |
||
log_->info(GPL, 133, "Unlocked instances"); | ||
for (auto& pb : pbVec_) { | ||
pb->unlockAll(); | ||
|
@@ -354,6 +355,7 @@ bool Replace::initNesterovPlace(int threads) | |
npVars.debug_draw_bins = gui_debug_draw_bins_; | ||
npVars.debug_inst = gui_debug_inst_; | ||
npVars.debug_start_iter = gui_debug_start_iter_; | ||
npVars.allowRevertIfDiverge = allowRevertIfDiverge_; | ||
|
||
for (const auto& nb : nbVec_) { | ||
nb->setNpVars(&npVars); | ||
|
@@ -375,7 +377,20 @@ int Replace::doNesterovPlace(int threads, int start_iter) | |
if (timingDrivenMode_) { | ||
rs_->resizeSlackPreamble(); | ||
} | ||
return np_->doNesterovPlace(start_iter); | ||
|
||
auto start = std::chrono::high_resolution_clock::now(); | ||
|
||
int return_do_nesterov = np_->doNesterovPlace(start_iter); | ||
|
||
auto end = std::chrono::high_resolution_clock::now(); | ||
std::chrono::duration<double> elapsed = end - start; | ||
debugPrint(log_, | ||
GPL, | ||
"runtime", | ||
1, | ||
"NP->doNesterovPlace() runtime: {} seconds ", | ||
elapsed.count()); | ||
return return_do_nesterov; | ||
} | ||
|
||
void Replace::setInitialPlaceMaxIter(int iter) | ||
|
@@ -485,6 +500,11 @@ void Replace::setDebug(int pause_iterations, | |
gui_debug_start_iter_ = start_iter; | ||
} | ||
|
||
void Replace::setAllowRevertIfDiverge(bool mode) | ||
{ | ||
allowRevertIfDiverge_ = !mode; | ||
} | ||
|
||
void Replace::setSkipIoMode(bool mode) | ||
{ | ||
skipIoMode_ = mode; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ sta::define_cmd_args "global_placement" {\ | |
[-timing_driven_nets_percentage timing_driven_nets_percentage]\ | ||
[-pad_left pad_left]\ | ||
[-pad_right pad_right]\ | ||
[-allow_revert_if_diverge]\ | ||
} | ||
|
||
proc global_placement { args } { | ||
|
@@ -92,7 +93,8 @@ proc global_placement { args } { | |
-disable_timing_driven \ | ||
-disable_routability_driven \ | ||
-skip_io \ | ||
-incremental} | ||
-incremental\ | ||
-allow_revert_if_diverge} | ||
|
||
# flow control for initial_place | ||
if { [info exists flags(-skip_initial_place)] } { | ||
|
@@ -327,6 +329,14 @@ proc global_placement { args } { | |
} else { | ||
utl::error GPL 130 "No rows defined in design. Use initialize_floorplan to add rows." | ||
} | ||
|
||
# Revert to saved snapshot if a divergence is detected. | ||
set allow_revert_if_diverge [info exists flags(-allow_revert_if_diverge)] | ||
gpl::set_allow_revert_if_diverge $allow_revert_if_diverge | ||
maliberty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if { $allow_revert_if_diverge } { | ||
utl::warn "GPL" 153 \ | ||
"Allow revert to saved snapshot if a divergence is detected." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a warning? If the user set this flag, it is not something unexpected. This can be a utl::info, but I'm not sure if it is necessary at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other existing messages in gpl/src/replace.tcl tend to be warnings also. I think this message is useful to make sure the non-default behavior is activated. Maybe let's leave it as ult::info? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with utl::info. |
||
} | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are going to flip this to on by default with a disable.