source: icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.hpp @ 4578

Last change on this file since 4578 was 4578, checked in by nmedfort, 4 years ago

More multiplexing work.

File size: 2.0 KB
Line 
1#ifndef PABLO_AUTOMULTIPLEXING_HPP
2#define PABLO_AUTOMULTIPLEXING_HPP
3
4#include <pablo/codegenstate.h>
5#include <slab_allocator.h>
6#include <unordered_map>
7#include <pablo/analysis/bdd/bdd.hpp>
8#include <boost/graph/adjacency_list.hpp>
9#include <boost/graph/adjacency_matrix.hpp>
10#include <boost/graph/edge_list.hpp>
11#include <boost/container/flat_map.hpp>
12#include <boost/numeric/ublas/matrix.hpp>
13#include <random>
14#include <stdint.h>
15
16namespace pablo {
17
18class AutoMultiplexing {
19
20    using CharacterizationMap = boost::container::flat_map<PabloAST *, bdd::BDD>;
21    using ConstraintGraph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::directedS>;
22    using PathGraph = boost::adjacency_matrix<boost::undirectedS>;
23    using SubsetGraph = boost::edge_list<std::pair<unsigned, unsigned>>;
24    using MappingGraph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::bidirectionalS>;
25    using IndependentSetGraph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::undirectedS, unsigned>;
26    using Advances = std::vector<Advance *>;
27
28    using RNG = std::mt19937;
29    using RNGDistribution = std::uniform_int_distribution<RNG::result_type>;
30
31    using Vertex = ConstraintGraph::vertex_descriptor;
32
33    using IndependentSet = std::vector<Vertex>;
34
35public:
36    static void optimize(PabloBlock & block);
37protected:
38    bdd::Engine initialize(const std::vector<Var *> & vars, const PabloBlock & entry);
39    void characterize(bdd::Engine & engine, const PabloBlock & entry);
40    bool generateMultiplexSets(RNG & rng);
41    void addMultiplexSet(const IndependentSet & set);
42    void approxMaxWeightIndependentSet(RNG & rng);
43    void applySubsetConstraints();
44    void multiplexSelectedIndependentSets();
45    void topologicalSort();
46
47private:
48    AutoMultiplexing();
49
50    CharacterizationMap     mCharacterizationMap;
51    PathGraph               mPathGraph;
52    ConstraintGraph         mConstraintGraph;
53    SubsetGraph             mSubsetGraph;
54    Advances                mAdvance;
55    MappingGraph            mMappingGraph;
56};
57
58}
59
60#endif // PABLO_AUTOMULTIPLEXING_HPP
Note: See TracBrowser for help on using the repository browser.