Ignore:
Timestamp:
Jan 21, 2016, 5:15:33 PM (3 years ago)
Author:
nmedfort
Message:

Work on lowering + some timing and papi information that will be cleaned up later.

File:
1 edited

Legend:

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

    r4899 r4919  
    1414namespace pablo {
    1515
    16 using Graph = adjacency_list<hash_setS, vecS, bidirectionalS, PabloAST *>;
    17 using Vertex = Graph::vertex_descriptor;
     16using DependencyGraph = adjacency_list<hash_setS, vecS, bidirectionalS, PabloAST *>;
     17using Vertex = DependencyGraph::vertex_descriptor;
    1818using SinkMap = flat_map<PabloAST *, Vertex>;
    1919using VertexSet = std::vector<Vertex>;
     
    2828 * @brief getVertex
    2929 ** ------------------------------------------------------------------------------------------------------------- */
    30 static inline Vertex getVertex(PabloAST * value, Graph & G, SinkMap & M) {
     30static inline Vertex getVertex(PabloAST * value, DependencyGraph & G, SinkMap & M) {
    3131    const auto f = M.find(value);
    3232    if (f != M.end()) {
     
    4343 * Generate a graph G describing the potential applications of the distributive law for the given block.
    4444 ** ------------------------------------------------------------------------------------------------------------- */
    45 VertexSet generateDistributionGraph(PabloBlock * block, Graph & G) {
     45VertexSet generateDistributionGraph(PabloBlock * block, DependencyGraph & G) {
    4646    SinkMap M;
    4747    VertexSet distSet;
     
    126126 ** ------------------------------------------------------------------------------------------------------------- */
    127127template <unsigned side>
    128 inline static BicliqueSet && independentCliqueSets(BicliqueSet && cliques, const unsigned minimum) {
     128inline static BicliqueSet && independentCliqueSets(BicliqueSet && bicliques, const unsigned minimum) {
    129129    using IndependentSetGraph = adjacency_list<hash_setS, vecS, undirectedS, unsigned>;
    130130
    131     const auto l = cliques.size();
     131    const auto l = bicliques.size();
    132132    IndependentSetGraph I(l);
    133133
    134     // Initialize our weights
     134    // Initialize our weights and determine the constraints
    135135    for (unsigned i = 0; i != l; ++i) {
    136         I[i] = std::pow(std::get<side>(cliques[i]).size(), 2);
    137     }
    138 
    139     // Determine our constraints
    140     for (unsigned i = 0; i != l; ++i) {
     136        I[i] = std::pow(std::get<side>(bicliques[i]).size(), 2);
    141137        for (unsigned j = i + 1; j != l; ++j) {
    142             if (intersects(std::get<side>(cliques[i]), std::get<side>(cliques[j]))) {
     138            if (intersects(std::get<side>(bicliques[i]), std::get<side>(bicliques[j]))) {
    143139                add_edge(i, j, I);
    144140            }
    145141        }
    146142    }
     143
     144//    // Initialize our weights and determine the constraints
     145//    for (auto i = bicliques.begin(); i != bicliques.end(); ++i) {
     146//        I[std::distance(bicliques.begin(), i)] = std::pow(std::get<side>(*i).size(), 2);
     147//        for (auto j = i; ++j != bicliques.end(); ) {
     148//            if (intersects(i->second, j->second) && intersects(i->first, j->first)) {
     149//                add_edge(std::distance(bicliques.begin(), i), std::distance(bicliques.begin(), j), I);
     150//            }
     151//        }
     152//    }
    147153
    148154    // Use the greedy algorithm to choose our independent set
     
    167173    // Sort the selected list and then remove the unselected cliques
    168174    std::sort(selected.begin(), selected.end(), std::greater<Vertex>());
    169     auto end = cliques.end();
     175    auto end = bicliques.end();
    170176    for (const unsigned offset : selected) {
    171         end = cliques.erase(cliques.begin() + offset + 1, end) - 1;
    172     }
    173     cliques.erase(cliques.begin(), end);
    174 
    175     return std::move(cliques);
     177        end = bicliques.erase(bicliques.begin() + offset + 1, end) - 1;
     178    }
     179    bicliques.erase(bicliques.begin(), end);
     180
     181    return std::move(bicliques);
    176182}
    177183
     
    183189 * bipartition A and their adjacencies to be in B.
    184190  ** ------------------------------------------------------------------------------------------------------------- */
    185 static BicliqueSet enumerateBicliques(const Graph & G, const VertexSet & A) {
     191static BicliqueSet enumerateBicliques(const DependencyGraph & G, const VertexSet & A) {
    186192    using IntersectionSets = std::set<VertexSet>;
    187193
     
    265271 * there are not enough vertices in the biclique to make distribution profitable, eliminate the clique.
    266272 ** ------------------------------------------------------------------------------------------------------------- */
    267 static BicliqueSet && removeUnhelpfulBicliques(BicliqueSet && cliques, Graph & G) {
     273static BicliqueSet && removeUnhelpfulBicliques(BicliqueSet && cliques, DependencyGraph & G) {
    268274    for (auto ci = cliques.begin(); ci != cliques.end(); ) {
    269275        const auto cardinalityA = std::get<0>(*ci).size();
     
    288294 * @brief safeDistributionSets
    289295 ** ------------------------------------------------------------------------------------------------------------- */
    290 static DistributionSets safeDistributionSets(Graph & G, const VertexSet & distSet) {
     296static DistributionSets safeDistributionSets(DependencyGraph & G, const VertexSet & distSet) {
    291297    DistributionSets T;
    292298    BicliqueSet lowerSet = independentCliqueSets<1>(removeUnhelpfulBicliques(enumerateBicliques(G, distSet), G), 1);
     
    309315        // FlattenAssociativeDFG::coalesce(block, false);
    310316
    311         Graph G;
     317        DependencyGraph G;
    312318
    313319        const VertexSet distSet = generateDistributionGraph(block, G);
     
    350356                outerOp->addOperand(G[u]);
    351357            }
    352             FlattenAssociativeDFG::coalesce(outerOp);
     358            CoalesceDFG::coalesce(outerOp);
    353359
    354360            for (const Vertex u : sources) {
     
    359365            }
    360366            innerOp->addOperand(outerOp);
    361             FlattenAssociativeDFG::coalesce(innerOp);
     367            CoalesceDFG::coalesce(innerOp);
    362368
    363369            for (const Vertex u : sinks) {
    364                 Variadic * const resultOp = cast<Variadic>(G[u]);
    365                 resultOp->addOperand(innerOp);
    366                 FlattenAssociativeDFG::coalesce(resultOp);
     370                cast<Variadic>(G[u])->addOperand(innerOp);
    367371            }
    368372        }
     
    391395    #endif
    392396    Simplifier::optimize(function);
    393 //    FlattenAssociativeDFG::deMorgansReduction(function.getEntryBlock());
    394 //    #ifndef NDEBUG
    395 //    PabloVerifier::verify(function, "post-demorgans-reduction");
    396 //    #endif
    397 //    Simplifier::optimize(function);
    398 }
    399 
    400 
    401 }
     397}
     398
     399
     400}
Note: See TracChangeset for help on using the changeset viewer.