12
12
13
13
FeasibleRegionMoveGenerator::FeasibleRegionMoveGenerator (PlacerState& placer_state,
14
14
const PlaceMacros& place_macros,
15
+ const NetCostHandler& net_cost_handler,
15
16
e_reward_function reward_function,
16
17
vtr::RngContainer& rng)
17
- : MoveGenerator(placer_state, place_macros, reward_function, rng) {}
18
+ : MoveGenerator(placer_state, place_macros, net_cost_handler, reward_function, rng) {}
18
19
19
20
e_create_move FeasibleRegionMoveGenerator::propose_move (t_pl_blocks_to_be_moved& blocks_affected,
20
21
t_propose_action& proposed_action,
@@ -23,7 +24,6 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
23
24
const PlacerCriticalities* criticalities) {
24
25
const auto & cluster_ctx = g_vpr_ctx.clustering ();
25
26
auto & placer_state = placer_state_.get ();
26
- auto & place_move_ctx = placer_state.mutable_move ();
27
27
const auto & block_locs = placer_state.block_locs ();
28
28
const auto & blk_loc_registry = placer_state.blk_loc_registry ();
29
29
@@ -48,18 +48,22 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
48
48
49
49
// from block data
50
50
t_pl_loc from = block_locs[b_from].loc ;
51
- auto cluster_from_type = cluster_ctx.clb_nlist .block_type (b_from);
52
- auto grid_from_type = g_vpr_ctx.device ().grid .get_physical_type ({from.x , from.y , from.layer });
51
+ t_logical_block_type_ptr cluster_from_type = cluster_ctx.clb_nlist .block_type (b_from);
52
+ t_physical_tile_type_ptr grid_from_type = g_vpr_ctx.device ().grid .get_physical_type ({from.x , from.y , from.layer });
53
53
VTR_ASSERT (is_tile_compatible (grid_from_type, cluster_from_type));
54
54
55
55
/* Calculate the feasible region */
56
56
t_pl_loc to;
57
57
// Currently, we don't change the layer for this move
58
58
to.layer = from.layer ;
59
- int max_x, min_x, max_y, min_y;
60
59
61
- place_move_ctx.X_coord .clear ();
62
- place_move_ctx.Y_coord .clear ();
60
+ int max_x = std::numeric_limits<int >::min ();
61
+ int min_x = std::numeric_limits<int >::max ();
62
+ int max_y = std::numeric_limits<int >::min ();
63
+ int min_y = std::numeric_limits<int >::max ();
64
+
65
+ bool found = false ;
66
+
63
67
// For critical input nodes, calculate the x & y min-max values
64
68
for (ClusterPinId pin_id : cluster_ctx.clb_nlist .block_input_pins (b_from)) {
65
69
ClusterNetId net_id = cluster_ctx.clb_nlist .pin_net (pin_id);
@@ -69,28 +73,25 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
69
73
int ipin = cluster_ctx.clb_nlist .pin_net_index (pin_id);
70
74
if (criticalities->criticality (net_id, ipin) > placer_opts.place_crit_limit ) {
71
75
ClusterBlockId bnum = cluster_ctx.clb_nlist .net_driver_block (net_id);
72
- place_move_ctx.X_coord .push_back (block_locs[bnum].loc .x );
73
- place_move_ctx.Y_coord .push_back (block_locs[bnum].loc .y );
76
+ const t_pl_loc& loc = block_locs[bnum].loc ;
77
+ min_x = std::min (min_x, loc.x );
78
+ max_x = std::max (max_x, loc.x );
79
+ min_y = std::min (min_y, loc.y );
80
+ max_y = std::max (max_y, loc.y );
81
+ found = true ;
74
82
}
75
83
}
76
- if (!place_move_ctx.X_coord .empty ()) {
77
- max_x = *(std::max_element (place_move_ctx.X_coord .begin (), place_move_ctx.X_coord .end ()));
78
- min_x = *(std::min_element (place_move_ctx.X_coord .begin (), place_move_ctx.X_coord .end ()));
79
- max_y = *(std::max_element (place_move_ctx.Y_coord .begin (), place_move_ctx.Y_coord .end ()));
80
- min_y = *(std::min_element (place_move_ctx.Y_coord .begin (), place_move_ctx.Y_coord .end ()));
81
- } else {
82
- max_x = from.x ;
83
- min_x = from.x ;
84
- max_y = from.y ;
85
- min_y = from.y ;
84
+
85
+ if (!found) {
86
+ min_x = max_x = from.x ;
87
+ min_y = max_y = from.y ;
86
88
}
87
89
88
90
// Get the most critical output of the node
89
- int xt, yt;
90
91
ClusterBlockId b_output = cluster_ctx.clb_nlist .net_pin_block (net_from, pin_from);
91
92
t_pl_loc output_loc = block_locs[b_output].loc ;
92
- xt = output_loc.x ;
93
- yt = output_loc.y ;
93
+ int xt = output_loc.x ;
94
+ int yt = output_loc.y ;
94
95
95
96
/* *
96
97
* @brief determine the feasible region
@@ -128,14 +129,13 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
128
129
VTR_ASSERT (FR_coords.ymin <= FR_coords.ymax );
129
130
130
131
t_range_limiters range_limiters{rlim,
131
- place_move_ctx. first_rlim ,
132
+ first_rlim,
132
133
placer_opts.place_dm_rlim };
133
134
134
135
// Try to find a legal location inside the feasible region
135
136
if (!find_to_loc_median (cluster_from_type, from, &FR_coords, to, b_from, blk_loc_registry, rng_)) {
136
- /* * If there is no legal location in the feasible region, calculate the center of the FR and try to find a legal location
137
- * in a range around this center.
138
- */
137
+ /* If there is no legal location in the feasible region, calculate the center of the FR and try to find a legal location
138
+ * in a range around this center. */
139
139
t_pl_loc center;
140
140
center.x = (FR_coords.xmin + FR_coords.xmax ) / 2 ;
141
141
center.y = (FR_coords.ymin + FR_coords.ymax ) / 2 ;
0 commit comments