@@ -51,6 +51,26 @@ static void place_noc_routers_randomly(std::vector<ClusterBlockId>& unfixed_rout
51
51
*/
52
52
static void noc_routers_anneal (const t_noc_opts& noc_opts);
53
53
54
+ /* *
55
+ * @brief Returns the compressed grid of NoC.
56
+ * @return const t_compressed_block_grid& The compressed grid of NoC.
57
+ */
58
+ static const t_compressed_block_grid& get_compressed_noc_grid ();
59
+
60
+ static const t_compressed_block_grid& get_compressed_noc_grid () {
61
+ auto & noc_ctx = g_vpr_ctx.noc ();
62
+ auto & place_ctx = g_vpr_ctx.placement ();
63
+ auto & cluster_ctx = g_vpr_ctx.clustering ();
64
+
65
+ // Get the logical block type for router
66
+ const t_logical_block_type_ptr router_block_type = cluster_ctx.clb_nlist .block_type (noc_ctx.noc_traffic_flows_storage .get_router_clusters_in_netlist ()[0 ]);
67
+
68
+ // Get the compressed grid for NoC
69
+ const auto & compressed_noc_grid = place_ctx.compressed_block_grids [router_block_type->index ];
70
+
71
+ return compressed_noc_grid;
72
+ }
73
+
54
74
static bool accept_noc_swap (double delta_cost, double prob) {
55
75
if (delta_cost <= 0.0 ) {
56
76
return true ;
@@ -99,7 +119,6 @@ static void place_constrained_noc_router(ClusterBlockId router_blk_id) {
99
119
static void place_noc_routers_randomly (std::vector<ClusterBlockId>& unfixed_routers, int seed) {
100
120
auto & place_ctx = g_vpr_ctx.placement ();
101
121
auto & noc_ctx = g_vpr_ctx.noc ();
102
- auto & cluster_ctx = g_vpr_ctx.clustering ();
103
122
auto & device_ctx = g_vpr_ctx.device ();
104
123
105
124
/*
@@ -123,15 +142,12 @@ static void place_noc_routers_randomly(std::vector<ClusterBlockId>& unfixed_rout
123
142
vtr::RandState rand_state = seed;
124
143
vtr::shuffle (noc_phy_routers.begin (), noc_phy_routers.end (), rand_state);
125
144
126
- // Get the logical block type for router
127
- const auto router_block_type = cluster_ctx.clb_nlist .block_type (noc_ctx.noc_traffic_flows_storage .get_router_clusters_in_netlist ()[0 ]);
128
-
129
145
// Get the compressed grid for NoC
130
- const auto & compressed_noc_grid = place_ctx. compressed_block_grids [router_block_type-> index ] ;
146
+ const auto & compressed_noc_grid = get_compressed_noc_grid () ;
131
147
132
148
// Iterate over shuffled physical routers to place logical routers
133
149
// Since physical routers are shuffled, router placement would be random
134
- for (const auto & phy_router : noc_phy_routers) {
150
+ for (const NocRouter & phy_router : noc_phy_routers) {
135
151
t_physical_tile_loc router_phy_loc = phy_router.get_router_physical_location ();
136
152
137
153
// Find a compatible sub-tile
@@ -143,7 +159,7 @@ static void place_noc_routers_randomly(std::vector<ClusterBlockId>& unfixed_rout
143
159
144
160
if (place_ctx.grid_blocks .is_sub_tile_empty (router_phy_loc, sub_tile)) {
145
161
// Pick one of the unplaced routers
146
- auto logical_router_bid = unfixed_routers.back ();
162
+ ClusterBlockId logical_router_bid = unfixed_routers.back ();
147
163
unfixed_routers.pop_back ();
148
164
149
165
// Create a macro with a single member
@@ -179,11 +195,16 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts) {
179
195
update_noc_normalization_factors (costs);
180
196
costs.cost = calculate_noc_cost (costs.noc_cost_terms , costs.noc_cost_norm_factors , noc_opts);
181
197
182
- // Maximum distance in each direction that a router can travel in a move
183
- // It is assumed that NoC routers are organized in a square grid.
184
- // Each router can initially move within the entire grid with a single swap.
198
+ const auto & compressed_noc_grid = get_compressed_noc_grid ();
199
+ const size_t n_noc_layers = compressed_noc_grid.get_layer_nums ().size ();
200
+
201
+ /* Maximum distance in each direction that a router can travel in a move
202
+ * It is assumed that NoC routers are organized in a square grid.
203
+ * Each router can initially move within the entire grid with a single swap.
204
+ * For 3D NoCs, it is assumed that each layer has the same number of routers,
205
+ * and each layer NoC routers are laid out in a square grid. */
185
206
const size_t n_physical_routers = noc_ctx.noc_model .get_noc_routers ().size ();
186
- const float max_r_lim = ceilf (sqrtf ((float )n_physical_routers));
207
+ const float max_r_lim = ceilf (sqrtf ((float )n_physical_routers / ( float )n_noc_layers ));
187
208
188
209
// At most, two routers are swapped
189
210
t_pl_blocks_to_be_moved blocks_affected (2 );
@@ -266,7 +287,7 @@ void initial_noc_placement(const t_noc_opts& noc_opts, const t_placer_opts& plac
266
287
std::vector<ClusterBlockId> unfixed_routers;
267
288
268
289
// Check for floorplanning constraints and place constrained NoC routers
269
- for (auto router_blk_id : router_blk_ids) {
290
+ for (const ClusterBlockId router_blk_id : router_blk_ids) {
270
291
// The block is fixed and was placed in mark_fixed_blocks()
271
292
if (is_block_placed ((router_blk_id))) {
272
293
continue ;
0 commit comments