11#ifndef CLUSTER_UTIL_H
22#define CLUSTER_UTIL_H
33
4+ #include < unordered_set>
45#include < vector>
56#include " cluster_legalizer.h"
67#include " pack_types.h"
@@ -63,18 +64,9 @@ struct t_molecule_stats {
6364 int num_used_ext_outputs = 0 ; // Number of *used external* output pins across all primitives in molecule
6465};
6566
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-
7467/* Useful data structures for creating or modifying clusters */
7568struct t_clustering_data {
76- int * hill_climbing_inputs_avail;
77-
69+ int unclustered_list_head_size = 0 ;
7870 /* Keeps a linked list of the unclustered blocks to speed up looking for *
7971 * unclustered blocks with a certain number of *external* inputs. *
8072 * [0..lut_size]. Unclustered_list_head[i] points to the head of the *
@@ -83,16 +75,6 @@ struct t_clustering_data {
8375
8476 // Maintaining a linked list of free molecule data for speed
8577 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;
9678};
9779
9880/* **********************************/
@@ -112,8 +94,7 @@ void calc_init_packing_timing(const t_packer_opts& packer_opts,
11294/*
11395 * @brief Free the clustering data structures.
11496 */
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);
11798
11899/*
119100 * @brief Check clustering legality and output it.
@@ -154,8 +135,6 @@ void remove_molecule_from_pb_stats_candidates(t_pack_molecule* molecule,
154135void alloc_and_init_clustering (const t_molecule_stats& max_molecule_stats,
155136 const Prepacker& prepacker,
156137 t_clustering_data& clustering_data,
157- std::unordered_map<AtomNetId, int >& net_output_feeds_driving_block_input,
158- int & unclustered_list_head_size,
159138 int num_molecules);
160139
161140/*
@@ -195,8 +174,7 @@ void print_pack_status_header();
195174/*
196175 * @brief Incrementally print progress updates during clustering.
197176 */
198- void print_pack_status (int num_clb,
199- int tot_num_molecules,
177+ void print_pack_status (int tot_num_molecules,
200178 int num_molecules_processed,
201179 int & mols_since_last_print,
202180 int device_width,
@@ -212,42 +190,6 @@ void print_pack_status(int num_clb,
212190void rebuild_attraction_groups (AttractionInfo& attraction_groups,
213191 const ClusterLegalizer& cluster_legalizer);
214192
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-
251193void update_connection_gain_values (const AtomNetId net_id,
252194 const AtomBlockId clustered_blk_id,
253195 t_pb* cur_pb,
@@ -260,7 +202,7 @@ void update_timing_gain_values(const AtomNetId net_id,
260202 enum e_net_relation_to_clustered_block net_relation_to_clustered_block,
261203 const SetupTimingInfo& timing_info,
262204 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);
264206
265207/*
266208 * @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,
281223 const SetupTimingInfo& timing_info,
282224 const std::unordered_set<AtomNetId>& is_global,
283225 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);
285227
286228/*
287229 * @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,
309251 const int high_fanout_net_threshold,
310252 const SetupTimingInfo& timing_info,
311253 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);
330255
331256/*
332257 * @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,
351276 bool prioritize_transitive_connectivity,
352277 int transitive_fanout_threshold,
353278 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);
355280
356281/*
357282 * @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,
392317 AttractionInfo& attraction_groups,
393318 const int feasible_block_array_size,
394319 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);
396321
397322/*
398323 * @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,
421346 int verbosity,
422347 t_molecule_link* unclustered_list_head,
423348 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);
425350
426351/*
427352 * @brief Calculates molecule statistics for a single molecule.
@@ -455,6 +380,12 @@ void load_transitive_fanout_candidates(LegalizationClusterId cluster_index,
455380
456381std::map<const t_model*, std::vector<t_logical_block_type_ptr>> identify_primitive_candidate_block_types ();
457382
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+
458389/* *
459390 * @brief This function update the pb_type_count data structure by incrementing
460391 * the number of used pb_types in the given packed cluster t_pb
@@ -465,7 +396,12 @@ size_t update_pb_type_count(const t_pb* pb, std::map<t_pb_type*, int>& pb_type_c
465396 * @brief This function updates the le_count data structure from the given
466397 * packed cluster.
467398 */
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,
400+ const t_logical_block_type_ptr logic_block_type,
401+ const t_pb_type* le_pb_type,
402+ int & num_logic_le,
403+ int & num_reg_le,
404+ int & num_logic_and_reg_le);
469405
470406void 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);
471407
@@ -478,7 +414,7 @@ void print_pb_type_count(const ClusteredNetlist& clb_nlist);
478414 * @brief This function identifies the logic block type which is defined by the
479415 * block type which has a lut primitive.
480416 */
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);
417+ 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);
482418
483419/*
484420 * @brief This function returns the pb_type that is similar to Logic Element (LE)
@@ -499,7 +435,10 @@ bool pb_used_for_blif_model(const t_pb* pb, const std::string& blif_model_name);
499435/*
500436 * @brief Print the LE count data strurture.
501437 */
502- void print_le_count (std::vector<int >& le_count, const t_pb_type* le_pb_type);
438+ void print_le_count (int num_logic_le,
439+ int num_reg_le,
440+ int num_logic_and_reg_le,
441+ const t_pb_type* le_pb_type);
503442
504443/*
505444 * @brief Given a pointer to a pb in a cluster, this routine returns a pointer
0 commit comments