@@ -51,8 +51,9 @@ namespace drt {
5151using utl::ThreadException;
5252
5353static inline void serializePatterns (
54- const std::vector<std::vector<std::unique_ptr<FlexPinAccessPattern>>>&
55- patterns,
54+ const std::unordered_map<
55+ frInst*,
56+ std::vector<std::unique_ptr<FlexPinAccessPattern>>>& patterns,
5657 const std::string& file_name)
5758{
5859 std::ofstream file (file_name.c_str ());
@@ -99,7 +100,7 @@ void FlexPA::prepPattern()
99100 const auto & unique = unique_insts_.getUnique ();
100101
101102 // revert access points to origin
102- unique_inst_patterns_.resize (unique.size ());
103+ unique_inst_patterns_.reserve (unique.size ());
103104
104105 int cnt = 0 ;
105106
@@ -192,6 +193,10 @@ void FlexPA::prepPattern()
192193
193194void FlexPA::prepPatternInst (frInst* unique_inst)
194195{
196+ #pragma omp critical
197+ unique_inst_patterns_[unique_inst]
198+ = std::vector<std::unique_ptr<FlexPinAccessPattern>>();
199+
195200 int num_valid_pattern = prepPatternInstHelper (unique_inst, true );
196201
197202 if (num_valid_pattern > 0 ) {
@@ -258,7 +263,7 @@ int FlexPA::prepPatternInstHelper(frInst* unique_inst, const bool use_x)
258263}
259264
260265int FlexPA::genPatterns (
261- frInst* inst ,
266+ frInst* unique_inst ,
262267 const std::vector<std::pair<frMPin*, frInstTerm*>>& pins)
263268{
264269 if (pins.empty ()) {
@@ -282,7 +287,7 @@ int FlexPA::genPatterns(
282287 std::set<std::pair<int , int >> viol_access_points;
283288 int num_valid_pattern = 0 ;
284289
285- num_valid_pattern += FlexPA::genPatternsHelper (inst ,
290+ num_valid_pattern += FlexPA::genPatternsHelper (unique_inst ,
286291 pins,
287292 inst_access_patterns,
288293 used_access_points,
@@ -293,7 +298,7 @@ int FlexPA::genPatterns(
293298 auto reversed_pins = pins;
294299 reverse (reversed_pins.begin (), reversed_pins.end ());
295300
296- num_valid_pattern += FlexPA::genPatternsHelper (inst ,
301+ num_valid_pattern += FlexPA::genPatternsHelper (unique_inst ,
297302 reversed_pins,
298303 inst_access_patterns,
299304 used_access_points,
@@ -305,7 +310,7 @@ int FlexPA::genPatterns(
305310}
306311
307312int FlexPA::genPatternsHelper (
308- frInst* inst ,
313+ frInst* unique_inst ,
309314 const std::vector<std::pair<frMPin*, frInstTerm*>>& pins,
310315 std::set<std::vector<int >>& inst_access_patterns,
311316 std::set<std::pair<int , int >>& used_access_points,
@@ -327,15 +332,15 @@ int FlexPA::genPatternsHelper(
327332
328333 for (int i = 0 ; i < router_cfg_->ACCESS_PATTERN_END_ITERATION_NUM ; i++) {
329334 genPatternsReset (nodes, pins);
330- genPatternsPerform (inst ,
335+ genPatternsPerform (unique_inst ,
331336 nodes,
332337 pins,
333338 vio_edge,
334339 used_access_points,
335340 viol_access_points,
336341 max_access_point_size);
337342 bool is_valid = false ;
338- if (genPatternsCommit (inst ,
343+ if (genPatternsCommit (unique_inst ,
339344 nodes,
340345 pins,
341346 is_valid,
@@ -483,7 +488,7 @@ bool FlexPA::genPatternsGC(
483488}
484489
485490void FlexPA::genPatternsPerform (
486- frInst* inst ,
491+ frInst* unique_inst ,
487492 std::vector<std::vector<std::unique_ptr<FlexDPNode>>>& nodes,
488493 const std::vector<std::pair<frMPin*, frInstTerm*>>& pins,
489494 std::vector<int >& vio_edges,
@@ -510,7 +515,7 @@ void FlexPA::genPatternsPerform(
510515 continue ;
511516 }
512517
513- const int edge_cost = getEdgeCost (inst ,
518+ const int edge_cost = getEdgeCost (unique_inst ,
514519 prev_node,
515520 curr_node,
516521 pins,
@@ -530,7 +535,7 @@ void FlexPA::genPatternsPerform(
530535}
531536
532537int FlexPA::getEdgeCost (
533- frInst* inst ,
538+ frInst* unique_inst ,
534539 FlexDPNode* prev_node,
535540 FlexDPNode* curr_node,
536541 const std::vector<std::pair<frMPin*, frInstTerm*>>& pins,
@@ -556,7 +561,7 @@ int FlexPA::getEdgeCost(
556561 if (vio_edges[edge_idx] != -1 ) {
557562 has_vio = (vio_edges[edge_idx] == 1 );
558563 } else {
559- dbTransform xform = inst ->getNoRotationTransform ();
564+ dbTransform xform = unique_inst ->getNoRotationTransform ();
560565 // check DRC
561566 std::vector<std::pair<frConnFig*, frBlockObject*>> objs;
562567 const auto & [pin_1, inst_term_1] = pins[prev_pin_idx];
@@ -684,7 +689,7 @@ std::vector<int> FlexPA::extractAccessPatternFromNodes(
684689}
685690
686691bool FlexPA::genPatternsCommit (
687- frInst* inst ,
692+ frInst* unique_inst ,
688693 const std::vector<std::vector<std::unique_ptr<FlexDPNode>>>& nodes,
689694 const std::vector<std::pair<frMPin*, frInstTerm*>>& pins,
690695 bool & is_valid,
@@ -711,8 +716,8 @@ bool FlexPA::genPatternsCommit(
711716 for (int pin_idx = 0 ; pin_idx < (int ) pins.size (); pin_idx++) {
712717 auto acc_point_idx = access_pattern[pin_idx];
713718 auto & [pin, inst_term] = pins[pin_idx];
714- target_obj = inst ;
715- const int pin_access_idx = unique_insts_.getPAIndex (inst );
719+ target_obj = unique_inst ;
720+ const int pin_access_idx = unique_insts_.getPAIndex (unique_inst );
716721 const auto pa = pin->getPinAccess (pin_access_idx);
717722 const auto access_point = pa->getAccessPoint (acc_point_idx);
718723 pin_to_access_point[pin] = access_point;
@@ -724,7 +729,7 @@ bool FlexPA::genPatternsCommit(
724729 auto rvia = via.get ();
725730 temp_vias.push_back (std::move (via));
726731
727- dbTransform xform = inst ->getNoRotationTransform ();
732+ dbTransform xform = unique_inst ->getNoRotationTransform ();
728733 Point pt (access_point->getPoint ());
729734 xform.apply (pt);
730735 rvia->setOrigin (pt);
@@ -741,7 +746,7 @@ bool FlexPA::genPatternsCommit(
741746 frCoord left_pt = std::numeric_limits<frCoord>::max ();
742747 frCoord right_pt = std::numeric_limits<frCoord>::min ();
743748
744- for (auto & inst_term : inst ->getInstTerms ()) {
749+ for (auto & inst_term : unique_inst ->getInstTerms ()) {
745750 if (isSkipInstTerm (inst_term.get ())) {
746751 continue ;
747752 }
@@ -778,8 +783,7 @@ bool FlexPA::genPatternsCommit(
778783 if (target_obj != nullptr
779784 && genPatternsGC ({target_obj}, objs, Commit, &owners)) {
780785 pin_access_pattern->updateCost ();
781- const int inst_idx = unique_insts_.getIndex (inst);
782- unique_inst_patterns_[inst_idx].push_back (std::move (pin_access_pattern));
786+ unique_inst_patterns_[unique_inst].push_back (std::move (pin_access_pattern));
783787 // genPatternsPrint(nodes, pins);
784788 is_valid = true ;
785789 } else {
@@ -811,8 +815,8 @@ void FlexPA::genPatternsPrintDebug(
811815 dbTransform xform;
812816 auto & [pin, inst_term] = pins[0 ];
813817 if (inst_term) {
814- frInst* inst = inst_term->getInst ();
815- xform = inst ->getNoRotationTransform ();
818+ frInst* unique_inst = inst_term->getInst ();
819+ xform = unique_inst ->getNoRotationTransform ();
816820 }
817821
818822 std::cout << " failed pattern:" ;
@@ -822,9 +826,9 @@ void FlexPA::genPatternsPrintDebug(
822826 // non-virtual node
823827 if (pin_cnt != (int ) pins.size ()) {
824828 auto & [pin, inst_term] = pins[pin_cnt];
825- auto inst = inst_term->getInst ();
829+ auto unique_inst = inst_term->getInst ();
826830 std::cout << " " << inst_term->getTerm ()->getName ();
827- const int pin_access_idx = unique_insts_.getPAIndex (inst );
831+ const int pin_access_idx = unique_insts_.getPAIndex (unique_inst );
828832 auto pa = pin->getPinAccess (pin_access_idx);
829833 auto [curr_pin_idx, curr_acc_point_idx] = curr_node->getIdx ();
830834 Point pt (pa->getAccessPoint (curr_acc_point_idx)->getPoint ());
@@ -855,17 +859,17 @@ void FlexPA::genPatternsPrint(
855859 // non-virtual node
856860 if (pin_cnt != (int ) pins.size ()) {
857861 auto & [pin, inst_term] = pins[pin_cnt];
858- auto inst = inst_term->getInst ();
859- const int pin_access_idx = unique_insts_.getPAIndex (inst );
862+ auto unique_inst = inst_term->getInst ();
863+ const int pin_access_idx = unique_insts_.getPAIndex (unique_inst );
860864 auto pa = pin->getPinAccess (pin_access_idx);
861865 auto [curr_pin_idx, curr_acc_point_idx] = curr_node->getIdx ();
862866 std::unique_ptr<frVia> via = std::make_unique<frVia>(
863867 pa->getAccessPoint (curr_acc_point_idx)->getViaDef ());
864868 Point pt (pa->getAccessPoint (curr_acc_point_idx)->getPoint ());
865- std::cout << " gccleanvia " << inst ->getMaster ()->getName () << " "
869+ std::cout << " gccleanvia " << unique_inst ->getMaster ()->getName () << " "
866870 << inst_term->getTerm ()->getName () << " "
867871 << via->getViaDef ()->getName () << " " << pt.x () << " " << pt.y ()
868- << " " << inst ->getOrient ().getString () << " \n " ;
872+ << " " << unique_inst ->getOrient ().getString () << " \n " ;
869873 }
870874
871875 curr_node = curr_node->getPrevNode ();
0 commit comments