1
1
#ifndef CLUSTER_UTIL_H
2
2
#define CLUSTER_UTIL_H
3
3
4
+ #include < unordered_set>
4
5
#include < vector>
5
6
#include " cluster_legalizer.h"
6
7
#include " pack_types.h"
@@ -63,18 +64,9 @@ struct t_molecule_stats {
63
64
int num_used_ext_outputs = 0 ; // Number of *used external* output pins across all primitives in molecule
64
65
};
65
66
66
- struct t_cluster_progress_stats {
67
- int num_molecules = 0 ;
68
- int num_molecules_processed = 0 ;
69
- int mols_since_last_print = 0 ;
70
- int blocks_since_last_analysis = 0 ;
71
- int num_unrelated_clustering_attempts = 0 ;
72
- };
73
-
74
67
/* Useful data structures for creating or modifying clusters */
75
68
struct t_clustering_data {
76
- int * hill_climbing_inputs_avail;
77
-
69
+ int unclustered_list_head_size = 0 ;
78
70
/* Keeps a linked list of the unclustered blocks to speed up looking for *
79
71
* unclustered blocks with a certain number of *external* inputs. *
80
72
* [0..lut_size]. Unclustered_list_head[i] points to the head of the *
@@ -83,16 +75,6 @@ struct t_clustering_data {
83
75
84
76
// Maintaining a linked list of free molecule data for speed
85
77
t_molecule_link* memory_pool = nullptr ;
86
-
87
- /* Does the atom block that drives the output of this atom net also appear as a *
88
- * receiver (input) pin of the atom net? If so, then by how much?
89
- *
90
- * This is used in the gain routines to avoid double counting the connections from *
91
- * the current cluster to other blocks (hence yielding better clusterings). *
92
- * The only time an atom block should connect to the same atom net *
93
- * twice is when one connection is an output and the other is an input, *
94
- * so this should take care of all multiple connections. */
95
- std::unordered_map<AtomNetId, int > net_output_feeds_driving_block_input;
96
78
};
97
79
98
80
/* **********************************/
@@ -112,8 +94,7 @@ void calc_init_packing_timing(const t_packer_opts& packer_opts,
112
94
/*
113
95
* @brief Free the clustering data structures.
114
96
*/
115
- void free_clustering_data (const t_packer_opts& packer_opts,
116
- t_clustering_data& clustering_data);
97
+ void free_clustering_data (t_clustering_data& clustering_data);
117
98
118
99
/*
119
100
* @brief Check clustering legality and output it.
@@ -154,8 +135,6 @@ void remove_molecule_from_pb_stats_candidates(t_pack_molecule* molecule,
154
135
void alloc_and_init_clustering (const t_molecule_stats& max_molecule_stats,
155
136
const Prepacker& prepacker,
156
137
t_clustering_data& clustering_data,
157
- std::unordered_map<AtomNetId, int >& net_output_feeds_driving_block_input,
158
- int & unclustered_list_head_size,
159
138
int num_molecules);
160
139
161
140
/*
@@ -195,8 +174,7 @@ void print_pack_status_header();
195
174
/*
196
175
* @brief Incrementally print progress updates during clustering.
197
176
*/
198
- void print_pack_status (int num_clb,
199
- int tot_num_molecules,
177
+ void print_pack_status (int tot_num_molecules,
200
178
int num_molecules_processed,
201
179
int & mols_since_last_print,
202
180
int device_width,
@@ -212,42 +190,6 @@ void print_pack_status(int num_clb,
212
190
void rebuild_attraction_groups (AttractionInfo& attraction_groups,
213
191
const ClusterLegalizer& cluster_legalizer);
214
192
215
- /*
216
- * @brief Try to pack next_molecule into the given cluster. If this succeeds
217
- * prepares the next_molecule with a new value to pack next iteration.
218
- *
219
- * This method will print the pack status and update the cluster stats.
220
- */
221
- void try_fill_cluster (ClusterLegalizer& cluster_legalizer,
222
- const Prepacker& prepacker,
223
- const t_packer_opts& packer_opts,
224
- t_pack_molecule*& prev_molecule,
225
- t_pack_molecule*& next_molecule,
226
- int & num_same_molecules,
227
- t_cluster_progress_stats& cluster_stats,
228
- int num_clb,
229
- const LegalizationClusterId legalization_cluster_id,
230
- AttractionInfo& attraction_groups,
231
- vtr::vector<LegalizationClusterId, std::vector<AtomNetId>>& clb_inter_blk_nets,
232
- bool allow_unrelated_clustering,
233
- const int & high_fanout_threshold,
234
- const std::unordered_set<AtomNetId>& is_clock,
235
- const std::unordered_set<AtomNetId>& is_global,
236
- const std::shared_ptr<SetupTimingInfo>& timing_info,
237
- e_block_pack_status& block_pack_status,
238
- t_molecule_link* unclustered_list_head,
239
- const int & unclustered_list_head_size,
240
- std::unordered_map<AtomNetId, int >& net_output_feeds_driving_block_input,
241
- std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
242
-
243
- void store_cluster_info_and_free (const t_packer_opts& packer_opts,
244
- const LegalizationClusterId clb_index,
245
- const t_logical_block_type_ptr logic_block_type,
246
- const t_pb_type* le_pb_type,
247
- std::vector<int >& le_count,
248
- const ClusterLegalizer& cluster_legalizer,
249
- vtr::vector<LegalizationClusterId, std::vector<AtomNetId>>& clb_inter_blk_nets);
250
-
251
193
void update_connection_gain_values (const AtomNetId net_id,
252
194
const AtomBlockId clustered_blk_id,
253
195
t_pb* cur_pb,
@@ -260,7 +202,7 @@ void update_timing_gain_values(const AtomNetId net_id,
260
202
enum e_net_relation_to_clustered_block net_relation_to_clustered_block,
261
203
const SetupTimingInfo& timing_info,
262
204
const std::unordered_set<AtomNetId>& is_global,
263
- std::unordered_map <AtomNetId, int >& net_output_feeds_driving_block_input);
205
+ const std::unordered_set <AtomNetId>& net_output_feeds_driving_block_input);
264
206
265
207
/*
266
208
* @brief Updates the marked data structures, and if gain_flag is GAIN, the gain
@@ -281,7 +223,7 @@ void mark_and_update_partial_gain(const AtomNetId net_id,
281
223
const SetupTimingInfo& timing_info,
282
224
const std::unordered_set<AtomNetId>& is_global,
283
225
const int high_fanout_net_threshold,
284
- std::unordered_map <AtomNetId, int >& net_output_feeds_driving_block_input);
226
+ const std::unordered_set <AtomNetId>& net_output_feeds_driving_block_input);
285
227
286
228
/*
287
229
* @brief Updates the total gain array to reflect the desired tradeoff between
@@ -309,24 +251,7 @@ void update_cluster_stats(const t_pack_molecule* molecule,
309
251
const int high_fanout_net_threshold,
310
252
const SetupTimingInfo& timing_info,
311
253
AttractionInfo& attraction_groups,
312
- std::unordered_map<AtomNetId, int >& net_output_feeds_driving_block_input);
313
-
314
- /*
315
- * @brief Given a starting seed block, start_new_cluster determines the next
316
- * cluster type to use.
317
- *
318
- * It expands the FPGA if it cannot find a legal cluster for the atom block
319
- */
320
- void start_new_cluster (ClusterLegalizer& cluster_legalizer,
321
- LegalizationClusterId& legalization_cluster_id,
322
- t_pack_molecule* molecule,
323
- std::map<t_logical_block_type_ptr, size_t >& num_used_type_instances,
324
- const float target_device_utilization,
325
- const t_arch* arch,
326
- const std::string& device_layout_name,
327
- const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types,
328
- int verbosity,
329
- bool balance_block_type_utilization);
254
+ const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input);
330
255
331
256
/*
332
257
* @brief Get candidate molecule to pack into currently open cluster
@@ -351,7 +276,7 @@ t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
351
276
bool prioritize_transitive_connectivity,
352
277
int transitive_fanout_threshold,
353
278
const int feasible_block_array_size,
354
- std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
279
+ const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
355
280
356
281
/*
357
282
* @brief Add molecules with strong connectedness to the current cluster to the
@@ -392,7 +317,7 @@ void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
392
317
AttractionInfo& attraction_groups,
393
318
const int feasible_block_array_size,
394
319
LegalizationClusterId clb_index,
395
- std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
320
+ const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
396
321
397
322
/*
398
323
* @brief Add molecules based on transitive connections (eg. 2 hops away) with
@@ -421,7 +346,7 @@ t_pack_molecule* get_molecule_for_cluster(t_pb* cur_pb,
421
346
int verbosity,
422
347
t_molecule_link* unclustered_list_head,
423
348
const int & unclustered_list_head_size,
424
- std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
349
+ const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
425
350
426
351
/*
427
352
* @brief Calculates molecule statistics for a single molecule.
@@ -455,6 +380,12 @@ void load_transitive_fanout_candidates(LegalizationClusterId cluster_index,
455
380
456
381
std::map<const t_model*, std::vector<t_logical_block_type_ptr>> identify_primitive_candidate_block_types ();
457
382
383
+ /* *
384
+ * @brief Identify which nets in the atom netlist are driven by the same atom
385
+ * block that they appear as a receiver (input) pin of.
386
+ */
387
+ std::unordered_set<AtomNetId> identify_net_output_feeds_driving_block_input (const AtomNetlist& atom_netlist);
388
+
458
389
/* *
459
390
* @brief This function update the pb_type_count data structure by incrementing
460
391
* the number of used pb_types in the given packed cluster t_pb
@@ -465,7 +396,7 @@ size_t update_pb_type_count(const t_pb* pb, std::map<t_pb_type*, int>& pb_type_c
465
396
* @brief This function updates the le_count data structure from the given
466
397
* packed cluster.
467
398
*/
468
- void update_le_count (const t_pb* pb, const t_logical_block_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::vector <int >& le_count);
399
+ void update_le_count (const t_pb* pb, const t_logical_block_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::array <int , 3 >& le_count);
469
400
470
401
void print_pb_type_count_recurr (t_pb_type* type, size_t max_name_chars, size_t curr_depth, std::map<t_pb_type*, int >& pb_type_count);
471
402
@@ -478,7 +409,7 @@ void print_pb_type_count(const ClusteredNetlist& clb_nlist);
478
409
* @brief This function identifies the logic block type which is defined by the
479
410
* block type which has a lut primitive.
480
411
*/
481
- t_logical_block_type_ptr identify_logic_block_type (std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
412
+ t_logical_block_type_ptr identify_logic_block_type (const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types);
482
413
483
414
/*
484
415
* @brief This function returns the pb_type that is similar to Logic Element (LE)
@@ -499,7 +430,7 @@ bool pb_used_for_blif_model(const t_pb* pb, const std::string& blif_model_name);
499
430
/*
500
431
* @brief Print the LE count data strurture.
501
432
*/
502
- void print_le_count (std::vector <int >& le_count, const t_pb_type* le_pb_type);
433
+ void print_le_count (const std::array <int , 3 >& le_count, const t_pb_type* le_pb_type);
503
434
504
435
/*
505
436
* @brief Given a pointer to a pb in a cluster, this routine returns a pointer
0 commit comments