11
22#include " build_scatter_gathers.h"
33
4+ #include < vector>
5+
46#include " switchblock_scatter_gather_common_utils.h"
57#include " scatter_gather_types.h"
68#include " rr_types.h"
79#include " globals.h"
810#include " vtr_assert.h"
9-
10- #include < vector>
11+ #include " vtr_random.h"
1112
1213//
13- // Static Function Declrations
14+ // Static Function Declarations
1415//
1516
1617/* *
@@ -31,13 +32,14 @@ static void index_to_correct_sg_channels(const t_wireconn_inf& pattern,
3132/* *
3233 * @brief Collects candidate wires from given channels that match specified switchpoints.
3334 *
34- * @param channels List of channel locations to search for candiates .
35+ * @param channels List of channel locations to search for candidates .
3536 * @param wire_switchpoints_vec Set of wire segments and valid switchpoints for matching.
3637 * @param chan_details_x Channel details for horizontal routing channels.
3738 * @param chan_details_y Channel details for vertical routing channels.
38- * @param is_dest True if searching for destination (scatter) wires, false for source (gather).
3939 * @param wire_type_sizes_x Stores the number of wires of each wire segment type and their starting index for horizontal routing channels.
4040 * @param wire_type_sizes_y Stores the number of wires of each wire segment type and their starting index for vertical routing channels.
41+ * @param is_dest True if searching for destination (scatter) wires, false for source (gather).
42+ * @param rng Random number generator used to shuffle wire candidates.
4143 * @return Vector of candidate wires that satisfy the switchpoint and direction constraints.
4244 */
4345static std::vector<t_sg_candidate> find_candidate_wires (const std::vector<t_chan_loc>& channels,
@@ -46,7 +48,8 @@ static std::vector<t_sg_candidate> find_candidate_wires(const std::vector<t_chan
4648 const t_chan_details& chan_details_y,
4749 const t_wire_type_sizes& wire_type_sizes_x,
4850 const t_wire_type_sizes& wire_type_sizes_y,
49- bool is_dest);
51+ bool is_dest,
52+ vtr::RngContainer& rng);
5053
5154//
5255// Static Function Definitions
@@ -77,7 +80,8 @@ static std::vector<t_sg_candidate> find_candidate_wires(const std::vector<t_chan
7780 const t_chan_details& chan_details_y,
7881 const t_wire_type_sizes& wire_type_sizes_x,
7982 const t_wire_type_sizes& wire_type_sizes_y,
80- bool is_dest) {
83+ bool is_dest,
84+ vtr::RngContainer& rng) {
8185
8286 // TODO: reuse
8387 std::vector<t_sg_candidate> candidates;
@@ -144,6 +148,9 @@ static std::vector<t_sg_candidate> find_candidate_wires(const std::vector<t_chan
144148 }
145149 }
146150
151+ // TODO: Whether we shuffle candidates or not should be determined by switch point order type.
152+ vtr::shuffle (candidates.begin (), candidates.end (), rng);
153+
147154 return candidates;
148155}
149156
@@ -157,6 +164,7 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
157164 const t_chan_details& chan_details_x,
158165 const t_chan_details& chan_details_y,
159166 const t_chan_width& nodes_per_chan,
167+ vtr::RngContainer& rng,
160168 vtr::NdMatrix<std::vector<t_bottleneck_link>, 2 >& interdie_3d_links) {
161169 const DeviceGrid& grid = g_vpr_ctx.device ().grid ;
162170
@@ -229,14 +237,14 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
229237 sg_pattern.gather_pattern .from_switchpoint_set ,
230238 chan_details_x, chan_details_y,
231239 wire_type_sizes_x, wire_type_sizes_y,
232- /* is_dest=*/ false );
240+ /* is_dest=*/ false , rng );
233241
234242 std::vector<t_sg_candidate> scatter_wire_candidates;
235243 scatter_wire_candidates = find_candidate_wires (scatter_channels,
236244 sg_pattern.scatter_pattern .to_switchpoint_set ,
237245 chan_details_x, chan_details_y,
238246 wire_type_sizes_x, wire_type_sizes_y,
239- /* is_dest=*/ true );
247+ /* is_dest=*/ true , rng );
240248
241249 int bottleneck_fanin = evaluate_num_conns_formula (formula_parser,
242250 formula_data,
0 commit comments