Changeset 4772 for icGREP/icgrepdevel
 Timestamp:
 Sep 15, 2015, 4:41:40 PM (4 years ago)
 Location:
 icGREP/icgrepdevel/icgrep/pablo/optimizers
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/pablo/optimizers/booleanreassociationpass.cpp
r4771 r4772 14 14 #include <iostream> 15 15 #include <pablo/printer_pablos.h> 16 #include "graphfacade.hpp"17 16 18 17 using namespace boost; … … 39 38 * @brief helper functions 40 39 **  */ 41 template <class Graph>42 static VertexSet incomingVertexSet(const Vertex u, const Graph & G) {43 VertexSet V;44 V.reserve(G.in_degree(u));45 for (auto e : make_iterator_range(G.in_edges(u))) {46 V.push_back(G.source(e));47 }48 std::sort(V.begin(), V.end());49 return std::move(V);50 }51 52 template <class Graph>53 static VertexSet outgoingVertexSet(const Vertex u, const Graph & G) {54 VertexSet V;55 V.reserve(G.out_degree(u));56 for (auto e : make_iterator_range(G.out_edges(u))) {57 V.push_back(G.target(e));58 }59 std::sort(V.begin(), V.end());60 return std::move(V);61 }62 63 template <class Graph>64 static VertexSet sinks(const Graph & G) {65 VertexSet V;66 for (const Vertex u : make_iterator_range(vertices(G))) {67 if (out_degree(u, G) == 0) {68 V.push_back(u);69 }70 }71 std::sort(V.begin(), V.end());72 return std::move(V);73 }74 75 40 template<typename Iterator> 76 41 inline Graph::edge_descriptor first(const std::pair<Iterator, Iterator> & range) { … … 88 53 89 54 inline void add_edge(PabloAST * expr, const Vertex u, const Vertex v, Graph & G) { 90 //assert (u != v);91 //assert (no_edge(v, u, G));55 assert (u != v); 56 assert (no_edge(v, u, G)); 92 57 // Make sure each edge is unique 93 58 for (auto e : make_iterator_range(out_edges(u, G))) { … … 562 527 IntersectionSets B1; 563 528 for (auto u : A) { 564 B1.insert(std::move(incomingVertexSet(u, G))); 529 VertexSet V; 530 V.reserve(in_degree(u, G)); 531 for (auto e : make_iterator_range(in_edges(u, G))) { 532 V.push_back(source(e, G)); 533 } 534 std::sort(V.begin(), V.end()); 535 B1.insert(std::move(V)); 565 536 } 566 537 … … 607 578 VertexSet Ai(A); 608 579 for (const Vertex u : *Bi) { 609 VertexSet Aj = outgoingVertexSet(u, G); 580 VertexSet Aj; 581 Aj.reserve(out_degree(u, G)); 582 for (auto e : make_iterator_range(out_edges(u, G))) { 583 Aj.push_back(target(e, G)); 584 } 585 std::sort(Aj.begin(), Aj.end()); 586 610 587 VertexSet Ak; 611 588 std::set_intersection(Ai.begin(), Ai.end(), Aj.begin(), Aj.end(), std::back_inserter(Ak)); 589 612 590 Ai.swap(Ak); 613 591 } … … 721 699 **  */ 722 700 static DistributionSets safeDistributionSets(const Graph & G, DistributionGraph & H) { 723 const auto F = makeGraphFacade(H); 701 702 VertexSet sinks; 703 for (const Vertex u : make_iterator_range(vertices(G))) { 704 if (out_degree(u, G) == 0) { 705 sinks.push_back(u); 706 } 707 } 708 std::sort(sinks.begin(), sinks.end()); 709 724 710 DistributionSets T; 725 BicliqueSet lowerSet = independentCliqueSets<1>(removeUnhelpfulBicliques(enumerateBicliques( F, sinks(H)), G, H), 1);711 BicliqueSet lowerSet = independentCliqueSets<1>(removeUnhelpfulBicliques(enumerateBicliques(H, sinks), G, H), 1); 726 712 for (Biclique & lower : lowerSet) { 727 BicliqueSet upperSet = independentCliqueSets<0>(enumerateBicliques( F, std::get<1>(lower)), 2);713 BicliqueSet upperSet = independentCliqueSets<0>(enumerateBicliques(H, std::get<1>(lower)), 2); 728 714 for (Biclique & upper : upperSet) { 729 715 T.emplace_back(std::move(std::get<1>(upper)), std::move(std::get<0>(upper)), std::get<0>(lower)); 
icGREP/icgrepdevel/icgrep/pablo/optimizers/pablo_automultiplexing.cpp
r4770 r4772 17 17 #include <unordered_set> 18 18 #include <pablo/optimizers/pablo_simplifier.hpp> 19 #include <pablo/optimizers/pablo_bddminimization.h>20 21 19 22 20 using namespace llvm; … … 104 102 namespace pablo { 105 103 104 using TypeId = PabloAST::ClassTypeId; 105 106 106 bool AutoMultiplexing::optimize(PabloFunction & function) { 107 108 BDDMinimizationPass::optimize(function);109 107 110 108 // std::random_device rd; … … 202 200 203 201 switch (stmt>getClassTypeId()) { 204 case PabloAST::ClassTypeId::Advance:202 case TypeId::Advance: 205 203 mAdvanceMap.emplace(stmt, m); 206 204 map.emplace(stmt, m++); 207 case PabloAST::ClassTypeId::Call:208 case PabloAST::ClassTypeId::ScanThru:209 case PabloAST::ClassTypeId::MatchStar:205 case TypeId::Call: 206 case TypeId::ScanThru: 207 case TypeId::MatchStar: 210 208 variableCount++; 211 209 break; … … 401 399 402 400 switch (stmt>getClassTypeId()) { 403 case PabloAST::ClassTypeId::Assign:404 case PabloAST::ClassTypeId::Next:401 case TypeId::Assign: 402 case TypeId::Next: 405 403 bdd = input[0]; 406 404 break; 407 case PabloAST::ClassTypeId::And:405 case TypeId::And: 408 406 bdd = And(input[0], input[1]); 409 407 break; 410 case PabloAST::ClassTypeId::Or:408 case TypeId::Or: 411 409 bdd = Or(input[0], input[1]); 412 410 break; 413 case PabloAST::ClassTypeId::Xor:411 case TypeId::Xor: 414 412 bdd = Xor(input[0], input[1]); 415 413 break; 416 case PabloAST::ClassTypeId::Not:414 case TypeId::Not: 417 415 bdd = Not(input[0]); 418 416 break; 419 case PabloAST::ClassTypeId::Sel:417 case TypeId::Sel: 420 418 bdd = Ite(input[0], input[1], input[2]); 421 419 break; 422 case PabloAST::ClassTypeId::ScanThru:420 case TypeId::ScanThru: 423 421 // It may be possible use "Not(input[1])" for ScanThrus if we rule out the possibility 424 422 // of a contradition being erroneously calculated later. An example of this 425 423 // would be Â¬(ScanThru(c,m) âš m) 426 case PabloAST::ClassTypeId::MatchStar:427 case PabloAST::ClassTypeId::Call:424 case TypeId::MatchStar: 425 case TypeId::Call: 428 426 bdd = NewVar(); 429 427 mRecentCharacterizations.emplace_back(stmt, bdd); 430 428 return bdd; 431 case PabloAST::ClassTypeId::Advance:429 case TypeId::Advance: 432 430 // This returns so that it doesn't mistakeningly replace the Advance with 0 or add it 433 431 // to the list of recent characterizations. 
icGREP/icgrepdevel/icgrep/pablo/optimizers/pablo_bddminimization.cpp
r4771 r4772 27 27 BDDMinimizationPass am; 28 28 am.eliminateLogicallyEquivalentStatements(function); 29 30 29 am.shutdown(); 31 30 return Simplifier::optimize(function); … … 57 56 } 58 57 switch (stmt>getClassTypeId()) { 59 case TypeId::Assign:60 case TypeId::Next:61 58 case TypeId::Advance: 62 59 case TypeId::Call:
Note: See TracChangeset
for help on using the changeset viewer.