Go to the documentation of this file.
16 #ifndef MRRG_PROCEDURES__H_
17 #define MRRG_PROCEDURES__H_
25 #include <unordered_map>
26 #include <unordered_set>
36 struct NodeExclusions;
56 using NodeInfoList = std::unordered_map<MRRG::NodeDescriptor, NodeInfo>;
62 std::unordered_map<MRRG::NodeDescriptor, NodeInfoList>
neighbours = {};
102 template<
typename NodeList = std::vector<MRRG::NodeDescriptor>,
typename NEIGHBOUR_FINDER = FunctionalUnitNeighbours::NodeInfoList(const MRRG&, MRRG::NodeDescriptor,
int)>
105 for(
auto& n : sources) result.
neighbours.emplace(n, std::forward<NEIGHBOUR_FINDER>(neighbour_finder)(mrrg, n, min_neighbours_to_find));
131 std::pair<int,int> cycle_trip_count_min_max,
const OperandTag& operand_tag,
149 const MRRG& mrrg,
const std::vector<MrrgNodeSpan>& walks);
155 const MRRG& mrrg,
const std::vector<std::vector<MRRG::NodeDescriptor>>& walks
157 std::vector<MrrgNodeSpan> with_pointers;
158 with_pointers.reserve(walks.size());
159 auto to_span = [](
auto& e) ->
MrrgNodeSpan {
return {e.
data(), e.size()}; };
160 std::transform(walks.begin(), walks.end(), std::back_inserter(with_pointers), to_span);
247 using NodeSet = std::unordered_set<MRRG::NodeDescriptor>;
260 template<
typename NodeList = std::vector<MRRG::NodeDescriptor>>
262 template<
typename NodeList = std::vector<MRRG::NodeDescriptor>>
273 std::unordered_map<MRRG::NodeDescriptor, NodeSet>
forward_map = {};
274 std::unordered_map<MRRG::NodeDescriptor, NodeSet>
reverse_map = {};
auto makeNClosestNeighbourFinder(int min_neighbours)
@ MRRG_NODE_ROUTING_FUNCTION
std::vector< MRRG::NodeDescriptor > function_nodes
bool isNodeFaninOf(const MRRG &mrrg, MRRG::NodeDescriptor driven_ndesc, MRRG::NodeDescriptor test_ndesc)
void assertNodeIsExcusiveFanin(const MRRG &mrrg, MRRG::NodeDescriptor driven_ndesc, MRRG::NodeDescriptor test_ndesc, const char *action_name=" -- ")
FunctionalUnitNeighbours::NodeInfoList findNeighbourFUs(const MRRG &mrrg, MRRG::NodeDescriptor source, int min_neighbours_to_find)
MRRGTransformationResult muxExNodeInsertion(const MRRG &src_mrrg)
bool nodeIsCompatibleWithOperand(const MRRG &mrrg, MRRG::NodeDescriptor node, const OperandTag &operand_tag)
bool operator==(const InterMRRGMap &rhs) const
const MRRGNode * NodeDescriptor
std::unordered_map< MRRG::NodeDescriptor, NodeSet > forward_map
void mergeNodePropertiesOfExclusiveFanoutToExclusiveFanin(MRRG &mrrg, MRRG::NodeDescriptor into_ndesc, MRRG::NodeDescriptor from_ndesc)
bool operator==(const MRRG::NodeDescriptor &ndesc) const
std::vector< std::vector< MRRG::NodeDescriptor > > routing_nodes
std::unordered_set< MRRG::NodeDescriptor > discovered_fu_nodes
void recordNodeMerge(MRRGTransformationResult &transformation_result, const MRRG &src_mrrg, MRRG::NodeDescriptor into, MRRG::NodeDescriptor from)
MRRG::NodeDescriptor const * data() const
Mapping removeMuxExNodeInsertion(const Mapping &map, const MRRGTransformationResult &transformation)
void assertNodeIsExcusiveFanout(const MRRG &mrrg, MRRG::NodeDescriptor driver_ndesc, MRRG::NodeDescriptor test_ndesc, const char *action_name=" -- ")
friend std::ostream & operator<<(std::ostream &os, const FunctionalUnitNeighbours &fu_neighbours)
std::vector< std::vector< MRRG::NodeDescriptor > > findNRoutingPathsBetween(int num_paths, const MRRG &mrrg, MRRG::NodeDescriptor source, MRRG::NodeDescriptor sink, std::pair< int, int > cycle_trip_count_min_max, const OperandTag &operand_tag, MRRGProcedureCacheHandle *cache_handle)
void assertHasNoOps(const MRRGNode &n, const char *action_name="")
MRRG::NodeDescriptor node
void onExamineEdge(const MRRG::NodeDescriptor &, const MRRG::NodeDescriptor &fanout)
bool walkIsCompatibleWithOperand(const MRRG &mrrg, const std::vector< MRRG::NodeDescriptor > &walk, const OperandTag &operand_tag)
Mapping transformToOriginalMRRG(const Mapping &map, const MRRGTransformationResult &transformation)
void assertNodeIsFaninOf(const MRRG &mrrg, MRRG::NodeDescriptor driven_ndesc, MRRG::NodeDescriptor test_ndesc, const char *action_name=" -- ")
int tripCountOfWalk(const MRRG &mrrg, const std::vector< MRRG::NodeDescriptor > &walk)
const NodeSet & newNodesForOldNode(MRRG::NodeDescriptor n) const
const NodeInfo & getInfoFor(MRRG::NodeDescriptor src, MRRG::NodeDescriptor dest) const
const NodeSet & oldNodesForNewNode(MRRG::NodeDescriptor n) const
std::vector< std::vector< MRRG::NodeDescriptor > > mergeMRRGWalks(const MRRG &mrrg, const std::vector< MrrgNodeSpan > &walks)
void addMapping(MRRG::NodeDescriptor old_node, MRRG::NodeDescriptor new_node)
bool isNodeFanoutOf(const MRRG &mrrg, MRRG::NodeDescriptor driver_ndesc, MRRG::NodeDescriptor test_ndesc)
bool shouldIgnore(const MRRG::NodeDescriptor &v)
MRRGTransformationResult reduceLosslessly(const MRRG &src_mrrg, const MRRGTransformFlags &flags)
void collapseSingleFaninFanoutNodeIntoFanin(MRRG &mrrg, MRRG::NodeDescriptor into_ndesc, MRRG::NodeDescriptor from_ndesc)
bool isReachableFrom(MRRG::NodeDescriptor src, MRRG::NodeDescriptor dest) const
void addAllByMatchingProperties(const MRRG &src_mrrg, const MRRG &transformed_mrrg)
auto end(const SingleItemImmutableSet< VertexID > &siis)
void assertNodeIsFanoutOf(const MRRG &mrrg, MRRG::NodeDescriptor driver_ndesc, MRRG::NodeDescriptor test_ndesc, const char *action_name=" -- ")
std::unordered_map< MRRG::NodeDescriptor, NodeSet > reverse_map
std::vector< MRRG::NodeDescriptor > routing_nodes
std::unordered_map< OpGraph::OpDescriptor, std::vector< MRRG::NodeDescriptor > > findAllCompatibleFUs(const OpGraph &opgraph, const MRRG &base_mrrg)
auto value_for_key_or(ASSOCIATIVE_COLLECTION &assoc_collection, const KEY &key, DEFAULT_VALUE &default_value) -> std::conditional_t< std::is_lvalue_reference< DEFAULT_VALUE >::value, decltype(false ? default_value :assoc_collection.find(key) ->second)&, decltype(false ? default_value :assoc_collection.find(key) ->second) >
std::vector< std::vector< MRRG::NodeDescriptor > > function_nodes
void mergeDescriptors(MRRG::NodeDescriptor from, MRRG::NodeDescriptor into)
std::unordered_map< MRRG::NodeDescriptor, NodeInfo > NodeInfoList
MRRGNodeClassListsByCycle computeNodeClassListsByCycle(const MRRG &mrrg)
FunctionalUnitNeighbours findAllNeighbourFUs(const MRRG &mrrg, const NodeList &sources, int min_neighbours_to_find=-1, NEIGHBOUR_FINDER &&neighbour_finder=findNeighbourFUs)
std::unordered_map< MRRG::NodeDescriptor, NodeInfoList > neighbours
void addMappingMulti(MRRG::NodeDescriptor old_node, const NodeList &new_nodes)
MRRGNodeClassLists computeNodeClassLists(const MRRG &mrrg)
void assertHasSingleFanout(const MRRGNode &n, const char *action_name)
std::unordered_set< MRRG::NodeDescriptor > NodeSet
friend std::ostream & operator<<(std::ostream &os, const InterMRRGMap &imm)
void mergeNodeConnections(MRRG &mrrg, MRRG::NodeDescriptor into_ndesc, MRRG::NodeDescriptor from_ndesc)