@@ -25,21 +25,9 @@ namespace drt {
2525
2626using utl::ThreadException;
2727
28- static inline void serializePatterns (
29- const std::unordered_map<
30- frInst*,
31- std::vector<std::unique_ptr<FlexPinAccessPattern>>>& patterns,
32- const std::string& file_name)
33- {
34- std::ofstream file (file_name.c_str ());
35- frOArchive ar (file);
36- registerTypes (ar);
37- ar << patterns;
38- file.close ();
39- }
40-
41- void FlexPA::getInsts (std::vector<frInst*>& insts)
28+ void FlexPA::buildInstsSet ()
4229{
30+ insts_set_.clear ();
4331 std::set<frInst*> target_frinsts;
4432 for (auto inst : target_insts_) {
4533 target_frinsts.insert (design_->getTopBlock ()->findInst (inst));
@@ -63,107 +51,9 @@ void FlexPA::getInsts(std::vector<frInst*>& insts)
6351 }
6452 }
6553 if (!is_skip) {
66- insts.push_back (inst.get ());
67- }
68- }
69- }
70-
71- void FlexPA::prepPattern ()
72- {
73- ProfileTask profile (" PA:pattern" );
74-
75- const auto & unique = unique_insts_.getUnique ();
76-
77- // revert access points to origin
78- unique_inst_patterns_.reserve (unique.size ());
79-
80- int cnt = 0 ;
81-
82- omp_set_num_threads (router_cfg_->MAX_THREADS );
83- ThreadException exception;
84- #pragma omp parallel for schedule(dynamic)
85- for (frInst* unique_inst : unique) {
86- try {
87- // only do for core and block cells
88- // TODO the above comment says "block cells" but that's not what the code
89- // does?
90- if (!isStdCell (unique_inst)) {
91- continue ;
92- }
93- prepPatternInst (unique_inst);
94- #pragma omp critical
95- {
96- cnt++;
97- if (router_cfg_->VERBOSE > 0 ) {
98- if (cnt % (cnt > 1000 ? 1000 : 100 ) == 0 ) {
99- logger_->info (DRT , 79 , " Complete {} unique inst patterns." , cnt);
100- }
101- }
102- }
103- } catch (...) {
104- exception.capture ();
105- }
106- }
107- exception.rethrow ();
108- if (router_cfg_->VERBOSE > 0 ) {
109- logger_->info (DRT , 81 , " Complete {} unique inst patterns." , cnt);
110- }
111- if (isDistributed ()) {
112- dst::JobMessage msg (dst::JobMessage::PIN_ACCESS ,
113- dst::JobMessage::BROADCAST ),
114- result;
115- std::unique_ptr<PinAccessJobDescription> uDesc
116- = std::make_unique<PinAccessJobDescription>();
117- std::string patterns_file = fmt::format (" {}/patterns.bin" , shared_vol_);
118- serializePatterns (unique_inst_patterns_, patterns_file);
119- uDesc->setPath (patterns_file);
120- uDesc->setType (PinAccessJobDescription::UPDATE_PATTERNS );
121- msg.setJobDescription (std::move (uDesc));
122- const bool ok
123- = dist_->sendJob (msg, remote_host_.c_str (), remote_port_, result);
124- if (!ok) {
125- logger_->error (
126- utl::DRT , 330 , " Error sending UPDATE_PATTERNS Job to cloud" );
54+ insts_set_.insert (inst.get ());
12755 }
12856 }
129-
130- // prep pattern for each row
131- std::vector<frInst*> insts;
132- std::vector<std::vector<frInst*>> inst_rows;
133- std::vector<frInst*> row_insts;
134-
135- auto instLocComp = [](frInst* const & a, frInst* const & b) {
136- const Point originA = a->getOrigin ();
137- const Point originB = b->getOrigin ();
138- if (originA.y () == originB.y ()) {
139- return (originA.x () < originB.x ());
140- }
141- return (originA.y () < originB.y ());
142- };
143-
144- getInsts (insts);
145- std::sort (insts.begin (), insts.end (), instLocComp);
146-
147- // gen rows of insts
148- int prev_y_coord = INT_MIN ;
149- int prev_x_end_coord = INT_MIN ;
150- for (auto inst : insts) {
151- Point origin = inst->getOrigin ();
152- if (origin.y () != prev_y_coord || origin.x () > prev_x_end_coord) {
153- if (!row_insts.empty ()) {
154- inst_rows.push_back (row_insts);
155- row_insts.clear ();
156- }
157- }
158- row_insts.push_back (inst);
159- prev_y_coord = origin.y ();
160- Rect inst_boundary_box = inst->getBoundaryBBox ();
161- prev_x_end_coord = inst_boundary_box.xMax ();
162- }
163- if (!row_insts.empty ()) {
164- inst_rows.push_back (row_insts);
165- }
166- prepPatternInstRows (std::move (inst_rows));
16757}
16858
16959void FlexPA::prepPatternInst (frInst* unique_inst)
0 commit comments