Skip to content

Commit 0c58fb3

Browse files
use rng to shuffle wire candiates
1 parent 7d9358e commit 0c58fb3

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

vpr/src/route/rr_graph_generation/build_scatter_gathers.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
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
*/
4345
static 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,

vpr/src/route/rr_graph_generation/build_scatter_gathers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#include <vector>
99

10+
// forward declartion
11+
namespace vtr {class RngContainer; }
12+
1013
/// Identifies a specific channel location in the device grid.
1114
struct t_chan_loc {
1215
t_physical_tile_loc location; ///< Physical grid location of the channel
@@ -45,6 +48,7 @@ struct t_bottleneck_link {
4548
* @param chan_details_x Channel details for horizontal routing channels.
4649
* @param chan_details_y Channel details for vertical routing channels.
4750
* @param nodes_per_chan Channel width data.
51+
* @param rng Random number generator used to shuffle wire candidates.
4852
* @param interdie_3d_links Output: matrix storing inter-die (3D) bottleneck links.
4953
* @return Vector of non-3d bottleneck links.
5054
*/
@@ -54,4 +58,5 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
5458
const t_chan_details& chan_details_x,
5559
const t_chan_details& chan_details_y,
5660
const t_chan_width& nodes_per_chan,
61+
vtr::RngContainer& rng,
5762
vtr::NdMatrix<std::vector<t_bottleneck_link>, 2>& interdie_3d_links);

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ static void build_rr_graph(e_graph_type graph_type,
12121212
segment_inf,
12131213
chan_details_x, chan_details_y,
12141214
nodes_per_chan,
1215+
switchpoint_rng,
12151216
interdie_3d_links);
12161217

12171218
// Check whether RR graph need to allocate new nodes for 3D connections.

0 commit comments

Comments
 (0)