1
1
/* *
2
2
* @file place_util.cpp
3
- * @brief Definitions of structure routines declared in place_util.h.
3
+ * @brief Definitions of structure methods and routines declared in place_util.h.
4
+ * These are mainly utility functions used by the placer.
4
5
*/
5
6
6
7
#include " place_util.h"
7
8
#include " globals.h"
8
9
#include " draw_global.h"
9
10
11
+ /* File-scope routines */
10
12
static vtr::Matrix<t_grid_blocks> init_grid_blocks ();
11
13
14
+ /* *
15
+ * @brief Initialize the placer's block-grid dual direction mapping.
16
+ *
17
+ * Forward direction - block to grid: place_ctx.block_locs.
18
+ * Reverse direction - grid to block: place_ctx.grid_blocks.
19
+ *
20
+ * Initialize both of them to empty states.
21
+ */
12
22
void init_placement_context () {
13
23
auto & place_ctx = g_vpr_ctx.mutable_placement ();
14
24
auto & cluster_ctx = g_vpr_ctx.clustering ();
15
25
26
+ /* Intialize the lookup of CLB block positions */
16
27
place_ctx.block_locs .clear ();
17
28
place_ctx.block_locs .resize (cluster_ctx.clb_nlist .blocks ().size ());
18
29
30
+ /* Initialize the reverse lookup of CLB block positions */
19
31
place_ctx.grid_blocks = init_grid_blocks ();
20
32
}
21
33
34
+ /* *
35
+ * @brief Initialize `grid_blocks`, the inverse structure of `block_locs`.
36
+ *
37
+ * The container at each grid block location should have a length equal to the
38
+ * subtile capacity of that block. Unused subtile would be marked EMPTY_BLOCK_ID.
39
+ */
22
40
static vtr::Matrix<t_grid_blocks> init_grid_blocks () {
23
41
auto & device_ctx = g_vpr_ctx.device ();
24
42
43
+ /* Structure should have the same dimensions as the grid. */
25
44
auto grid_blocks = vtr::Matrix<t_grid_blocks>({device_ctx.grid .width (), device_ctx.grid .height ()});
45
+
26
46
for (size_t x = 0 ; x < device_ctx.grid .width (); ++x) {
27
47
for (size_t y = 0 ; y < device_ctx.grid .height (); ++y) {
28
48
auto type = device_ctx.grid [x][y].type ;
29
-
30
- int capacity = type->capacity ;
31
-
32
- grid_blocks[x][y].blocks .resize (capacity, EMPTY_BLOCK_ID);
49
+ grid_blocks[x][y].blocks .resize (type->capacity , EMPTY_BLOCK_ID);
33
50
}
34
51
}
35
-
36
52
return grid_blocks;
37
53
}
38
54
@@ -54,12 +70,13 @@ void t_placer_costs::update_norm_factors() {
54
70
}
55
71
}
56
72
57
- // /@brief Constructor: Initialize all annealing state variables.
73
+ // /@brief Constructor: Initialize all annealing state variables and macros .
58
74
t_annealing_state::t_annealing_state (const t_annealing_sched& annealing_sched,
59
75
float first_t ,
60
76
float first_rlim,
61
77
int first_move_lim,
62
78
float first_crit_exponent) {
79
+ num_temps = 0 ;
63
80
alpha = annealing_sched.alpha_min ;
64
81
t = first_t ;
65
82
restart_t = first_t ;
@@ -74,8 +91,10 @@ t_annealing_state::t_annealing_state(const t_annealing_sched& annealing_sched,
74
91
move_lim = move_lim_max;
75
92
}
76
93
94
+ /* Store this inverse value for speed when updating crit_exponent. */
77
95
INVERSE_DELTA_RLIM = 1 / (first_rlim - FINAL_RLIM);
78
96
97
+ /* The range limit cannot exceed the largest grid size. */
79
98
auto & grid = g_vpr_ctx.device ().grid ;
80
99
UPPER_RLIM = std::max (grid.width () - 1 , grid.height () - 1 );
81
100
}
@@ -212,7 +231,7 @@ bool t_annealing_state::outer_loop_update(const t_placer_costs& costs,
212
231
}
213
232
214
233
/* *
215
- * @brief Update the range limited to keep acceptance prob. near 0.44.
234
+ * @brief Update the range limiter to keep acceptance prob. near 0.44.
216
235
*
217
236
* Use a floating point rlim to allow gradual transitions at low temps.
218
237
* The range is bounded by 1 (FINAL_RLIM) and the grid size (UPPER_RLIM).
@@ -275,4 +294,4 @@ double get_std_dev(int n, double sum_x_squared, double av_x) {
275
294
276
295
/* Very small variances sometimes round negative. */
277
296
return (std_dev > 0 .) ? sqrt (std_dev) : 0 .;
278
- }
297
+ }
0 commit comments