@@ -2956,128 +2956,110 @@ static int pick_best_direct_connect_target_rr_node(const t_rr_graph_storage& rr_
2956
2956
return best_rr;
2957
2957
}
2958
2958
2959
- // Class for building a group of connected edges.
2960
- class EdgeGroups {
2961
- public:
2962
- EdgeGroups () {}
2959
+ // Adds non-configurable (undirected) edge to be grouped.
2960
+ //
2961
+ // Returns true if this is a new edge.
2962
+ bool EdgeGroups::add_non_config_edge (int from_node, int to_node) {
2963
+ return graph_[from_node].edges .insert (to_node).second && graph_[to_node].edges .insert (from_node).second ;
2964
+ }
2963
2965
2964
- // Adds non-configurable (undirected) edge to be grouped.
2965
- //
2966
- // Returns true if this is a new edge.
2967
- bool add_non_config_edge (int from_node, int to_node) {
2968
- return graph_[from_node].edges .insert (to_node).second && graph_[to_node].edges .insert (from_node).second ;
2969
- }
2970
-
2971
- // After add_non_config_edge has been called for all edges, create_sets
2972
- // will form groups of nodes that are connected via non-configurable
2973
- // edges.
2974
- void create_sets () {
2975
- rr_non_config_node_sets_map_.clear ();
2976
-
2977
- // https://en.wikipedia.org/wiki/Component_(graph_theory)#Algorithms
2978
- std::vector<size_t > group_size;
2979
- for (auto & node : graph_) {
2980
- if (node.second .set == OPEN) {
2981
- node.second .set = group_size.size ();
2982
- group_size.push_back (add_connected_group (node.second ));
2983
- }
2984
- }
2966
+ // After add_non_config_edge has been called for all edges, create_sets
2967
+ // will form groups of nodes that are connected via non-configurable
2968
+ // edges.
2969
+ void EdgeGroups::create_sets () {
2970
+ rr_non_config_node_sets_map_.clear ();
2985
2971
2986
- // Sanity check the node sets.
2987
- for (const auto & node : graph_) {
2988
- VTR_ASSERT (node.second .set != OPEN);
2989
- for (const auto & e : node.second .edges ) {
2990
- int set = graph_[e].set ;
2991
- VTR_ASSERT (set == node.second .set );
2992
- }
2972
+ // https://en.wikipedia.org/wiki/Component_(graph_theory)#Algorithms
2973
+ std::vector<size_t > group_size;
2974
+ for (auto & node : graph_) {
2975
+ if (node.second .set == OPEN) {
2976
+ node.second .set = group_size.size ();
2977
+ group_size.push_back (add_connected_group (node.second ));
2993
2978
}
2979
+ }
2994
2980
2995
- // Create compact set of sets.
2996
- rr_non_config_node_sets_map_.resize (group_size.size ());
2997
- for (size_t i = 0 ; i < group_size.size (); i++) {
2998
- rr_non_config_node_sets_map_[i].reserve (group_size[i]);
2999
- }
3000
- for (const auto & node : graph_) {
3001
- rr_non_config_node_sets_map_[node.second .set ].push_back (node.first );
2981
+ // Sanity check the node sets.
2982
+ for (const auto & node : graph_) {
2983
+ VTR_ASSERT (node.second .set != OPEN);
2984
+ for (const auto & e : node.second .edges ) {
2985
+ int set = graph_[e].set ;
2986
+ VTR_ASSERT (set == node.second .set );
3002
2987
}
3003
2988
}
3004
2989
3005
- // Create t_non_configurable_rr_sets from set data.
3006
- // NOTE: The stored graph is undirected, so this may generate reverse edges that don't exist.
3007
- t_non_configurable_rr_sets output_sets () {
3008
- t_non_configurable_rr_sets sets;
3009
- for (const auto & nodes : rr_non_config_node_sets_map_) {
3010
- std::set<t_node_edge> edge_set;
3011
- std::set<int > node_set (nodes.begin (), nodes.end ());
2990
+ // Create compact set of sets.
2991
+ rr_non_config_node_sets_map_.resize (group_size.size ());
2992
+ for (size_t i = 0 ; i < group_size.size (); i++) {
2993
+ rr_non_config_node_sets_map_[i].reserve (group_size[i]);
2994
+ }
2995
+ for (const auto & node : graph_) {
2996
+ rr_non_config_node_sets_map_[node.second .set ].push_back (node.first );
2997
+ }
2998
+ }
3012
2999
3013
- for (const auto & src : node_set) {
3014
- for (const auto & dest : graph_[src].edges ) {
3015
- edge_set.emplace (t_node_edge (src, dest));
3016
- }
3000
+ // Create t_non_configurable_rr_sets from set data.
3001
+ // NOTE: The stored graph is undirected, so this may generate reverse edges that don't exist.
3002
+ t_non_configurable_rr_sets EdgeGroups::output_sets () {
3003
+ t_non_configurable_rr_sets sets;
3004
+ for (const auto & nodes : rr_non_config_node_sets_map_) {
3005
+ std::set<t_node_edge> edge_set;
3006
+ std::set<int > node_set (nodes.begin (), nodes.end ());
3007
+
3008
+ for (const auto & src : node_set) {
3009
+ for (const auto & dest : graph_[src].edges ) {
3010
+ edge_set.emplace (t_node_edge (src, dest));
3017
3011
}
3018
-
3019
- sets.node_sets .emplace (std::move (node_set));
3020
- sets.edge_sets .emplace (std::move (edge_set));
3021
3012
}
3022
3013
3023
- return sets;
3014
+ sets.node_sets .emplace (std::move (node_set));
3015
+ sets.edge_sets .emplace (std::move (edge_set));
3024
3016
}
3025
3017
3026
- // Set device context structures for non-configurable node sets.
3027
- void set_device_context () {
3028
- std::vector<std::vector<int >> rr_non_config_node_sets;
3029
- for (const auto & item : rr_non_config_node_sets_map_) {
3030
- rr_non_config_node_sets.emplace_back (std::move (item));
3031
- }
3018
+ return sets;
3019
+ }
3032
3020
3033
- std::unordered_map<int , int > rr_node_to_non_config_node_set;
3034
- for (size_t set = 0 ; set < rr_non_config_node_sets.size (); ++set) {
3035
- for (const auto inode : rr_non_config_node_sets[set]) {
3036
- rr_node_to_non_config_node_set.insert (
3037
- std::make_pair (inode, set));
3038
- }
3039
- }
3021
+ // Set device context structures for non-configurable node sets.
3022
+ void EdgeGroups::set_device_context () {
3023
+ std::vector<std::vector<int >> rr_non_config_node_sets;
3024
+ for (const auto & item : rr_non_config_node_sets_map_) {
3025
+ rr_non_config_node_sets.emplace_back (std::move (item));
3026
+ }
3040
3027
3041
- auto & device_ctx = g_vpr_ctx.mutable_device ();
3042
- device_ctx.rr_non_config_node_sets = std::move (rr_non_config_node_sets);
3043
- device_ctx.rr_node_to_non_config_node_set = std::move (rr_node_to_non_config_node_set);
3028
+ std::unordered_map<int , int > rr_node_to_non_config_node_set;
3029
+ for (size_t set = 0 ; set < rr_non_config_node_sets.size (); ++set) {
3030
+ for (const auto inode : rr_non_config_node_sets[set]) {
3031
+ rr_node_to_non_config_node_set.insert (
3032
+ std::make_pair (inode, set));
3033
+ }
3044
3034
}
3045
3035
3046
- private:
3047
- struct node_data {
3048
- std::unordered_set<int > edges;
3049
- int set = OPEN;
3050
- };
3036
+ auto & device_ctx = g_vpr_ctx.mutable_device ();
3037
+ device_ctx.rr_non_config_node_sets = std::move (rr_non_config_node_sets);
3038
+ device_ctx.rr_node_to_non_config_node_set = std::move (rr_node_to_non_config_node_set);
3039
+ }
3051
3040
3052
- // Perform a DFS traversal marking everything reachable with the same set id
3053
- size_t add_connected_group (const node_data& node) {
3054
- // stack contains nodes with edges to mark with node.set
3055
- // The set for each node must be set before pushing it onto the stack
3056
- std::stack<const node_data*> stack;
3057
- stack.push (&node);
3058
- size_t n = 1 ;
3059
- while (!stack.empty ()) {
3060
- auto top = stack.top ();
3061
- stack.pop ();
3062
- for (auto e : top->edges ) {
3063
- auto & next = graph_[e];
3064
- if (next.set != node.set ) {
3065
- VTR_ASSERT (next.set == OPEN);
3066
- n++;
3067
- next.set = node.set ;
3068
- stack.push (&next);
3069
- }
3041
+ // Perform a DFS traversal marking everything reachable with the same set id
3042
+ size_t EdgeGroups::add_connected_group (const node_data& node) {
3043
+ // stack contains nodes with edges to mark with node.set
3044
+ // The set for each node must be set before pushing it onto the stack
3045
+ std::stack<const node_data*> stack;
3046
+ stack.push (&node);
3047
+ size_t n = 1 ;
3048
+ while (!stack.empty ()) {
3049
+ auto top = stack.top ();
3050
+ stack.pop ();
3051
+ for (auto e : top->edges ) {
3052
+ auto & next = graph_[e];
3053
+ if (next.set != node.set ) {
3054
+ VTR_ASSERT (next.set == OPEN);
3055
+ n++;
3056
+ next.set = node.set ;
3057
+ stack.push (&next);
3070
3058
}
3071
3059
}
3072
- return n;
3073
3060
}
3074
-
3075
- // Set of non-configurable edges.
3076
- std::unordered_map<int , node_data> graph_;
3077
-
3078
- // Compact set of node sets. Map key is arbitrary.
3079
- std::vector<std::vector<int >> rr_non_config_node_sets_map_;
3080
- };
3061
+ return n;
3062
+ }
3081
3063
3082
3064
// Collects the sets of connected non-configurable edges in the RR graph
3083
3065
static void create_edge_groups (EdgeGroups* groups) {
0 commit comments