Skip to content

Commit 2f1c08d

Browse files
Bill-hbrhbrvaughnbetz
authored andcommitted
Added documentation according to review comments.
1 parent ce6c3a7 commit 2f1c08d

File tree

2 files changed

+52
-22
lines changed

2 files changed

+52
-22
lines changed

vpr/src/place/place_util.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,54 @@
11
/**
22
* @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.
45
*/
56

67
#include "place_util.h"
78
#include "globals.h"
89
#include "draw_global.h"
910

11+
/* File-scope routines */
1012
static vtr::Matrix<t_grid_blocks> init_grid_blocks();
1113

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+
*/
1222
void init_placement_context() {
1323
auto& place_ctx = g_vpr_ctx.mutable_placement();
1424
auto& cluster_ctx = g_vpr_ctx.clustering();
1525

26+
/* Intialize the lookup of CLB block positions */
1627
place_ctx.block_locs.clear();
1728
place_ctx.block_locs.resize(cluster_ctx.clb_nlist.blocks().size());
1829

30+
/* Initialize the reverse lookup of CLB block positions */
1931
place_ctx.grid_blocks = init_grid_blocks();
2032
}
2133

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+
*/
2240
static vtr::Matrix<t_grid_blocks> init_grid_blocks() {
2341
auto& device_ctx = g_vpr_ctx.device();
2442

43+
/* Structure should have the same dimensions as the grid. */
2544
auto grid_blocks = vtr::Matrix<t_grid_blocks>({device_ctx.grid.width(), device_ctx.grid.height()});
45+
2646
for (size_t x = 0; x < device_ctx.grid.width(); ++x) {
2747
for (size_t y = 0; y < device_ctx.grid.height(); ++y) {
2848
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);
3350
}
3451
}
35-
3652
return grid_blocks;
3753
}
3854

@@ -54,12 +70,13 @@ void t_placer_costs::update_norm_factors() {
5470
}
5571
}
5672

57-
///@brief Constructor: Initialize all annealing state variables.
73+
///@brief Constructor: Initialize all annealing state variables and macros.
5874
t_annealing_state::t_annealing_state(const t_annealing_sched& annealing_sched,
5975
float first_t,
6076
float first_rlim,
6177
int first_move_lim,
6278
float first_crit_exponent) {
79+
num_temps = 0;
6380
alpha = annealing_sched.alpha_min;
6481
t = first_t;
6582
restart_t = first_t;
@@ -74,8 +91,10 @@ t_annealing_state::t_annealing_state(const t_annealing_sched& annealing_sched,
7491
move_lim = move_lim_max;
7592
}
7693

94+
/* Store this inverse value for speed when updating crit_exponent. */
7795
INVERSE_DELTA_RLIM = 1 / (first_rlim - FINAL_RLIM);
7896

97+
/* The range limit cannot exceed the largest grid size. */
7998
auto& grid = g_vpr_ctx.device().grid;
8099
UPPER_RLIM = std::max(grid.width() - 1, grid.height() - 1);
81100
}
@@ -212,7 +231,7 @@ bool t_annealing_state::outer_loop_update(const t_placer_costs& costs,
212231
}
213232

214233
/**
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.
216235
*
217236
* Use a floating point rlim to allow gradual transitions at low temps.
218237
* 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) {
275294

276295
/* Very small variances sometimes round negative. */
277296
return (std_dev > 0.) ? sqrt(std_dev) : 0.;
278-
}
297+
}

vpr/src/place/place_util.h

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file place_util.h
33
* @brief Utility structures representing various states of the
4-
* placement. Also contains declarations of related routines.
4+
* placement and utility functions used by the placer.
55
*/
66

77
#pragma once
@@ -65,21 +65,31 @@ class t_placer_costs {
6565
* loop iteration. It stores various important variables that need to
6666
* be accessed during the placement inner loop.
6767
*
68+
* Private variables are not given accessor functions. They serve as
69+
* macros originally defined in place.cpp as global scope variables.
70+
*
6871
* Public members:
6972
* @param t
7073
* Temperature for simulated annealing.
71-
* @param rlim
72-
* Range limit for block swaps.
73-
* @param alpha
74-
* Temperature decays factor (multiplied each outer loop iteration).
7574
* @param restart_t
7675
* Temperature used after restart due to minimum success ratio.
76+
* Currently only used and updated by DUSTY_SCHED.
77+
* @param alpha
78+
* Temperature decays factor (multiplied each outer loop iteration).
79+
* @param num_temps
80+
* The count of how many temperature iterations have passed.
81+
*
82+
* @param rlim
83+
* Range limit for block swaps.
84+
* Currently only updated by DUSTY_SCHED and AUTO_SCHED.
7785
* @param crit_exponent
7886
* Used by timing-driven placement to "sharpen" the timing criticality.
79-
* @param move_lim_max
80-
* Maximum block move limit.
87+
* Depends on rlim. Currently only updated by DUSTY_SCHED and AUTO_SCHED.
8188
* @param move_lim
8289
* Current block move limit.
90+
* Currently only updated by DUSTY_SCHED.
91+
* @param move_lim_max
92+
* Maximum block move limit.
8393
*
8494
* Private members:
8595
* @param UPPER_RLIM
@@ -99,14 +109,15 @@ class t_placer_costs {
99109
class t_annealing_state {
100110
public:
101111
float t;
102-
float rlim;
103-
float alpha;
104112
float restart_t;
113+
float alpha;
114+
int num_temps;
115+
116+
float rlim;
105117
float crit_exponent;
106-
int move_lim_max;
107118
int move_lim;
119+
int move_lim_max;
108120
float success_rate;
109-
int num_temps = 0;
110121

111122
private:
112123
float UPPER_RLIM;
@@ -131,11 +142,11 @@ class t_annealing_state {
131142
inline void update_move_lim(float success_target);
132143
};
133144

134-
///@brief Initialize the placement context.
145+
///@brief Initialize the placer's block-grid dual direction mapping.
135146
void init_placement_context();
136147

137148
///@brief Get the initial limit for inner loop block move attempt limit.
138149
int get_initial_move_lim(const t_placer_opts& placer_opts, const t_annealing_sched& annealing_sched);
139150

140151
///@brief Returns the standard deviation of data set x.
141-
double get_std_dev(int n, double sum_x_squared, double av_x);
152+
double get_std_dev(int n, double sum_x_squared, double av_x);

0 commit comments

Comments
 (0)