Changeset 4588 for icGREP/icgrepdevel/icgrep/pablo/optimizers
 Timestamp:
 Jun 3, 2015, 9:48:23 AM (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/pablo/optimizers/pablo_automultiplexing.cpp
r4587 r4588 247 247 248 248 bool testContradiction = true; 249 bool updateCharacterization = true; 249 250 250 251 switch (stmt>getClassTypeId()) { … … 282 283 case PabloAST::ClassTypeId::Call: 283 284 testContradiction = false; 284 assert (mCharacterizationMap.count(stmt)); 285 bdd = mCharacterizationMap[stmt]; 285 updateCharacterization = false; 286 286 break; 287 287 case PabloAST::ClassTypeId::Advance: … … 310 310 DdNode * Vi = std::get<1>(advances[i]); 311 311 312 // We could probably avoid some tests by infering that if X â Y and Y â Z then X â Z too. Will need a 313 // more complex graph structure for storing subset edges. Similarly if X â© Y = â 314 and Z â X, Z â© Y = â 315 316 317 // Only test pairs if they are in the same scope or one has a user in the same scope that is reachable 318 // by the other? 319 312 320 bool constrained = true; 313 321 … … 315 323 if ((stmt>getOperand(1) == adv>getOperand(1)) && (!edge(k, i, mPathGraph).second)) { 316 324 317 // Test this with Cudd_bddIntersect(mManager, Ik, Ii); 318 DdNode * const tmp = And(Ik, Ii); // do we need to simplify this to identify subsets? 319 320 if (Ik == tmp) { 321 // If Ik = C and C = Ii â© Ik then Ik (the input to the kth advance) is a *subset* of Ii (the input of the 325 326 // Test this with Cudd_bddIntersect / Cudd_bddLeq 327 DdNode * const tmp = Cudd_bddIntersect(mManager, Ik, Ii); 328 Cudd_Ref(tmp); 329 // Is there any satisfying truth assignment? If not, these streams are mutually exclusive. 330 if (noSatisfyingAssignment(tmp)) { 331 std::cerr << stmt>getName()>to_string() << " â© " << adv>getName()>to_string() << " = â 332 " << std::endl; 333 334 assert (mCharacterizationMap.count(adv)); 335 336 DdNode *& other = mCharacterizationMap[adv]; 337 // mark the ith and kth Advances as being mutually exclusive 338 bdd = And(bdd, Not(Vi)); 339 other = And(other, Not(Vk)); 340 constrained = false; 341 } 342 else if (Ik == tmp) { 343 std::cerr << stmt>getName()>to_string() << " â " << adv>getName()>to_string() << std::endl; 344 // If Ik = Ii â© Ik then Ik (the input to the kth advance) is a *subset* of Ii (the input of the 322 345 // ith advance). Record this in the subset graph with the arc (k,i). These edges will be moved into the 323 346 // multiplex set graph if Advance_i and Advance_k happen to be in the same mutually exclusive set. … … 326 349 } 327 350 else if (Ii == tmp) { 351 std::cerr << stmt>getName()>to_string() << " â " << adv>getName()>to_string() << std::endl; 328 352 mSubsetGraph.emplace_back(i, k); 329 353 constrained = false; 330 354 } 331 // Is there any satisfying truth assignment? If not, these streams are mutually exclusive.332 else if (noSatisfyingAssignment(tmp)) {333 334 assert (mCharacterizationMap.count(adv));335 336 DdNode *& other = mCharacterizationMap[adv];337 // mark the ith and kth Advances as being mutually exclusive338 bdd = And(bdd, Not(Vi));339 other = And(other, Not(Vk));340 constrained = false;341 }342 343 355 Cudd_RecursiveDeref(mManager, tmp); 344 356 } 345 357 346 // Advances must be in the same scope or they cannot be safely multiplexed unless one is moved.358 // Even if these Advances are mutually exclusive, they must be in the same scope or they cannot be safely multiplexed. 347 359 if (constrained  (stmt>getParent() != adv>getParent())) { 348 360 // We want the constraint graph to be acyclic; since the dependencies are already in topological order, … … 367 379 Cudd_RecursiveDeref(mManager, bdd); 368 380 stmt = stmt>replaceWith(entry.createZeroes()); 369 } 370 else { 381 continue; 382 } 383 else if (LLVM_LIKELY(updateCharacterization)){ 371 384 mCharacterizationMap[stmt] = bdd; 372 stmt = stmt>getNextNode();373 }385 } 386 stmt = stmt>getNextNode(); 374 387 } 375 388 … … 799 812 800 813 std::stringstream name; 801 802 814 name << "mux"; 803 804 815 for (size_t i = 1; i <= n; ++i) { 805 816 if ((i & (static_cast<size_t>(1) << j)) != 0) { … … 880 891 } 881 892 882 PabloAST * a1 = Q.front(); Q.pop_front(); assert (demux); 893 assert (Q.size() >= 0 && Q.size() <= 2); 894 895 PabloAST * a1 = Q.front(); Q.pop_front(); assert (a1); 883 896 PabloAST * a2 = neg; 884 if (LLVM_UNLIKELY( Q.size() == 2)) {897 if (LLVM_UNLIKELY(neg == nullptr)) { 885 898 a2 = Q.front(); Q.pop_front(); assert (a2); 886 899 } 900 assert (Q.empty()); 901 887 902 pb>setInsertPoint(choose(a2, a1, adv)); 888 903 PabloAST * demux = pb>createAnd(a1, a2, "demux_" + V[i  1]>getName()>to_string()); 889 904 890 V[i  1]>replaceWith(demux, false , true);905 V[i  1]>replaceWith(demux, false); 891 906 } 892 907 }
Note: See TracChangeset
for help on using the changeset viewer.