Ignore:
Timestamp:
Sep 15, 2015, 4:27:23 PM (4 years ago)
Author:
nmedfort
Message:

Bug fixes for reassociation pass; passes make check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_bddminimization.cpp

    r4770 r4771  
    7979    // Initialize the BDD engine ...
    8080    mManager = Cudd_Init(variableCount + function.getNumOfParameters() - function.getNumOfResults(), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
     81    mVariables = 0;
    8182    Cudd_MakeTreeNode(mManager, 0, function.getNumOfParameters(), MTR_DEFAULT);
    8283    // Map the predefined 0/1 entries
     
    138139        stmt = stmt->getNextNode();
    139140    }   
    140     // Cudd_ReduceHeap(mManager, CUDD_REORDER_SIFT, 1);
    141141}
    142142
     
    211211
    212212/** ------------------------------------------------------------------------------------------------------------- *
    213  * @brief identifyHiddenContradicionsAndTautologies
    214  *
    215  * This function attempts to scan through the AST and identify statements such as (A op2 B) op1 (¬A op3 C), where
    216  * op1, op2 and op3 are And, Or or Xor operations.
    217  ** ------------------------------------------------------------------------------------------------------------- */
    218 void BDDMinimizationPass::identifyHiddenContradicionsAndTautologies(PabloBlock & block) {
    219 
    220     using Graph = adjacency_list<hash_setS, vecS, bidirectionalS, PabloAST *>;
    221     using Vertex = Graph::vertex_descriptor;
    222     using Map = std::unordered_map<const PabloAST *, Vertex>;
    223 
    224     Graph G;
    225     Map M;
    226     for (Statement * stmt : block) {
    227         const TypeId typeId = stmt->getClassTypeId();
    228         if (typeId == TypeId::And || typeId == TypeId::Or || typeId == TypeId::Xor) {
    229             const auto u = add_vertex(stmt, G);
    230             M.insert(std::make_pair(stmt, u));
    231             for (unsigned i = 0; i != stmt->getNumOperands(); ++i) {
    232                 const auto f = M.find(stmt->getOperand(i));
    233                 if (f != M.end()) {
    234                     add_edge(f->second, u, G);
    235                 }
    236             }
    237         }
    238     }
    239 
    240     if (num_edges(G) == 0) {
    241         return;
    242     }
    243 
    244     std::vector<Vertex> ordering;
    245     ordering.reserve(num_vertices(G));
    246     topological_sort(G, std::back_inserter(ordering));
    247 
    248     std::vector<unsigned> component(num_vertices(G));
    249     unsigned components = 0;
    250     for (auto u : ordering) {
    251         if (out_degree(u, G) != G[u]->users().size()) {
    252             assert (out_degree(u, G) > G[u]->users().size());
    253             component[u] = ++components;
    254         }
    255     }
    256 
    257     // ....
    258 
    259 
    260 }
    261 
    262 /** ------------------------------------------------------------------------------------------------------------- *
    263213 * @brief CUDD wrappers
    264214 ** ------------------------------------------------------------------------------------------------------------- */
     
    272222}
    273223
    274 inline DdNode * BDDMinimizationPass::NewVar(const PabloAST * expr) {
    275     DdNode * var = Cudd_bddIthVar(mManager, mVariables.size());
    276     mVariables.push_back(const_cast<PabloAST *>(expr));
    277     return var;
     224inline DdNode * BDDMinimizationPass::NewVar(const PabloAST *) {
     225    return Cudd_bddIthVar(mManager, mVariables++);
    278226}
    279227
     
    318266    Cudd_Quit(mManager);
    319267    mCharacterizationMap.clear();
    320     mVariables.clear();
    321268}
    322269
Note: See TracChangeset for help on using the changeset viewer.