@@ -169,6 +169,7 @@ class FastRouteCore
169169 NetRouteMap run ();
170170 int totalOverflow () const { return total_overflow_; }
171171 bool has2Doverflow () const { return has_2D_overflow_; }
172+ int getSnapshotBatchCount () const { return snapshot_batch_count_; }
172173 void getBlockage (odb::dbTechLayer* layer,
173174 int x,
174175 int y,
@@ -244,6 +245,12 @@ class FastRouteCore
244245 void setCongestionReportFile (const char * congestion_file_name);
245246 void setGridMax (int x_max, int y_max);
246247 void setDetourPenalty (int penalty);
248+ void setNumThreads (int num_threads) { num_threads_ = num_threads; }
249+ void setSnapshotBatchedWidth (int snapshot_batched_width)
250+ {
251+ snapshot_batched_width_ = snapshot_batched_width;
252+ }
253+ int getSnapshotBatchedWidth () const { return snapshot_batched_width_; }
247254 void getCongestionNets (std::set<odb::dbNet*>& congestion_nets);
248255 void computeCongestionInformation ();
249256 std::vector<int > getOriginalResources ();
@@ -326,6 +333,24 @@ class FastRouteCore
326333 int L,
327334 const CostParams& cost_params,
328335 float & slack_th);
336+ void mazeRouteMSMDSequential (int iter,
337+ int expand,
338+ int ripup_threshold,
339+ int maze_edge_threshold,
340+ bool ordering,
341+ int via,
342+ int L,
343+ const CostParams& cost_params,
344+ float & slack_th);
345+ bool runSnapshotBatchedMazeRoute (int iter,
346+ int expand,
347+ int ripup_threshold,
348+ int maze_edge_threshold,
349+ bool ordering,
350+ int via,
351+ int L,
352+ const CostParams& cost_params,
353+ float & slack_th);
329354 void convertToMazeroute ();
330355 int getOverflow2D (int * maxOverflow);
331356 int getOverflow2Dmaze (int * maxOverflow, int * tUsage);
@@ -621,6 +646,47 @@ class FastRouteCore
621646 void copyBR ();
622647 void copyRS ();
623648 void freeRR ();
649+ std::vector<int > getMazeRouteNetOrder (bool ordering, float & slack_th);
650+ bool hasNonSoftNdrNets () const ;
651+ int resolveSnapshotExecutionThreads (int work_items) const ;
652+ int resolveSnapshotWaveSize (int available_batch_count) const ;
653+ int resolveSnapshotBaseBatchSize (int net_count) const ;
654+ bool useSnapshotBatchRouting (int net_count) const ;
655+ int resolveSnapshotBatchIterationLimit (int net_count) const ;
656+ bool useSnapshotBatchRoutingForIteration (int iter, int net_count) const ;
657+ int resolveSnapshotNetsForBatch (int iter, int net_count) const ;
658+ std::unique_ptr<FastRouteCore> buildSnapshotBatchWorker () const ;
659+ void syncSnapshotBatchWorker (const FastRouteCore& snapshot,
660+ const std::vector<int >& batch_net_ids);
661+ void applySnapshotBatchRoute (int net_id, StTree&& sttree);
662+ void updatePlanarNetUsage (const StTree& sttree, FrNet* net, int edge_cost);
663+ void resetSnapshotBatchStats ();
664+
665+ // Timing data collected during run(), reported via reportRunMetrics().
666+ struct RunTimings
667+ {
668+ double total = 0.0 ;
669+ double initial_rsmt = 0.0 ;
670+ double route_l = 0.0 ;
671+ double congestion_rsmt = 0.0 ;
672+ double new_route_l = 0.0 ;
673+ double spiral = 0.0 ;
674+ double route_z = 0.0 ;
675+ double monotonic = 0.0 ;
676+ double overflow_iterations = 0.0 ;
677+ double finalization = 0.0 ;
678+ };
679+ void reportRunMetrics (const RunTimings& timings,
680+ int num_vias,
681+ int final_length);
682+
683+ // Returns true if the overflow loop should break due to snapshot
684+ // convergence patience being exhausted.
685+ bool checkSnapshotConvergence (int past_cong,
686+ int & bmfl,
687+ int & bwcnt,
688+ int iter,
689+ int snapshot_batch_count_before);
624690 int edgeShift (stt::Tree& t, int net);
625691 int edgeShiftNew (stt::Tree& t, int net);
626692
@@ -635,6 +701,23 @@ class FastRouteCore
635701 static const int BIG_INT = 1e9 ; // big integer used as infinity
636702 static const int HCOST = 5000 ;
637703
704+ // Snapshot-batched routing constants.
705+ // Nets are partitioned into batches and routed in parallel waves against
706+ // a frozen graph snapshot. The user-supplied snapshot_batched_width_
707+ // controls the maximum batches per wave (independent of thread count) and
708+ // gates the minimum routable net count (2 * width) needed to attempt
709+ // batching.
710+ //
711+ // kSnapshotLowOverflowForSerialCleanup /
712+ // kSnapshotLowMaxOverflowForSerialCleanup:
713+ // overflow thresholds below which batching is disabled for the run,
714+ // because the design is already near-converged.
715+ // kSnapshotCleanupPatience: how many non-improving iterations to tolerate
716+ // in the snapshot cleanup phase before breaking.
717+ static constexpr int kSnapshotLowOverflowForSerialCleanup = 1500 ;
718+ static constexpr int kSnapshotLowMaxOverflowForSerialCleanup = 32 ;
719+ static constexpr int kSnapshotCleanupPatience = 12 ;
720+
638721 int max_degree_;
639722 std::vector<int > cap_per_layer_;
640723 std::vector<int > usage_per_layer_;
@@ -647,6 +730,12 @@ class FastRouteCore
647730 std::string congestion_file_name_;
648731 std::vector<odb::dbTechLayerDir> layer_directions_;
649732 std::vector<odb::dbTechLayer*> db_layers_;
733+ int num_threads_;
734+ // When false, nets_ contains borrowed pointers from a parent
735+ // FastRouteCore (snapshot-batch workers). Workers must not outlive
736+ // the parent's nets_ lifetime.
737+ bool owns_nets_;
738+ int snapshot_batched_width_;
650739 int x_range_;
651740 int y_range_;
652741
@@ -746,6 +835,15 @@ class FastRouteCore
746835
747836 std::vector<int > net_ids_;
748837
838+ // Maze 2D variables
839+ std::vector<bool > pop_heap2_2D_;
840+ std::vector<double *> src_heap_2D_;
841+ std::vector<double *> dest_heap_2D_;
842+ multi_array<double , 2 > d1_2D_;
843+ multi_array<double , 2 > d2_2D_;
844+ std::vector<bool > visited_2D_;
845+ std::vector<int > queue_2D_;
846+
749847 // Maze 3D variables
750848 multi_array<Direction, 3 > directions_3D_;
751849 multi_array<int , 3 > corr_edge_3D_;
@@ -756,6 +854,15 @@ class FastRouteCore
756854 multi_array<int , 3 > d1_3D_;
757855 multi_array<int , 3 > d2_3D_;
758856 multi_array<int , 3 > path_len_3D_;
857+ double snapshot_batch_sync_time_ = 0.0 ;
858+ double snapshot_batch_route_time_ = 0.0 ;
859+ double snapshot_batch_apply_time_ = 0.0 ;
860+ int snapshot_batch_count_ = 0 ;
861+ int snapshot_batch_net_count_ = 0 ;
862+ int snapshot_batch_wave_count_ = 0 ;
863+ bool snapshot_batch_disabled_for_run_ = false ;
864+ bool snapshot_cleanup_active_ = false ;
865+ bool has_non_soft_ndr_nets_ = false ;
759866 int detour_penalty_;
760867};
761868
0 commit comments