@@ -365,165 +365,170 @@ void NesterovPlace::runTimingDriven(const int iter,
365365 const std::string& timing_driven_dir,
366366 const int routability_driven_revert_count,
367367 int & timing_driven_count,
368- int64_t & td_accumulated_delta_area)
368+ int64_t & td_accumulated_delta_area,
369+ bool is_routability_gpl_iter)
369370{
370371 // timing driven feature
371372 // if virtual, do reweight on timing-critical nets,
372373 // otherwise keep all modifications by rsz.
374+ if (npVars_.timingDrivenMode
375+ && tb_->isTimingNetWeightOverflow (average_overflow_unscaled_)
376+ && (!is_routability_gpl_iter || !npVars_.routability_driven_mode )) {
377+ // update db's instance location from current density coordinates
378+ updateDb ();
373379
374- // update db's instance location from current density coordinates
375- updateDb ();
376-
377- if (graphics_) {
378- graphics_->addTimingDrivenIter (iter);
380+ if (graphics_) {
381+ graphics_->addTimingDrivenIter (iter);
379382
380- if (npVars_.debug_generate_images ) {
381- graphics_->saveLabeledImage (
382- fmt::format (" {}/timing_{:05d}_0.png" , timing_driven_dir, iter),
383- fmt::format (" Iter {} |R: {} |T: {} before TD" ,
384- iter,
385- routability_driven_revert_count,
386- timing_driven_count),
387- /* select_buffers = */ false );
383+ if (npVars_.debug_generate_images ) {
384+ graphics_->saveLabeledImage (
385+ fmt::format (" {}/timing_{:05d}_0.png" , timing_driven_dir, iter),
386+ fmt::format (" Iter {} |R: {} |T: {} before TD" ,
387+ iter,
388+ routability_driven_revert_count,
389+ timing_driven_count),
390+ /* select_buffers = */ false );
391+ }
388392 }
389- }
390393
391- // Call resizer's estimateRC API to fill in PEX using placed locations,
392- // Call sta's API to extract worst timing paths,
393- // and update GNet's weights from worst timing paths.
394- //
395- // See timingBase.cpp in detail
396- bool virtual_td_iter
397- = (average_overflow_unscaled_ > npVars_.keepResizeBelowOverflow );
394+ // Call resizer's estimateRC API to fill in PEX using placed locations,
395+ // Call sta's API to extract worst timing paths,
396+ // and update GNet's weights from worst timing paths.
397+ //
398+ // See timingBase.cpp in detail
399+ bool virtual_td_iter
400+ = (average_overflow_unscaled_ > npVars_.keepResizeBelowOverflow );
398401
399- log_->info (GPL,
400- 100 ,
401- " Timing-driven iteration {}/{}, virtual: {}." ,
402- ++npVars_.timingDrivenIterCounter ,
403- tb_->getTimingNetWeightOverflowSize (),
404- virtual_td_iter);
402+ log_->info (GPL,
403+ 100 ,
404+ " Timing-driven iteration {}/{}, virtual: {}." ,
405+ ++npVars_.timingDrivenIterCounter ,
406+ tb_->getTimingNetWeightOverflowSize (),
407+ virtual_td_iter);
405408
406- log_->info (GPL,
407- 101 ,
408- " Iter: {}, overflow: {:.3f}, keep resizer changes at: {}, "
409- " HPWL: {}" ,
410- iter + 1 ,
411- average_overflow_unscaled_,
412- npVars_.keepResizeBelowOverflow ,
413- nbc_->getHpwl ());
414-
415- if (!virtual_td_iter) {
416- db_cbk_->addOwner (pbc_->db ()->getChip ()->getBlock ());
417- } else {
418- db_cbk_->removeOwner ();
419- }
409+ log_->info (GPL,
410+ 101 ,
411+ " Iter: {}, overflow: {:.3f}, keep resizer changes at: {}, "
412+ " HPWL: {}" ,
413+ iter + 1 ,
414+ average_overflow_unscaled_,
415+ npVars_.keepResizeBelowOverflow ,
416+ nbc_->getHpwl ());
417+
418+ if (!virtual_td_iter) {
419+ db_cbk_->addOwner (pbc_->db ()->getChip ()->getBlock ());
420+ } else {
421+ db_cbk_->removeOwner ();
422+ }
420423
421- auto block = pbc_->db ()->getChip ()->getBlock ();
422- int nb_total_gcells_delta = 0 ;
423- int nb_gcells_before_td = 0 ;
424- int nb_gcells_after_td = 0 ;
425- int nbc_total_gcells_before_td = nbc_->getNewGcellsCount ();
426- for (auto & nb : nbVec_) {
427- nb_gcells_before_td += nb->getGCells ().size ();
428- }
424+ auto block = pbc_->db ()->getChip ()->getBlock ();
425+ int nb_total_gcells_delta = 0 ;
426+ int nb_gcells_before_td = 0 ;
427+ int nb_gcells_after_td = 0 ;
428+ int nbc_total_gcells_before_td = nbc_->getNewGcellsCount ();
429+ for (auto & nb : nbVec_) {
430+ nb_gcells_before_td += nb->getGCells ().size ();
431+ }
429432
430- bool shouldTdProceed = tb_->executeTimingDriven (virtual_td_iter);
431- nbVec_[0 ]->setTrueReprintIterHeader ();
432- ++timing_driven_count;
433+ bool shouldTdProceed = tb_->executeTimingDriven (virtual_td_iter);
434+ nbVec_[0 ]->setTrueReprintIterHeader ();
435+ ++timing_driven_count;
433436
434- td_accumulated_delta_area += nbc_->getDeltaArea ();
435- for (auto & nb : nbVec_) {
436- nb_gcells_after_td += nb->getGCells ().size ();
437- }
438- nb_total_gcells_delta = nb_gcells_after_td - nb_gcells_before_td;
439- if (nb_total_gcells_delta != nbc_->getNewGcellsCount ()) {
440- log_->warn (GPL,
441- 92 ,
442- " Mismatch in #cells between central object and all regions. "
443- " NesterovBaseCommon: {}, Summing all regions: {}" ,
444- nbc_->getNewGcellsCount (),
445- nb_total_gcells_delta);
446- }
437+ td_accumulated_delta_area += nbc_->getDeltaArea ();
438+ for (auto & nb : nbVec_) {
439+ nb_gcells_after_td += nb->getGCells ().size ();
440+ }
441+ nb_total_gcells_delta = nb_gcells_after_td - nb_gcells_before_td;
442+ if (nb_total_gcells_delta != nbc_->getNewGcellsCount ()) {
443+ log_->warn (GPL,
444+ 92 ,
445+ " Mismatch in #cells between central object and all regions. "
446+ " NesterovBaseCommon: {}, Summing all regions: {}" ,
447+ nbc_->getNewGcellsCount (),
448+ nb_total_gcells_delta);
449+ }
447450
448- if (graphics_ && npVars_.debug_generate_images ) {
449- updateDb ();
450- bool select_buffers = !virtual_td_iter;
451- graphics_->saveLabeledImage (
452- fmt::format (" {}/timing_{:05d}_1.png" , timing_driven_dir, iter),
453- fmt::format (" Iter {} |R: {} |T: {} after TD" ,
454- iter,
455- routability_driven_revert_count,
456- timing_driven_count),
457- select_buffers);
458- }
451+ if (graphics_ && npVars_.debug_generate_images ) {
452+ updateDb ();
453+ bool select_buffers = !virtual_td_iter;
454+ graphics_->saveLabeledImage (
455+ fmt::format (" {}/timing_{:05d}_1.png" , timing_driven_dir, iter),
456+ fmt::format (" Iter {} |R: {} |T: {} after TD" ,
457+ iter,
458+ routability_driven_revert_count,
459+ timing_driven_count),
460+ select_buffers);
461+ }
459462
460- if (!virtual_td_iter) {
461- for (auto & nesterov : nbVec_) {
462- nesterov->updateGCellState (wireLengthCoefX_, wireLengthCoefY_);
463- // updates order in routability:
464- // 1. change areas
465- // 2. set target density with delta area
466- // 3. updateareas
467- // 4. updateDensitySize
468-
469- nesterov->setTargetDensity (
470- static_cast <float >(nbc_->getDeltaArea ()
471- + nesterov->nesterovInstsArea ()
472- + nesterov->getTotalFillerArea ())
473- / static_cast <float >(nesterov->whiteSpaceArea ()));
474-
475- float rsz_delta_area_microns
476- = block->dbuAreaToMicrons (nbc_->getDeltaArea ());
477- float rsz_delta_area_percentage
478- = (nbc_->getDeltaArea ()
479- / static_cast <float >(nesterov->nesterovInstsArea ()))
480- * 100 .0f ;
481- log_->info (
482- GPL,
483- 107 ,
484- " Timing-driven: repair_design delta area: {:.3f} um^2 ({:+.2f}%)" ,
485- rsz_delta_area_microns,
486- rsz_delta_area_percentage);
487-
488- float new_gcells_percentage = 0 .0f ;
489- if (nbc_total_gcells_before_td > 0 ) {
490- new_gcells_percentage
491- = (nbc_->getNewGcellsCount ()
492- / static_cast <float >(nbc_total_gcells_before_td))
463+ if (!virtual_td_iter) {
464+ for (auto & nesterov : nbVec_) {
465+ nesterov->updateGCellState (wireLengthCoefX_, wireLengthCoefY_);
466+ // updates order in routability:
467+ // 1. change areas
468+ // 2. set target density with delta area
469+ // 3. updateareas
470+ // 4. updateDensitySize
471+
472+ nesterov->setTargetDensity (
473+ static_cast <float >(nbc_->getDeltaArea ()
474+ + nesterov->nesterovInstsArea ()
475+ + nesterov->getTotalFillerArea ())
476+ / static_cast <float >(nesterov->whiteSpaceArea ()));
477+
478+ float rsz_delta_area_microns
479+ = block->dbuAreaToMicrons (nbc_->getDeltaArea ());
480+ float rsz_delta_area_percentage
481+ = (nbc_->getDeltaArea ()
482+ / static_cast <float >(nesterov->nesterovInstsArea ()))
493483 * 100 .0f ;
484+ log_->info (
485+ GPL,
486+ 107 ,
487+ " Timing-driven: repair_design delta area: {:.3f} um^2 ({:+.2f}%)" ,
488+ rsz_delta_area_microns,
489+ rsz_delta_area_percentage);
490+
491+ float new_gcells_percentage = 0 .0f ;
492+ if (nbc_total_gcells_before_td > 0 ) {
493+ new_gcells_percentage
494+ = (nbc_->getNewGcellsCount ()
495+ / static_cast <float >(nbc_total_gcells_before_td))
496+ * 100 .0f ;
497+ }
498+ log_->info (
499+ GPL,
500+ 108 ,
501+ " Timing-driven: repair_design, gpl cells created: {} ({:+.2f}%)" ,
502+ nbc_->getNewGcellsCount (),
503+ new_gcells_percentage);
504+
505+ log_->info (GPL,
506+ 110 ,
507+ " Timing-driven: new target density: {}" ,
508+ nesterov->targetDensity ());
509+ nbc_->resetDeltaArea ();
510+ nbc_->resetNewGcellsCount ();
511+ nesterov->updateAreas ();
512+ nesterov->updateDensitySize ();
494513 }
495- log_->info (
496- GPL,
497- 108 ,
498- " Timing-driven: repair_design, gpl cells created: {} ({:+.2f}%)" ,
499- nbc_->getNewGcellsCount (),
500- new_gcells_percentage);
501514
502- log_->info (GPL,
503- 110 ,
504- " Timing-driven: new target density: {}" ,
505- nesterov->targetDensity ());
506- nbc_->resetDeltaArea ();
507- nbc_->resetNewGcellsCount ();
508- nesterov->updateAreas ();
509- nesterov->updateDensitySize ();
515+ // update snapshot after non-virtual TD
516+ int64_t hpwl = nbc_->getHpwl ();
517+ if (average_overflow_unscaled_ <= 0.25 ) {
518+ min_hpwl_ = hpwl;
519+ diverge_snapshot_average_overflow_unscaled_
520+ = average_overflow_unscaled_;
521+ diverge_snapshot_iter_ = iter + 1 ;
522+ is_min_hpwl_ = true ;
523+ }
510524 }
511525
512- // update snapshot after non-virtual TD
513- int64_t hpwl = nbc_->getHpwl ();
514- if (average_overflow_unscaled_ <= 0.25 ) {
515- min_hpwl_ = hpwl;
516- diverge_snapshot_average_overflow_unscaled_ = average_overflow_unscaled_;
517- diverge_snapshot_iter_ = iter + 1 ;
518- is_min_hpwl_ = true ;
526+ // problem occured
527+ // escape timing driven later
528+ if (!shouldTdProceed) {
529+ npVars_.timingDrivenMode = false ;
519530 }
520531 }
521-
522- // problem occured
523- // escape timing driven later
524- if (!shouldTdProceed) {
525- npVars_.timingDrivenMode = false ;
526- }
527532}
528533
529534bool NesterovPlace::isDiverged (float & diverge_snapshot_WlCoefX,
@@ -1010,15 +1015,12 @@ int NesterovPlace::doNesterovPlace(const int start_iter)
10101015 ++npVars_.maxNesterovIter ;
10111016 }
10121017
1013- if (npVars_.timingDrivenMode
1014- && tb_->isTimingNetWeightOverflow (average_overflow_unscaled_)
1015- && (!is_routability_gpl_iter || !npVars_.routability_driven_mode )) {
1016- runTimingDriven (nesterov_iter,
1017- timing_driven_dir,
1018- routability_driven_revert_count,
1019- timing_driven_count,
1020- td_accumulated_delta_area);
1021- }
1018+ runTimingDriven (nesterov_iter,
1019+ timing_driven_dir,
1020+ routability_driven_revert_count,
1021+ timing_driven_count,
1022+ td_accumulated_delta_area,
1023+ is_routability_gpl_iter);
10221024
10231025 if (isDiverged (diverge_snapshot_WlCoefX,
10241026 diverge_snapshot_WlCoefY,
0 commit comments