Ignore:
Timestamp:
Nov 30, 2015, 4:30:02 PM (4 years ago)
Author:
nmedfort
Message:

More work on n-ary operations. Unresolved bug in DistributionPass?.

Location:
icGREP/icgrep-devel/icgrep/pablo/optimizers
Files:
3 edited

Legend:

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

    r4880 r4885  
    77#include <boost/container/flat_map.hpp>
    88#include <boost/graph/adjacency_list.hpp>
     9
     10#include <pablo/printer_pablos.h>
     11#include <iostream>
    912
    1013using namespace boost;
     
    331334
    332335        block->setInsertPoint(cast<Variadic>(G[sinks.front()])->getPrevNode());
    333 
    334336        if (isa<And>(G[sinks.front()])) {
    335337            outerOp = block->createAnd(intermediary.size(), PabloBlock::createOnes());
     
    343345        for (const Vertex u : intermediary) {
    344346            for (const Vertex v : sinks) {
    345                 cast<Variadic>(G[v])->removeOperand(cast<Variadic>(G[u]));
     347                cast<Variadic>(G[v])->deleteOperand(G[u]);
    346348            }
    347349            outerOp->setOperand(i++, cast<Variadic>(G[u]));
     
    351353        for (const Vertex u : sources) {
    352354            for (const Vertex v : intermediary) {
    353                 cast<Variadic>(G[v])->removeOperand(G[u]);
     355                cast<Variadic>(G[v])->deleteOperand(G[u]);
    354356            }
    355357            innerOp->setOperand(i++, G[u]);
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.cpp

    r4880 r4885  
    2020using namespace boost::numeric::ublas;
    2121
    22 #define PRINT_DEBUG_OUTPUT
     22// #define PRINT_DEBUG_OUTPUT
    2323
    2424#if !defined(NDEBUG) && !defined(PRINT_DEBUG_OUTPUT)
     
    159159
    160160        AutoMultiplexing::topologicalSort(function);
    161 
    162161        #ifndef NDEBUG
    163162        PabloVerifier::verify(function, "post-multiplexing");
     
    469468    }
    470469
    471     const BDD Vk = bdd_ithvar(mVariables++);
    472 
    473     BDD Ck = Vk;
    474 
     470    const BDD Vk = bdd_addref(bdd_not(bdd_ithvar(mVariables++)));
     471    BDD Ck = bdd_one();
    475472    for (unsigned i = 0; i != k; ++i) {
    476473        const Advance * const ithAdv = std::get<0>(mAdvanceAttributes[i]);
     
    478475        const BDD Vi = std::get<1>(mAdvanceAttributes[i]);
    479476        if (unconstrained[i]) {
    480             Ck = bdd_addref(bdd_imp(Ck, bdd_addref(bdd_not(Vi))));
    481             Ci = bdd_addref(bdd_imp(Ci, bdd_addref(bdd_not(Vk))));
    482             // If these Advances are mutually exclusive, in the same scope, and transitively independent,
    483             // we safely multiplex them.
     477            const BDD exclusionConstraint = bdd_addref(bdd_or(Vi, Vk));
     478            Ci = bdd_addref(bdd_and(Ci, exclusionConstraint));
     479            Ck = bdd_addref(bdd_and(Ck, exclusionConstraint));
     480            // If these Advances are mutually exclusive, in the same scope and transitively independent,
     481            // we can safely multiplex them. Otherwise mark the constraint edge in the graph.
    484482            if (adv->getParent() == ithAdv->getParent()) {
    485483                continue;
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_simplifier.cpp

    r4880 r4885  
    1010#include <unordered_set>
    1111#endif
    12 #include <iostream>
    1312
    1413namespace pablo {
     
    2726bool Simplifier::optimize(PabloFunction & function) {
    2827    eliminateRedundantCode(function.getEntryBlock());
     28    #ifndef NDEBUG
     29    PabloVerifier::verify(function, "post-eliminate-redundant-code");
     30    #endif
    2931    deadCodeElimination(function.getEntryBlock());
     32    #ifndef NDEBUG
     33    PabloVerifier::verify(function, "post-dead-code-elimination");
     34    #endif
    3035    strengthReduction(function.getEntryBlock());
    3136    #ifndef NDEBUG
    32     PabloVerifier::verify(function, "post-simplification");
     37    PabloVerifier::verify(function, "post-strength-reduction");
    3338    #endif
    3439    return true;
     
    5964        for (unsigned i = 0; i != var->getNumOperands(); ++i) {
    6065            if (isa<Not>(var->getOperand(i))) {
    61                 // (A ⊕ ¬B) = ¬(A ⊕ B)
     66                // (A ⊕ ¬B) = (A ⊕ (B ⊕ 1)) = ¬(A ⊕ B)
    6267                var->setOperand(i, cast<Not>(var->getOperand(i))->getOperand(0));
    6368                negated = !negated;
     
    9095                const PabloAST * const negatedOp = cast<Not>(var->getOperand(i))->getOperand(0);
    9196                for (unsigned j = 0; j != var->getNumOperands(); ++j) {
    92                     if (LLVM_UNLIKELY(var->getOperand(j) == negatedOp)) {
     97                    if (LLVM_UNLIKELY(equals(var->getOperand(j), negatedOp))) {
    9398                        if (isa<And>(var)) { // (A ∧ ¬A) ∧ B = 0 for any B
    9499                            return PabloBlock::createZeroes();
     
    194199inline bool Simplifier::isSuperfluous(const Assign * const assign) {
    195200    for (const PabloAST * inst : assign->users()) {
    196         if (isa<Next>(inst) || isa<PabloFunction>(inst)) {
    197             return false;
    198         } else if (isa<If>(inst)) {
    199             const If * ifNode = cast<If>(inst);
    200             if (ifNode->getCondition() == assign) {
    201                 bool notFound = true;
    202                 for (Assign * defVar : ifNode->getDefined()) {
    203                     if (defVar == assign) {
    204                         notFound = false;
    205                         break;
    206                     }
    207                 }
    208                 if (notFound) {
    209                     continue;
    210                 }
    211             }
     201        if (isa<Next>(inst) || isa<PabloFunction>(inst) || (isa<If>(inst) && (cast<If>(inst)->getCondition() != assign))) {
    212202            return false;
    213203        }
Note: See TracChangeset for help on using the changeset viewer.