@@ -66,24 +66,16 @@ void PlaceMacros::alloc_and_load_placement_macros(const std::vector<t_direct_inf
66
66
* the amount of memory required for the actual variables.
67
67
* 2) Allocate the actual variables with the exact amount of
68
68
* memory. Then loads the data from the temporary data
69
- * structures before freeing them.
70
- *
71
- * For pl_macro_member_blk_num, allocate for the first dimension
72
- * only at first. Allocate for the second dimension when I know
73
- * the size. Otherwise, the array is going to be of size
74
- * cluster_ctx.clb_nlist.blocks().size()^2 (There are big
75
- * benchmarks VPR that have cluster_ctx.clb_nlist.blocks().size()
76
- * in the 100k's range).
77
- *
78
- * The placement macro array is freed by the caller(s).
69
+ * structures before freeing them.
79
70
*/
80
- auto & cluster_ctx = g_vpr_ctx.clustering ();
71
+ const auto & cluster_ctx = g_vpr_ctx.clustering ();
81
72
82
73
// Allocate maximum memory for temporary variables.
83
74
std::vector<int > pl_macro_idirect (cluster_ctx.clb_nlist .blocks ().size ());
84
75
std::vector<int > pl_macro_num_members (cluster_ctx.clb_nlist .blocks ().size ());
76
+ /* For pl_macro_member_blk_num, Allocate for the first dimension only at first. Allocate for the second dimension
77
+ * when I know the size. Otherwise, the array is going to be of size cluster_ctx.clb_nlist.blocks().size()^2 */
85
78
std::vector<std::vector<ClusterBlockId>> pl_macro_member_blk_num (cluster_ctx.clb_nlist .blocks ().size ());
86
- std::vector<ClusterBlockId> pl_macro_member_blk_num_of_this_blk (cluster_ctx.clb_nlist .blocks ().size ());
87
79
88
80
alloc_and_load_idirect_from_blk_pin_ (directs);
89
81
@@ -94,8 +86,7 @@ void PlaceMacros::alloc_and_load_placement_macros(const std::vector<t_direct_inf
94
86
* Head - blocks with to_pin OPEN and from_pin connected
95
87
* Tail - blocks with to_pin connected and from_pin OPEN
96
88
*/
97
- int num_macro = find_all_the_macro_ (pl_macro_member_blk_num_of_this_blk,
98
- pl_macro_idirect, pl_macro_num_members, pl_macro_member_blk_num);
89
+ const int num_macro = find_all_the_macro_ (pl_macro_idirect, pl_macro_num_members, pl_macro_member_blk_num);
99
90
100
91
// Allocate the memories for the macro.
101
92
pl_macros_.resize (num_macro);
@@ -133,8 +124,7 @@ ClusterBlockId PlaceMacros::macro_head(ClusterBlockId blk) const {
133
124
}
134
125
}
135
126
136
- int PlaceMacros::find_all_the_macro_ (std::vector<ClusterBlockId>& pl_macro_member_blk_num_of_this_blk,
137
- std::vector<int >& pl_macro_idirect,
127
+ int PlaceMacros::find_all_the_macro_ (std::vector<int >& pl_macro_idirect,
138
128
std::vector<int >& pl_macro_num_members,
139
129
std::vector<std::vector<ClusterBlockId>>& pl_macro_member_blk_num) {
140
130
/* Compute required size: *
@@ -143,30 +133,26 @@ int PlaceMacros::find_all_the_macro_(std::vector<ClusterBlockId>& pl_macro_membe
143
133
* as the number macros) and also the length of each macro *
144
134
* Head - blocks with to_pin OPEN and from_pin connected *
145
135
* Tail - blocks with to_pin connected and from_pin OPEN */
146
-
147
- int from_iblk_pin, to_iblk_pin, from_idirect, to_idirect,
148
- from_src_or_sink, to_src_or_sink;
149
- ClusterNetId to_net_id, from_net_id, next_net_id, curr_net_id;
150
- ClusterBlockId next_blk_id;
151
- int num_blk_pins, num_macro;
152
- int imember;
153
- auto & cluster_ctx = g_vpr_ctx.clustering ();
136
+ const auto & cluster_ctx = g_vpr_ctx.clustering ();
137
+ std::vector<ClusterBlockId> pl_macro_member_blk_num_of_this_blk (cluster_ctx.clb_nlist .blocks ().size ());
154
138
155
139
// Hash table holding the unique cluster ids and the macro id it belongs to
156
140
std::unordered_map<ClusterBlockId, int > clusters_macro;
157
141
158
- num_macro = 0 ;
159
- for (auto blk_id : cluster_ctx.clb_nlist .blocks ()) {
160
- auto logical_block = cluster_ctx.clb_nlist .block_type (blk_id);
161
- auto physical_tile = pick_physical_type (logical_block);
142
+ // counts the total number of macros
143
+ int num_macro = 0 ;
144
+
145
+ for (ClusterBlockId blk_id : cluster_ctx.clb_nlist .blocks ()) {
146
+ t_logical_block_type_ptr logical_block = cluster_ctx.clb_nlist .block_type (blk_id);
147
+ t_physical_tile_type_ptr physical_tile = pick_physical_type (logical_block);
162
148
163
- num_blk_pins = cluster_ctx.clb_nlist .block_type (blk_id)->pb_type ->num_pins ;
164
- for (to_iblk_pin = 0 ; to_iblk_pin < num_blk_pins; to_iblk_pin++) {
149
+ int num_blk_pins = cluster_ctx.clb_nlist .block_type (blk_id)->pb_type ->num_pins ;
150
+ for (int to_iblk_pin = 0 ; to_iblk_pin < num_blk_pins; to_iblk_pin++) {
165
151
int to_physical_pin = get_physical_pin (physical_tile, logical_block, to_iblk_pin);
166
152
167
- to_net_id = cluster_ctx.clb_nlist .block_net (blk_id, to_iblk_pin);
168
- to_idirect = idirect_from_blk_pin_[physical_tile->index ][to_physical_pin];
169
- to_src_or_sink = direct_type_from_blk_pin_[physical_tile->index ][to_physical_pin];
153
+ ClusterNetId to_net_id = cluster_ctx.clb_nlist .block_net (blk_id, to_iblk_pin);
154
+ int to_idirect = idirect_from_blk_pin_[physical_tile->index ][to_physical_pin];
155
+ int to_src_or_sink = direct_type_from_blk_pin_[physical_tile->index ][to_physical_pin];
170
156
171
157
// Identify potential macro head blocks (i.e. start of a macro)
172
158
//
@@ -177,16 +163,14 @@ int PlaceMacros::find_all_the_macro_(std::vector<ClusterBlockId>& pl_macro_membe
177
163
// Note that the restriction that constant nets are not driven from another direct ensures that
178
164
// blocks in the middle of a chain with internal constant signals are not detected as potential
179
165
// head blocks.
180
- if (to_src_or_sink == SINK && to_idirect != OPEN
181
- && (to_net_id == ClusterNetId::INVALID ()
182
- || (is_constant_clb_net (to_net_id)
183
- && !net_is_driven_by_direct_ (to_net_id)))) {
184
- for (from_iblk_pin = 0 ; from_iblk_pin < num_blk_pins; from_iblk_pin++) {
166
+ if (to_src_or_sink == SINK && to_idirect != OPEN &&
167
+ (to_net_id == ClusterNetId::INVALID () || (is_constant_clb_net (to_net_id) && !net_is_driven_by_direct_ (to_net_id)))) {
168
+ for (int from_iblk_pin = 0 ; from_iblk_pin < num_blk_pins; from_iblk_pin++) {
185
169
int from_physical_pin = get_physical_pin (physical_tile, logical_block, from_iblk_pin);
186
170
187
- from_net_id = cluster_ctx.clb_nlist .block_net (blk_id, from_iblk_pin);
188
- from_idirect = idirect_from_blk_pin_[physical_tile->index ][from_physical_pin];
189
- from_src_or_sink = direct_type_from_blk_pin_[physical_tile->index ][from_physical_pin];
171
+ ClusterNetId from_net_id = cluster_ctx.clb_nlist .block_net (blk_id, from_iblk_pin);
172
+ int from_idirect = idirect_from_blk_pin_[physical_tile->index ][from_physical_pin];
173
+ int from_src_or_sink = direct_type_from_blk_pin_[physical_tile->index ][from_physical_pin];
190
174
191
175
// Confirm whether this is a head macro
192
176
//
@@ -204,12 +188,12 @@ int PlaceMacros::find_all_the_macro_(std::vector<ClusterBlockId>& pl_macro_membe
204
188
// there are at least 2 members - 1 head and 1 tail.
205
189
206
190
// Initialize the variables
207
- next_net_id = from_net_id;
208
- next_blk_id = blk_id;
191
+ ClusterNetId next_net_id = from_net_id;
192
+ ClusterBlockId next_blk_id = blk_id;
209
193
210
194
// Start finding the other members
211
195
while (next_net_id != ClusterNetId::INVALID ()) {
212
- curr_net_id = next_net_id;
196
+ ClusterNetId curr_net_id = next_net_id;
213
197
214
198
// Assume that carry chains only has 1 sink - direct connection
215
199
VTR_ASSERT (cluster_ctx.clb_nlist .net_sinks (curr_net_id).size () == 1 );
@@ -221,7 +205,7 @@ int PlaceMacros::find_all_the_macro_(std::vector<ClusterBlockId>& pl_macro_membe
221
205
next_net_id = cluster_ctx.clb_nlist .block_net (next_blk_id, from_iblk_pin);
222
206
223
207
// Mark down this block as a member of the macro
224
- imember = pl_macro_num_members[num_macro];
208
+ int imember = pl_macro_num_members[num_macro];
225
209
pl_macro_member_blk_num_of_this_blk[imember] = next_blk_id;
226
210
227
211
// Increment the num_member count.
@@ -233,7 +217,7 @@ int PlaceMacros::find_all_the_macro_(std::vector<ClusterBlockId>& pl_macro_membe
233
217
pl_macro_member_blk_num[num_macro].resize (pl_macro_num_members[num_macro]);
234
218
int matching_macro = -1 ;
235
219
// Copy the data from the temporary array to the newly allocated array.
236
- for (imember = 0 ; imember < pl_macro_num_members[num_macro]; imember++) {
220
+ for (int imember = 0 ; imember < pl_macro_num_members[num_macro]; imember++) {
237
221
auto cluster_id = pl_macro_member_blk_num_of_this_blk[imember];
238
222
pl_macro_member_blk_num[num_macro][imember] = cluster_id;
239
223
// check if this cluster block was in a previous macro
@@ -382,7 +366,7 @@ static bool try_combine_macros(std::vector<std::vector<ClusterBlockId>>& pl_macr
382
366
int PlaceMacros::get_imacro_from_iblk (ClusterBlockId iblk) const {
383
367
int imacro;
384
368
if (iblk != ClusterBlockId::INVALID ()) {
385
- /* Return the imacro for the block. */
369
+ // Return the imacro for the block.
386
370
imacro = imacro_from_iblk_[iblk];
387
371
} else {
388
372
imacro = OPEN; // No valid block, so no valid macro
@@ -619,7 +603,7 @@ void PlaceMacros::write_place_macros_(std::string filename, const std::vector<t_
619
603
}
620
604
621
605
static bool is_constant_clb_net (ClusterNetId clb_net) {
622
- auto & atom_ctx = g_vpr_ctx.atom ();
606
+ const auto & atom_ctx = g_vpr_ctx.atom ();
623
607
AtomNetId atom_net = atom_ctx.lookup .atom_net (clb_net);
624
608
625
609
return atom_ctx.nlist .net_is_constant (atom_net);
0 commit comments