Ignore:
Timestamp:
Jul 23, 2015, 4:47:59 PM (4 years ago)
Author:
nmedfort
Message:

Temporary check in.

File:
1 edited

Legend:

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

    r4629 r4692  
    2323
    2424    using CharacterizationMap = llvm::DenseMap<const PabloAST *, DdNode *>;
    25     using ConstraintGraph = boost::adjacency_matrix<boost::directedS>;
    26     using ConstraintVertex = ConstraintGraph::vertex_descriptor;
    27     using RNG = std::mt19937;
    28     using IntDistribution = std::uniform_int_distribution<RNG::result_type>;
    29     using MultiplexSetGraph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::bidirectionalS>;
    30     using IndependentSetGraph = boost::adjacency_matrix<boost::undirectedS, std::pair<int, int>>;
    31     using SubsetGraph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::bidirectionalS>;
    32     // the Advance pointer, input BDD and the BDD variable of the i-th Advance
    33     using AdvanceMap = boost::container::flat_map<const Statement *, unsigned>;
    34     using AdvanceVector = std::vector<std::tuple<Advance *, DdNode *, DdNode *>>;
    35     using IndependentSet = std::vector<ConstraintVertex>;
    3625
    3726    struct SubsitutionMap {
    3827        SubsitutionMap(SubsitutionMap * parent = nullptr) : mParent(parent) {}
    39         PabloAST * test(const DdNode * node, PabloAST * stmt) {
    40             PabloAST * replacement = find(node);
    41             if (LLVM_LIKELY(replacement == nullptr)) {
    42                 mMap.insert(std::make_pair(node, stmt));
    43             }
    44             return replacement;
    45         }
    46         PabloAST * find(const DdNode * node) const {
     28
     29        PabloAST * operator [](const DdNode * node) const {
    4730            auto f = mMap.find(node);
    48             if (LLVM_LIKELY(f == mMap.end())) {
    49                 PabloAST * replacement = nullptr;
    50                 if (mParent == nullptr) {
    51                     replacement = mParent->find(node);
    52                 }
    53                 return replacement;
     31            if (f == mMap.end()) {
     32                return mParent ? mParent->find(node) : nullptr;
    5433            }
    5534            return f->second;
    5635        }
     36
    5737        void insert(const DdNode * node, PabloAST * stmt) {
    5838            mMap.insert(std::make_pair(node, stmt));
     
    6444
    6545public:
    66     static bool optimize(const std::vector<Var *> & input, PabloBlock & entry);
     46    static bool optimize(PabloFunction & function);
    6747protected:
    68     void initialize(const std::vector<Var *> & vars, PabloBlock & entry);
    69     void characterize(PabloBlock & block);
    70     DdNode * characterize(Statement * const stmt, const bool throwUncharacterizedOperandError);
    71     DdNode * characterize(Advance * adv, DdNode * input);
    72     void reevaluate(Next * next, DdNode * value);
    73     void minimize(PabloBlock & entry);
    74     void minimize(PabloBlock & block, SubsitutionMap & parent);
     48    void initialize(PabloFunction & function);
     49    void characterize(const PabloBlock &block);
     50    DdNode * characterize(const Statement * const stmt);
     51    void eliminateLogicallyEquivalentStatements(PabloBlock & entry);
     52    void eliminateLogicallyEquivalentStatements(PabloBlock & block, SubsitutionMap & parent);
     53    void simplify(PabloBlock & entry);
     54    PabloAST * simplify(DdNode * bdd);
    7555
    76     bool notTransitivelyDependant(const ConstraintVertex i, const ConstraintVertex j) const;
    77     bool generateMultiplexSets(RNG & rng, unsigned k = 1);
    78     void addMultiplexSet(const IndependentSet & N, const IndependentSet & M);
    79     void selectMultiplexSets(RNG &);
    80     void applySubsetConstraints();
    81     void multiplexSelectedIndependentSets() const;
    82     void topologicalSort(PabloBlock & entry) const;
    83     inline AutoMultiplexing()
    84     : mVariables(0)
    85     , mConstraintGraph(0)
    86     {
    87     }
    8856private:
    8957    DdNode * Zero() const;
     
    10371    unsigned                mVariables;
    10472    CharacterizationMap     mCharacterizationMap;
    105     ConstraintGraph         mConstraintGraph;
    106     SubsetGraph             mSubsetGraph;
    107     AdvanceMap              mAdvanceMap;
    108     AdvanceVector           mAdvance;
    109     MultiplexSetGraph       mMultiplexSetGraph;
    11073};
    11174
Note: See TracChangeset for help on using the changeset viewer.