systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
GlobalSuspensionAutomata.cpp
Go to the documentation of this file.
2using namespace systemc_clang;
3
5 raw_ostream &os,
6 ASTContext *a)
7 : _systemcModel(systemCmodel), _os(os), _a(a) {}
8
10
12 // GPU map algorithm.
13 // Input is the global sauto
14 // First identify transitions with the same time-stamp
15 // Need data structures of the form <time-stamp, vector of dp segments>
16 // Using the above data structure, for each time-stamp set, we identify which
17 // ones will go on the gpu.
18 //_os <<"\n Initialize gpu map\n";
19
20 for (int i = 0; i < _globalSauto.size(); i++) {
21 Transition *aTransition = _globalSauto.at(i);
22 for (int j = 0; j < _globalSauto.size(); j++) {
23 Transition *bTransition = _globalSauto.at(j);
24 if (aTransition != bTransition) {
25 transitionTimeMapType::iterator aTransitionFound =
26 _transitionTimeMap.find(aTransition);
27 transitionTimeMapType::iterator bTransitionFound =
28 _transitionTimeMap.find(bTransition);
29 timePairType aTimePair = aTransitionFound->second;
30 timePairType bTimePair = bTransitionFound->second;
31
32 if (aTimePair.first == bTimePair.first &&
33 aTimePair.second == bTimePair.second) {
34 // Transitions with same time-stamp
35 vector<SusCFG *> aCodeBlocks = aTransition->returnCodeBlocks();
36 vector<SusCFG *> bCodeBlocks = bTransition->returnCodeBlocks();
37 vector<SusCFG *> susCFGBlockList;
38 // iterate through each code block set and accumulate DP blocks.
39 // debug susCFGBlockGPUMacroMap
40
41 timePairType timePair = make_pair(aTimePair.first, aTimePair.second);
42 if (_commonTimeDPMap.find(timePair) == _commonTimeDPMap.end()) {
43 for (int k = 0; k < aCodeBlocks.size(); k++) {
44 if (_susCFGBlockGPUMacroMap.find(aCodeBlocks.at(k)) !=
46 // DP segment found
47 // if (notInVector(susCFGBlockList, aCodeBlocks.at(k))){
48 susCFGBlockList.push_back(aCodeBlocks.at(k));
49 //}
50 }
51 }
52 for (int k = 0; k < bCodeBlocks.size(); k++) {
53 if (_susCFGBlockGPUMacroMap.find(bCodeBlocks.at(k)) !=
55 // DP segment found
56 // if(notInVector(susCFGBlockList, bCodeBlocks.at(k))) {
57 susCFGBlockList.push_back(bCodeBlocks.at(k));
58 //}
59 }
60 }
61 _commonTimeDPMap.insert(
62 commonTimeDPPairType(timePair, susCFGBlockList));
63 } else {
64 commonTimeDPMapType::iterator commonTimeFound =
65 _commonTimeDPMap.find(timePair);
66 vector<SusCFG *> tmpVec = commonTimeFound->second;
67 for (int k = 0; k < bCodeBlocks.size(); k++) {
68 if (_susCFGBlockGPUMacroMap.find(bCodeBlocks.at(k)) !=
70 // DP segment found
71 if (!isElementPresent(tmpVec, bCodeBlocks.at(k))) {
72 susCFGBlockList.push_back(bCodeBlocks.at(k));
73 }
74 }
75 }
76 tmpVec.insert(tmpVec.end(), susCFGBlockList.begin(),
77 susCFGBlockList.end());
78 _commonTimeDPMap.erase(timePair);
79 _commonTimeDPMap.insert(commonTimeDPPairType(timePair, tmpVec));
80 }
81 }
82 }
83 }
84 }
85
86 // Actual gpu map algo starts here....
87 // use _commonTimeDPMap and for each timePair with more than one DP segment,
88 // do pseudo-knapsacking algo
89 /*
90 for (commonTimeDPMapType::iterator cit = _commonTimeDPMap.begin(),
91 cite = _commonTimeDPMap.end(); cit != cite; cit++) { _os <<"\nTime : "
92 <<cit->first.first<<" " <<cit->first.second<<"\n"; for (int i = 0;
93 i<cit->second.size(); i++) { _os <<"\n Block ID: "<<cit->second.at(i)<<" "
94 <<cit->second.at(i)->getBlockID();
95 }
96 }
97 */
98 for (commonTimeDPMapType::iterator cit = _commonTimeDPMap.begin(),
99 cite = _commonTimeDPMap.end();
100 cit != cite; cit++) {
101 timePairType timePair = cit->first;
102 //_os <<"\n Looking at time-pair : " <<timePair.first<<" "
103 //<<timePair.second;
104 vector<SusCFG *> susCFGBlockList = cit->second;
105 // l and u are lower and upper limits of the makespan.
106 // c_ideal and c_actual are ideal and actual makespan values.
107 float l = 0.0;
108 float u = 0.0;
109 float c_ideal = u;
110 float c_actual = u;
111
112 for (int i = 0; i < susCFGBlockList.size(); i++) {
113 if (_susCFGBlockGPUMacroMap.find(susCFGBlockList.at(i)) !=
115 // Found a DP segment
116 susCFGBlockGPUMacroMapType::iterator gpuMacroFound =
117 _susCFGBlockGPUMacroMap.find(susCFGBlockList.at(i));
118
119 GPUMacro *gpuMacro = gpuMacroFound->second;
120 u = u + max(gpuMacro->getGPUTime(), gpuMacro->getCPUTime());
121 //_os <<"\n Value of u : " <<u;
122 }
123 }
124 c_actual = u;
125 while (u != l) {
126 c_ideal = (u + l) / 2;
127 //_os <<"\n Value of c_ideal : " <<c_ideal;
128 if (GPUMap(c_ideal, susCFGBlockList, c_actual)) {
129 //_os <<"\n Changing value of u to : "<<c_actual;
130 u = c_actual;
131 } else {
132 //_os <<"\n Changing value of l to : "<<c_actual;
133 l = c_actual;
134 }
135 }
136 }
137}
138
140 vector<SusCFG *> susCFGBlockList,
141 float &c_actual) {
142 vector<SusCFG *> gpuFitSusCFGVector;
143 vector<SusCFG *> gpuUnfitSusCFGVector;
144 for (int i = 0; i < susCFGBlockList.size(); i++) {
145 if (_susCFGBlockGPUMacroMap.find(susCFGBlockList.at(i)) !=
147 susCFGBlockGPUMacroMapType::iterator gpuMacroFound =
148 _susCFGBlockGPUMacroMap.find(susCFGBlockList.at(i));
149 GPUMacro *gpuMacro = gpuMacroFound->second;
150 //_os <<"\n GPU macro gpu time : " <<gpuMacro->getGPUTime()<<" CPU time :
151 //" <<gpuMacro->getCPUTime();
152
153 if (gpuMacro->getGPUTime() <= c_ideal) {
154 // susCFGBlockList.at(i)->addGPUFit();
155 // gpuMacro->addGPUFit();
156 //_os <<"\n Pushing block : " <<susCFGBlockList.at(i)<<" into
157 //gpuFitSusCFGVector";
158 gpuFitSusCFGVector.push_back(susCFGBlockList.at(i));
159 } else {
160 // susCFGBlockList.at(i)->denyGPUFit();
161 // gpuMacro->denyGPUFit();
162 gpuUnfitSusCFGVector.push_back(susCFGBlockList.at(i));
163 }
164 }
165 }
166 //_os <<"\n arranging susCFGblocks";
167 vector<SusCFG *> orderedSusCFGList =
168 arrangeGPUSusCFGBlocks(gpuFitSusCFGVector);
170 /*
171 for (int i = 0; i<orderedSusCFGList.size(); i++) {
172 _os <<" "<<orderedSusCFGList.at(i)->getBlockID()<<"
173 "<<orderedSusCFGList.at(i);
174 }
175
176 _os <<"\n";
177 */
178 for (int i = 0; i < orderedSusCFGList.size(); i++) {
179 GPUMacro *gpuMacro = _susCFGBlockGPUMacroMap[orderedSusCFGList.at(i)];
180 float gpuTime = gpuMacro->getGPUTime();
181 //_os <<"\n gpuTime : " <<gpuTime;
182 //_os <<"\n c_ideal : " <<c_ideal;
183 if (gpuTime <= c_ideal) {
184 c_ideal = c_ideal - gpuTime;
185 } else {
186 // orderedSusCFGList.at(i)->denyGPUFit();
187 gpuUnfitSusCFGVector.push_back(gpuFitSusCFGVector.at(i));
188 gpuFitSusCFGVector.erase(gpuFitSusCFGVector.begin() + i - 1);
189 }
190 }
191 float newGPUTime = 0;
192 float newCPUTime = 0;
193 /*
194 for (int i = 0; i<susCFGBlockList.size(); i++) {
195 if (susCFGBlockList.at(i)->isGPUFit()) {
196 // On GPU
197 GPUMacro *gpuMacro =
198 _susCFGBlockGPUMacroMap[susCFGBlockList.at(i)]; newGPUTime +=
199 gpuMacro->getGPUTime();
200 }
201 else {
202 // On CPU
203 GPUMacro *gpuMacro =
204 _susCFGBlockGPUMacroMap[susCFGBlockList.at(i)]; if (newCPUTime <
205 gpuMacro->getCPUTime()){ newCPUTime = gpuMacro->getCPUTime();
206 }
207 }
208 }
209 */
210 for (int i = 0; i < gpuFitSusCFGVector.size(); i++) {
211 GPUMacro *gpuMacro = _susCFGBlockGPUMacroMap[gpuFitSusCFGVector.at(i)];
212 newGPUTime += gpuMacro->getGPUTime();
213 }
214 for (int i = 0; i < gpuUnfitSusCFGVector.size(); i++) {
215 GPUMacro *gpuMacro = _susCFGBlockGPUMacroMap[gpuUnfitSusCFGVector.at(i)];
216 if (newCPUTime < gpuMacro->getCPUTime()) {
217 newCPUTime = gpuMacro->getCPUTime();
218 }
219 }
220
221 //_os <<"\n new GPUTime : " <<newGPUTime<<" newCPUTime : " <<newCPUTime;
222 if (c_actual > max(newGPUTime, newCPUTime)) {
223 c_actual = max(newGPUTime, newCPUTime);
224 for (int i = 0; i < gpuFitSusCFGVector.size(); i++) {
225 gpuFitSusCFGVector.at(i)->addGPUFit();
226 _susCFGBlockGPUMacroMap[gpuFitSusCFGVector.at(i)]->addGPUFit();
227 }
228 for (int i = 0; i < gpuUnfitSusCFGVector.size(); i++) {
229 gpuUnfitSusCFGVector.at(i)->denyGPUFit();
230 _susCFGBlockGPUMacroMap[gpuUnfitSusCFGVector.at(i)]->denyGPUFit();
231 }
232 return true;
233 }
234 return false;
235}
236
238 vector<SusCFG *> gpuFitSusCFGVector) {
239 vector<SusCFG *> leftList;
240 vector<SusCFG *> rightList;
241 int middle;
242 if (gpuFitSusCFGVector.size() <= 1) {
243 return gpuFitSusCFGVector;
244 } else {
245 middle = gpuFitSusCFGVector.size() / 2;
246 for (int i = 0; i < middle; i++) {
247 leftList.push_back(gpuFitSusCFGVector.at(i));
248 }
249 for (int i = middle; i < gpuFitSusCFGVector.size(); i++) {
250 rightList.push_back(gpuFitSusCFGVector.at(i));
251 }
252
253 leftList = arrangeGPUSusCFGBlocks(leftList);
254 rightList = arrangeGPUSusCFGBlocks(rightList);
255 return (merge_sort(leftList, rightList));
256 }
257}
258
259// This needs to be a utility function
260vector<SusCFG *>
261GlobalSuspensionAutomata::merge_sort(vector<SusCFG *> leftList,
262 vector<SusCFG *> rightList) {
263 vector<SusCFG *> orderedList;
264 while (leftList.size() > 0 || rightList.size() > 0) {
265 if (leftList.size() > 0 && rightList.size() > 0) {
266 GPUMacro *leftGPUMacro = _susCFGBlockGPUMacroMap[leftList.back()];
267 GPUMacro *rightGPUMacro = _susCFGBlockGPUMacroMap[rightList.back()];
268 int leftGPUTime = leftGPUMacro->getGPUTime();
269 int leftCPUTime = leftGPUMacro->getCPUTime();
270 int rightGPUTime = rightGPUMacro->getCPUTime();
271 int rightCPUTime = rightGPUMacro->getCPUTime();
272 int leftAccFactor = leftCPUTime / leftGPUTime;
273 int rightAccFactor = rightCPUTime / rightGPUTime;
274 if (leftAccFactor >= rightAccFactor) {
275 orderedList.push_back(leftList.back());
276 leftList.pop_back();
277 } else {
278 orderedList.push_back(rightList.back());
279 rightList.pop_back();
280 }
281 } else if (leftList.size() > 0) {
282 orderedList.push_back(leftList.back());
283 leftList.pop_back();
284 } else if (rightList.size() > 0) {
285 orderedList.push_back(rightList.back());
286 rightList.pop_back();
287 }
288 }
289 return orderedList;
290}
291
292// This needs to be a utility function
293float GlobalSuspensionAutomata::max(float a, float b) {
294 if (a > b) {
295 return a;
296 } else if (a < b) {
297 return b;
298 } else
299 return a;
300}
301
303 int instanceId) {
304
305 vector<SusCFG *> codeBlockVector = t->returnCodeBlocks();
306 for (int i = 0; i < codeBlockVector.size(); i++) {
307
308 SusCFG *susCFGBlock = codeBlockVector.at(i);
309 CFGBlock *cfgBlock = susCFGBlock->getBlock();
310 if (cfgBlock->getLoopTarget()) {
311 if (const ForStmt *cfs = dyn_cast<ForStmt>(cfgBlock->getLoopTarget())) {
312 ForStmt *fs = const_cast<ForStmt *>(cfs);
313 for (entryFunctionMacroMapType::iterator
314 it = _entryFunctionGPUMacroMap.begin(),
315 eit = _entryFunctionGPUMacroMap.end();
316 it != eit; it++) {
317 FindGPUMacro::forStmtGPUMacroMapType gpuMacroMap = it->second;
318
319 for (FindGPUMacro::forStmtGPUMacroMapType::iterator
320 fit = gpuMacroMap.begin(),
321 fite = gpuMacroMap.end();
322 fit != fite; fit++) {
323 FindGPUMacro::forStmtInstanceIdPairType forStmtInstanceIdPair =
324 fit->first;
325
326 if (forStmtInstanceIdPair.first == instanceId &&
327 forStmtInstanceIdPair.second == fs) {
329 susCFGBlockGPUMacroPairType(susCFGBlock, fit->second));
330
331 break;
332 }
333 }
334 }
335 }
336 }
337 }
338}
339
341
342 _moduleInstanceMap = _systemcModel->getModuleInstanceMap();
343
344 for (Model::moduleInstanceMapType::iterator it = _moduleInstanceMap.begin(),
345 eit = _moduleInstanceMap.end();
346 it != eit; it++) {
347 vector<ModuleDecl *> mdVec = it->second;
348
349 for (int i = 0; i < mdVec.size(); i++) {
350 ModuleDecl *md = mdVec.at(i);
351 vector<EntryFunctionContainer *> vef = md->getEntryFunctionContainer();
352
353 for (int j = 0; j < vef.size(); j++) {
355 vef.at(j)->getSusAuto();
356
357 entryFunctionInstanceIdPairType entryFunctionInstanceIdPair =
358 make_pair(vef.at(j), i);
360 instanceFunctionSautoPairType(entryFunctionInstanceIdPair, sauto));
361 }
362
363 for (int j = 0; j < vef.size(); j++) {
364 CXXMethodDecl *entryFunctionDecl = vef.at(j)->getEntryMethod();
365
366 FindGPUMacro findGPUMacro(entryFunctionDecl, i, _os);
367
369 vef.at(j), findGPUMacro.getForStmtGPUMacroMap()));
370 }
371 }
372 }
373
374 instanceFunctionSautoMapType::iterator it = _instanceFunctionSautoMap.begin();
375 vector<Transition *> transitionVec = it->second;
376 State *initialState;
377 for (int i = 0; i < transitionVec.size(); i++) {
378 Transition *t = transitionVec.at(i);
379 State *state = t->returnInitialState();
380 if (state->isInitial()) {
381 initialState = state;
382 break;
383 }
384 }
385
386 for (instanceFunctionSautoMapType::iterator
387 it = _instanceFunctionSautoMap.begin(),
388 eit = _instanceFunctionSautoMap.end();
389 it != eit; it++) {
390
391 vector<Transition *> sauto = it->second;
392 entryFunctionInstanceIdPairType entryFunctionIdPair = it->first;
393 for (int i = 0; i < sauto.size(); i++) {
394 Transition *t = sauto.at(i);
395 t->addInstanceId(entryFunctionIdPair.second);
396 if (t->returnInitialState()->isInitial()) {
397 t->addInitialState(initialState);
398 }
400 _globalSauto.push_back(t);
401 }
402 }
403
404 for (int i = 0; i < _globalSauto.size(); i++) {
405 Transition *t = _globalSauto.at(i);
406
408 State *initState = t->returnInitialState();
409
410 vector<Transition *> incomingTransitions;
411 vector<Transition *> outgoingTransitions;
412 for (int j = 0; j < _globalSauto.size(); j++) {
413 Transition *t = _globalSauto.at(j);
414 if (t->returnInitialState() == initState) {
415 outgoingTransitions.push_back(t);
416 }
417 if (t->returnFinalState() == initState) {
418 incomingTransitions.push_back(t);
419 }
420 }
422 stateTransitionsPairType(initState, incomingTransitions));
424 stateTransitionsPairType(initState, outgoingTransitions));
425 }
426}
427
428vector<Transition *>
430 if (_outgoingTransitionsMap.find(state) != _outgoingTransitionsMap.end()) {
431 stateTransitionsMapType::iterator stateFound =
432 _outgoingTransitionsMap.find(state);
433 return stateFound->second;
434 } else {
435 llvm::errs() << "\n ERROR : Could not find state in map";
436 exit(0);
437 }
438}
439
444
446 return _globalSauto;
447}
448
453
454vector<Transition *>
456 vector<Transition *> transitionVec;
457 for (transitionTimeMapType::iterator it = _transitionTimeMap.begin(),
458 eit = _transitionTimeMap.end();
459 it != eit; it++) {
460 timePairType timePair = it->second;
461 if (timePair.first == tp.first && timePair.second == tp.second) {
462 transitionVec.push_back(it->first);
463 }
464 }
465 return transitionVec;
466}
467
472
475 if (_transitionTimeMap.find(t) != _transitionTimeMap.end()) {
476 return _transitionTimeMap[t];
477 } else {
478 _os << "\n Cannot find time of transition : " << t;
479 return make_pair(0, 0);
480 }
481}
482
483vector<Transition *> GlobalSuspensionAutomata::
484
486 if (_incomingTransitionsMap.find(state) != _incomingTransitionsMap.end()) {
487 stateTransitionsMapType::iterator stateFound =
488 _incomingTransitionsMap.find(state);
489 return stateFound->second;
490 } else {
491 llvm::errs() << "\n ERROR : Could not find state in map";
492 exit(0);
493 }
494}
495
497
498 Stmt *s = const_cast<Stmt *>(cs->getStmt());
499 CXXMemberCallExpr *m = dyn_cast<CXXMemberCallExpr>(s);
500
501 if (!m) {
502 return false;
503 ;
504 }
505
506 if (m->getDirectCallee()->getNameInfo().getAsString() == string("notify")) {
507 return true;
508 }
509
510 return false;
511}
512
514
515 LangOptions LangOpts;
516 LangOpts.CPlusPlus = true;
517 PrintingPolicy Policy(LangOpts);
518
519 string TypeS;
520 llvm::raw_string_ostream s(TypeS);
521
522 arg->printPretty(s, 0, Policy);
523 return s.str();
524}
525
527
528 Stmt *s = const_cast<Stmt *>(cs->getStmt());
529
530 CXXMemberCallExpr *ce = dyn_cast<CXXMemberCallExpr>(s);
531
532 MemberExpr *m = dyn_cast<MemberExpr>(ce->getCallee());
533
534 return getArgumentName(m->getBase()->IgnoreImpCasts());
535}
536
538
539 vector<SusCFG *> codeBlocks = tr->returnCodeBlocks();
540 string eventName;
541 for (int i = 0; i < codeBlocks.size(); i++) {
542 SusCFG *susCFGBlock = codeBlocks.at(i);
543 CFGBlock *cfgBlock = susCFGBlock->getBlock();
544 for (CFGBlock::iterator it = cfgBlock->begin(), eit = cfgBlock->end();
545 it != eit; it++) {
546 if (Optional<CFGStmt> cs = it->getAs<CFGStmt>()) {
547 const CFGStmt *s = (CFGStmt const *)&cs;
548
549 if (isNotifyCall(s)) {
550
551 eventName = getNotifyEventName(s);
552 float simCycles = 0.0;
553 float deltaTime = 0.0;
554
555 if (_transitionTimeMap.find(tr) != _transitionTimeMap.end()) {
556 transitionTimeMapType::iterator transitionTimeFound =
557 _transitionTimeMap.find(tr);
559 eventName, transitionTimeFound->second));
560 } else {
561 llvm::errs() << "\n ERROR : Cannot find transition time";
562 }
563 }
564 }
565 }
566 }
567}
568
570
571 State *state = tr->returnInitialState();
572
573 if (state->isInitial()) {
575 return true;
576 } else if (state->isDelta()) {
577 vector<Transition *> transitionVec = getIncomingTransitions(state);
578 float simTime = 0.0;
579 int deltaTime = 0;
580
581 for (int i = 0; i < transitionVec.size(); i++) {
582 if (_transitionTimeMap.find(transitionVec.at(i)) !=
583 _transitionTimeMap.end()) {
584 transitionTimeMapType::iterator transitionFound =
585 _transitionTimeMap.find(transitionVec.at(i));
586 if (simTime < transitionFound->second.first) {
587 simTime = transitionFound->second.first;
588 deltaTime = transitionFound->second.second + 1;
589 }
590 }
591 }
592 _transitionTimeMap.insert(
593 transitionTimePairType(tr, timePairType(simTime, deltaTime)));
594 return true;
595 }
596
597 else if (state->isTimed()) {
598 vector<Transition *> transitionVec = getIncomingTransitions(state);
599 float simTime = 0.0;
600 int deltaTime = 0;
601
602 for (int i = 0; i < transitionVec.size(); i++) {
603 if (_transitionTimeMap.find(transitionVec.at(i)) !=
604 _transitionTimeMap.end()) {
605 transitionTimeMapType::iterator transitionFound =
606 _transitionTimeMap.find(transitionVec.at(i));
607 if (simTime <= transitionFound->second.first) {
608 simTime = transitionFound->second.first + state->getSimTime();
609 deltaTime = transitionFound->second.second;
610 }
611 }
612 }
613 _transitionTimeMap.insert(
614 transitionTimePairType(tr, timePairType(simTime, deltaTime)));
615 return true;
616 } else if (state->isEvent()) {
617
618 if (_eventNotificationTimeMap.find(state->getEventName()) ==
620 return false;
621
622 } else {
623 eventNotificationTimeMapType::iterator eventFound =
625 _transitionTimeMap.insert(transitionTimePairType(tr, eventFound->second));
626 return true;
627 }
628 } else {
629 llvm::errs() << "\n ERROR : Unknown state type";
630 return false;
631 }
632 return true;
633}
634
636 /*
637 llvm::errs() << "\n Global Sauto\n";
638 llvm::errs() << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
639 for (int i = 0; i < _globalSauto.size(); i++) {
640 _globalSauto.at(i)->dump(_os);
641 }
642
643 llvm::errs() << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
644 */
645 deque<Transition *> transitionQueue;
646 State *initialState;
647 for (int i = 0; i < _globalSauto.size(); i++) {
648 Transition *t = _globalSauto.at(i);
649 if (t->returnInitialState()->isInitial()) {
650 initialState = t->returnInitialState();
651 break;
652 }
653 }
654
655 vector<Transition *> initialTransitions =
656 getOutgoingTransitions(initialState);
657
658 for (int i = 0; i < initialTransitions.size(); i++) {
659 transitionQueue.push_back(initialTransitions.at(i));
660 }
661
662 while (transitionQueue.size() != 0) {
663
664 Transition *tr = transitionQueue.front();
665
666 if (updateTransitionTime(tr)) {
667 transitionQueue.pop_front();
668 _visitTransitionMap.erase(tr);
670 } else {
671 transitionQueue.pop_front();
672 transitionQueue.push_back(tr);
674 }
676 vector<Transition *> outgoingTransitions =
678
679 for (int i = 0; i < outgoingTransitions.size(); i++) {
680 if (_visitTransitionMap[outgoingTransitions.at(i)] == false) {
681 transitionQueue.push_back(outgoingTransitions.at(i));
682 }
683 }
684 }
685}
686
688 for (instanceFunctionSautoMapType::iterator
689 it = _instanceFunctionSautoMap.begin(),
690 eit = _instanceFunctionSautoMap.end();
691 it != eit; it++) {
692 _os << "\n ############################################\n";
693 _os << "\n Instance Name : " << it->first.first;
694 _os << "\n Function Name : " << it->first.first->getName();
695
696 vector<Transition *> sauto = it->second;
697 for (int i = 0; i < sauto.size(); i++) {
698 _os << "\n Transition : " << sauto.at(i);
699 sauto.at(i)->dump(_os);
700 // Scheduled time-stamps for execution
701 if (_transitionTimeMap.find(sauto.at(i)) != _transitionTimeMap.end()) {
702 transitionTimeMapType::iterator transitionTimeFound =
703 _transitionTimeMap.find(sauto.at(i));
704 _os << "\n Sim Cycles : " << transitionTimeFound->second.first
705 << " Delta cycles : " << transitionTimeFound->second.second;
706 }
707 }
708 }
709 for (commonTimeDPMapType::iterator cit = _commonTimeDPMap.begin(),
710 cite = _commonTimeDPMap.end();
711 cit != cite; cit++) {
712 timePairType timePair = cit->first;
713 vector<SusCFG *> susCFGList = cit->second;
714 _os << "\n Time Pair : " << timePair.first << " " << timePair.second;
715 _os << "\n SusCFG* DP : \n";
716 for (int j = 0; j < susCFGList.size(); j++) {
717 if (_susCFGBlockGPUMacroMap.find(susCFGList.at(j)) !=
719 // Found a DP
720 _os << " " << susCFGList.at(j)->getBlockID();
721 susCFGBlockGPUMacroMapType::iterator DPCodeBlockFound =
722 _susCFGBlockGPUMacroMap.find(susCFGList.at(j));
723 GPUMacro *gpuMacro = DPCodeBlockFound->second;
724 gpuMacro->dump(_os);
725 }
726 if (susCFGList.at(j)->isGPUFit()) {
727 _os << "\n SusCFG Block : " << susCFGList.at(j)->getBlockID()
728 << " is marked for GPU execution\n";
729 }
730 }
731 }
732}
forStmtGPUMacroMapType getForStmtGPUMacroMap()
map< forStmtInstanceIdPairType, GPUMacro * > forStmtGPUMacroMapType
pair< int, ForStmt * > forStmtInstanceIdPairType
void dump(raw_ostream &)
pair< EntryFunctionContainer *, int > entryFunctionInstanceIdPairType
map< EntryFunctionContainer *, FindGPUMacro::forStmtGPUMacroMapType > entryFunctionMacroMapType
pair< entryFunctionInstanceIdPairType, transitionVectorType > instanceFunctionSautoPairType
vector< SusCFG * > merge_sort(vector< SusCFG * >, vector< SusCFG * >)
pair< SusCFG *, GPUMacro * > susCFGBlockGPUMacroPairType
pair< timePairType, vector< SusCFG * > > commonTimeDPPairType
map< Transition *, timePairType > transitionTimeMapType
bool GPUMap(float, vector< SusCFG * >, float &)
map< SusCFG *, GPUMacro * > susCFGBlockGPUMacroMapType
pair< string, timePairType > eventNotificationTimePairType
transitionVectorType getTransitionsAtTime(timePairType)
instanceFunctionSautoMapType _instanceFunctionSautoMap
pair< State *, vector< Transition * > > stateTransitionsPairType
GlobalSuspensionAutomata(Model *, raw_ostream &, ASTContext *)
pair< EntryFunctionContainer *, FindGPUMacro::forStmtGPUMacroMapType > entryFunctionMacroPairType
vector< SusCFG * > arrangeGPUSusCFGBlocks(vector< SusCFG * >)
eventNotificationTimeMapType _eventNotificationTimeMap
pair< Transition *, timePairType > transitionTimePairType
vector< Transition * > transitionVectorType
vector< SusCFG * > returnCodeBlocks()
bool isElementPresent(vec vecInput, element elemInput)
Definition Utility.h:66