Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ba88f64

Browse files
committedSep 16, 2024·
[ClusterLegalizer] Updated Based on PR Comments
Added more documentation. Cleaned up one set which should have been a vector.
1 parent 229a804 commit ba88f64

File tree

8 files changed

+369
-190
lines changed

8 files changed

+369
-190
lines changed
 

‎vpr/src/base/vpr_api.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <cstring>
1616
#include <cmath>
1717

18+
#include "cluster_util.h"
1819
#include "vpr_context.h"
1920
#include "vtr_assert.h"
2021
#include "vtr_math.h"
@@ -616,7 +617,7 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
616617

617618
}
618619

619-
// Load cluster_constraints data structure here since loading pack file
620+
// Load cluster_constraints data structure.
620621
load_cluster_constraints();
621622

622623
/* Sanity check the resulting netlist */
@@ -708,11 +709,7 @@ void vpr_load_packing(t_vpr_setup& vpr_setup, const t_arch& arch) {
708709
vpr_setup.PackerOpts.pack_verbosity);
709710

710711
/* Load the mapping between clusters and their atoms */
711-
cluster_ctx.atoms_lookup.resize(cluster_ctx.clb_nlist.blocks().size());
712-
for (AtomBlockId atom_blk_id : atom_ctx.nlist.blocks()) {
713-
ClusterBlockId atom_cluster_blk_id = atom_ctx.lookup.atom_clb(atom_blk_id);
714-
cluster_ctx.atoms_lookup[atom_cluster_blk_id].insert(atom_blk_id);
715-
}
712+
init_clb_atoms_lookup(cluster_ctx.atoms_lookup, atom_ctx, cluster_ctx.clb_nlist);
716713

717714
process_constant_nets(g_vpr_ctx.mutable_atom().nlist,
718715
atom_ctx.lookup,

‎vpr/src/pack/cluster_legalizer.cpp

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @date September 2024
55
* @brief The implementation of the Cluster Legalizer class.
66
*
7-
* Most of the code in this file was original part of cluster_util.cpp and was
7+
* Most of the code in this file was originally part of cluster_util.cpp and was
88
* highly integrated with the clusterer in VPR. All code that was used for
99
* legalizing the clusters was moved into this file and all the functionality
1010
* was moved into the ClusterLegalizer class.
@@ -40,6 +40,8 @@
4040

4141
/*
4242
* @brief Gets the max cluster size that any logical block can have.
43+
*
44+
* This is the maximum number of primitives any cluster can contain.
4345
*/
4446
static size_t calc_max_cluster_size(const std::vector<t_logical_block_type>& logical_block_types) {
4547
size_t max_cluster_size = 0;
@@ -63,11 +65,6 @@ static void alloc_and_load_pb_stats(t_pb* pb, const int feasible_block_array_siz
6365

6466
pb->pb_stats = new t_pb_stats;
6567

66-
/* If statement below is for speed. If nets are reasonably low-fanout, *
67-
* only a relatively small number of blocks will be marked, and updating *
68-
* only those atom block structures will be fastest. If almost all blocks *
69-
* have been touched it should be faster to just run through them all *
70-
* in order (less addressing and better cache locality). */
7168
pb->pb_stats->input_pins_used = std::vector<std::unordered_map<size_t, AtomNetId>>(pb->pb_graph_node->num_input_pin_class);
7269
pb->pb_stats->output_pins_used = std::vector<std::unordered_map<size_t, AtomNetId>>(pb->pb_graph_node->num_output_pin_class);
7370
pb->pb_stats->lookahead_input_pins_used = std::vector<std::vector<AtomNetId>>(pb->pb_graph_node->num_input_pin_class);
@@ -304,10 +301,10 @@ static bool check_cluster_noc_group(AtomBlockId atom_blk_id,
304301
}
305302

306303
/**
307-
* This function takes the root block of a chain molecule and a proposed
308-
* placement primitive for this block. The function then checks if this
309-
* chain root block has a placement constraint (such as being driven from
310-
* outside the cluster) and returns the status of the placement accordingly.
304+
* @brief This function takes the root block of a chain molecule and a proposed
305+
* placement primitive for this block. The function then checks if this
306+
* chain root block has a placement constraint (such as being driven from
307+
* outside the cluster) and returns the status of the placement accordingly.
311308
*/
312309
static enum e_block_pack_status check_chain_root_placement_feasibility(const t_pb_graph_node* pb_graph_node,
313310
const t_pack_molecule* molecule,
@@ -368,7 +365,7 @@ static enum e_block_pack_status check_chain_root_placement_feasibility(const t_p
368365

369366
/*
370367
* @brief Check that the two atom blocks blk_id and sibling_blk_id (which should
371-
* both be memory slices) are feasible, in the sence that they have
368+
* both be memory slices) are feasible, in the sense that they have
372369
* precicely the same net connections (with the exception of nets in data
373370
* port classes).
374371
*
@@ -480,7 +477,7 @@ static bool primitive_feasible(const AtomBlockId blk_id, t_pb* cur_pb) {
480477
}
481478

482479
/**
483-
* Try place atom block into current primitive location
480+
* @brief Try to place atom block into current primitive location
484481
*/
485482
static enum e_block_pack_status
486483
try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
@@ -613,7 +610,10 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
613610
return block_pack_status;
614611
}
615612

616-
/* Resets nets used at different pin classes for determining pin feasibility */
613+
/*
614+
* @brief Resets nets used at different pin classes for determining pin
615+
* feasibility.
616+
*/
617617
static void reset_lookahead_pins_used(t_pb* cur_pb) {
618618
const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type;
619619
if (cur_pb->pb_stats == nullptr) {
@@ -674,7 +674,7 @@ static int net_sinks_reachable_in_cluster(const t_pb_graph_pin* driver_pb_gpin,
674674
}
675675

676676
/**
677-
* Returns the pb_graph_pin of the atom pin defined by the driver_pin_id in the driver_pb
677+
* @brief Returns the pb_graph_pin of the atom pin defined by the driver_pin_id in the driver_pb
678678
*/
679679
static t_pb_graph_pin* get_driver_pb_graph_pin(const t_pb* driver_pb, const AtomPinId driver_pin_id) {
680680
const AtomContext& atom_ctx = g_vpr_ctx.atom();
@@ -701,12 +701,12 @@ static t_pb_graph_pin* get_driver_pb_graph_pin(const t_pb* driver_pb, const Atom
701701
}
702702

703703
/**
704-
* Given a pin and its assigned net, mark all pin classes that are affected.
705-
* Check if connecting this pin to it's driver pin or to all sink pins will
706-
* require leaving a pb_block starting from the parent pb_block of the
707-
* primitive till the root block (depth = 0). If leaving a pb_block is
708-
* required add this net to the pin class (to increment the number of used
709-
* pins from this class) that should be used to leave the pb_block.
704+
* @brief Given a pin and its assigned net, mark all pin classes that are affected.
705+
* Check if connecting this pin to it's driver pin or to all sink pins will
706+
* require leaving a pb_block starting from the parent pb_block of the
707+
* primitive till the root block (depth = 0). If leaving a pb_block is
708+
* required add this net to the pin class (to increment the number of used
709+
* pins from this class) that should be used to leave the pb_block.
710710
*/
711711
static void compute_and_mark_lookahead_pins_used_for_pin(const t_pb_graph_pin* pb_graph_pin,
712712
const t_pb* primitive_pb,
@@ -834,7 +834,9 @@ static void compute_and_mark_lookahead_pins_used_for_pin(const t_pb_graph_pin* p
834834
}
835835

836836

837-
/* Determine if pins of speculatively packed pb are legal */
837+
/*
838+
* @brief Determine if pins of speculatively packed pb are legal
839+
*/
838840
static void compute_and_mark_lookahead_pins_used(const AtomBlockId blk_id,
839841
const vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster) {
840842
const AtomContext& atom_ctx = g_vpr_ctx.atom();
@@ -851,7 +853,9 @@ static void compute_and_mark_lookahead_pins_used(const AtomBlockId blk_id,
851853
}
852854
}
853855

854-
/* Determine if speculatively packed cur_pb is pin feasible
856+
/*
857+
* @brief Determine if speculatively packed cur_pb is pin feasible
858+
*
855859
* Runtime is actually not that bad for this. It's worst case O(k^2) where k is the
856860
* number of pb_graph pins. Can use hash tables or make incremental if becomes an issue.
857861
*/
@@ -881,7 +885,10 @@ static void try_update_lookahead_pins_used(t_pb* cur_pb,
881885
}
882886
}
883887

884-
/* Check if the number of available inputs/outputs for a pin class is sufficient for speculatively packed blocks */
888+
/*
889+
* @brief Check if the number of available inputs/outputs for a pin class is
890+
* sufficient for speculatively packed blocks.
891+
*/
885892
static bool check_lookahead_pins_used(t_pb* cur_pb, t_ext_pin_util max_external_pin_util) {
886893
const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type;
887894

@@ -943,11 +950,11 @@ static bool check_lookahead_pins_used(t_pb* cur_pb, t_ext_pin_util max_external_
943950
}
944951

945952
/**
946-
* This function takes a chain molecule, and the pb_graph_node that is chosen
947-
* for packing the molecule's root block. Using the given root_primitive, this
948-
* function will identify which chain id this molecule is being mapped to and
949-
* will update the chain id value inside the chain info data structure of this
950-
* molecule
953+
* @brief This function takes a chain molecule, and the pb_graph_node that is
954+
* chosen for packing the molecule's root block. Using the given
955+
* root_primitive, this function will identify which chain id this
956+
* molecule is being mapped to and will update the chain id value inside
957+
* the chain info data structure of this molecule.
951958
*/
952959
static void update_molecule_chain_info(t_pack_molecule* chain_molecule, const t_pb_graph_node* root_primitive) {
953960
VTR_ASSERT(chain_molecule->chain_info->chain_id == -1 && chain_molecule->chain_info->is_long_chain);
@@ -969,7 +976,8 @@ static void update_molecule_chain_info(t_pack_molecule* chain_molecule, const t_
969976
VTR_ASSERT(false);
970977
}
971978

972-
/* Revert trial atom block iblock and free up memory space accordingly
979+
/*
980+
* @brief Revert trial atom block iblock and free up memory space accordingly.
973981
*/
974982
static void revert_place_atom_block(const AtomBlockId blk_id,
975983
t_lb_router_data* router_data,
@@ -1021,7 +1029,9 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
10211029
mutable_atom_ctx.lookup.set_atom_pb(blk_id, nullptr);
10221030
}
10231031

1024-
/* Speculation successful, commit input/output pins used */
1032+
/*
1033+
* @brief Speculation successful, commit input/output pins used.
1034+
*/
10251035
static void commit_lookahead_pins_used(t_pb* cur_pb) {
10261036
const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type;
10271037

@@ -1055,7 +1065,7 @@ static void commit_lookahead_pins_used(t_pb* cur_pb) {
10551065
}
10561066

10571067
/**
1058-
* Cleans up a pb after unsuccessful molecule packing
1068+
* @brief Cleans up a pb after unsuccessful molecule packing
10591069
*
10601070
* Recursively frees pbs from a t_pb tree. The given root pb itself is not
10611071
* deleted.
@@ -1135,7 +1145,7 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
11351145
VTR_ASSERT_DEBUG(cluster.pb != nullptr);
11361146
VTR_ASSERT_DEBUG(cluster.type != nullptr);
11371147

1138-
// TODO: Remove these global accesses.
1148+
// TODO: Remove these global accesses to the contexts.
11391149
// AtomContext used for:
11401150
// - printing verbose statements
11411151
// - Looking up the primitive pb
@@ -1349,7 +1359,7 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
13491359
cluster.noc_grp_id = new_cluster_noc_grp_id;
13501360

13511361
// Insert the molecule into the cluster for bookkeeping.
1352-
cluster.molecules.insert(molecule);
1362+
cluster.molecules.push_back(molecule);
13531363

13541364
for (int i = 0; i < molecule_size; i++) {
13551365
AtomBlockId atom_blk_id = molecule->atom_block_ids[i];
@@ -1653,10 +1663,13 @@ ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
16531663
feasible_block_array_size_ = feasible_block_array_size;
16541664
log_verbosity_ = log_verbosity;
16551665
// Get the target external pin utilization
1656-
// NOTE: This is really silly, but this can potentially fail. If it does
1657-
// it is important that everything is allocated. If not, when it fails
1658-
// it will call the reset method when only parts of the class are
1659-
// allocated which may cause havoc...
1666+
// NOTE: This has to be initialized last due to the fact that VPR_FATA_ERROR
1667+
// may be called within the constructor of t_ext_pin_util_targets. If
1668+
// this occurs, an excpetion is thrown which will drain the stack. If
1669+
// the cluster legalizer object is stored on the stack, this can call
1670+
// the destructor prematurely (before certain structures are allocated).
1671+
// Therefore, this is created at the end, when the class is in a state
1672+
// where it can be destroyed.
16601673
target_external_pin_util_ = t_ext_pin_util_targets(target_external_pin_util_str);
16611674
}
16621675

‎vpr/src/pack/cluster_legalizer.h

Lines changed: 100 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
/**
2+
* @file
3+
* @author Alex Singer
4+
* @date September 2024
5+
* @brief The declaration of the Cluster Legalizer class.
6+
*
7+
* This file declares a class called the ClusterLegalizer which encapsulates all
8+
* logic for creating legal clusters from prepacked molecules. This class is
9+
* designed to be self-contained to the point that it is able to be called
10+
* externally to the Packer in VPR.
11+
*/
12+
113
#pragma once
214

3-
#include <set>
415
#include <unordered_map>
16+
#include <vector>
517
#include "atom_netlist_fwd.h"
618
#include "noc_data_types.h"
719
#include "partition_region.h"
@@ -49,12 +61,15 @@ struct LegalizationCluster {
4961
/// @brief A list of the molecules in the cluster. By design, a cluster will
5062
/// only contain molecules which have been previously legalized into
5163
/// the cluster using a legalization strategy.
52-
std::set<t_pack_molecule*> molecules;
64+
std::vector<t_pack_molecule*> molecules;
5365

5466
/// @brief The logical block of this cluster.
5567
/// TODO: We should be more careful with how this is allocated. Instead of
5668
/// pointers, we really should use IDs and store them in a standard
57-
/// container.
69+
/// container. Currently this is being allocated with the new keyword
70+
/// and freed when the cluster is destroyed; however this is used
71+
/// externally to the class and it can be dangerous to pass around
72+
/// a pointer to this object.
5873
t_pb* pb;
5974

6075
/// @brief The logical block type this cluster represents.
@@ -79,7 +94,7 @@ struct LegalizationCluster {
7994
};
8095

8196
/*
82-
* @brief A manager class which manages the legalization of cluster. As clusters
97+
* @brief A manager class which manages the legalization of clusters. As clusters
8398
* are created, this class will legalize for each molecule added. It also
8499
* provides methods which are helpful for clustering.
85100
*
@@ -99,13 +114,15 @@ struct LegalizationCluster {
99114
* look something like this. Note, this example is simplified and the result
100115
* of the packings should be checked and handled.
101116
*
102-
* ClusterLegalizer legalizer(...);
117+
* ClusterLegalizer legalizer(...,
118+
* ClusterLegalizationStrategy::SKIP_INTRA_LB_ROUTE,
119+
* ...);
103120
*
104121
* std::tie(status, new_cluster_id) = legalizer.start_new_cluster(seed_mol,
105122
* cluster_type,
106123
* mode);
107124
* for mol in molecules_to_add:
108-
* // Cheaper additions, but may pack a molecule that wouldnt route.
125+
* // Cheaper additions, but may pack a molecule that wouldn't route.
109126
* status = legalizer.add_mol_to_cluster(mol, new_cluster_id);
110127
* if (status != e_block_pack_status::BLK_PASSED)
111128
* break;
@@ -114,16 +131,20 @@ struct LegalizationCluster {
114131
* if (!legalizer.check_cluster_legality(new_cluster_id))
115132
* // Destroy the illegal cluster.
116133
* legalizer.destroy_cluster(new_cluster_id);
134+
* // Clean-up the internal bookeeping of the class (required after
135+
* // destroying a cluster).
117136
* legalizer.compress();
118137
* // Handle how to try again (maybe use FULL strategy).
119138
*
120139
* 2) FULL Legalization Strategy Example:
121140
* This strategy will fully route the internal connections of the clusters for
122141
* each molecule added. This is much more expensive to run; however, will ensure
123142
* that the cluster is fully legalized while it is being created. An example
124-
* of how to sue this strategy would look something like this:
143+
* of how to use this strategy would look something like this:
125144
*
126-
* Clusterlegalizer legalizer(...);
145+
* Clusterlegalizer legalizer(...,
146+
* ClusterLegalizationStrategy::FULL,
147+
* ...);
127148
*
128149
* std::tie(pack_result, new_cluster_id) = legalizer.start_new_cluster(seed_mol,
129150
* cluster_type,
@@ -174,6 +195,46 @@ class ClusterLegalizer {
174195
* @brief Initialize the ClusterLegalizer class.
175196
*
176197
* Allocates internal state.
198+
*
199+
* @param atom_netlist The complete atom netlist. Used to allocate
200+
* internal structures to the correct size.
201+
* @param prepacker The prepacker object used to prepack the atoms
202+
* into molecules. A reference to this object is
203+
* stored internally to be used to lookup the
204+
* molecules of atoms.
205+
* @param logical_block_types Used to allocate internal objects. Used to
206+
* get the max number of primitives in any block
207+
* type.
208+
* @param lb_type_rr_graphs The routing resource graph internal to the
209+
* different cluster types. A reference is stored
210+
* in the class to be used to allocate and load
211+
* the router data.
212+
* @param num_models The total number of models in the architecture.
213+
* This is the sum of the number of the user and
214+
* library models. Used internally to allocate data
215+
* structures.
216+
* @param target_external_pin_util_str A string used to initialize the
217+
* target external pin utilization of
218+
* each cluster type.
219+
* @param high_fanout_thresholds An object that stores the thresholds for
220+
* a net to be considered high fanout for
221+
* different block types.
222+
* @param cluster_legalization_strategy The legalization strategy to be
223+
* used when creating clusters and
224+
* adding molecules to clusters.
225+
* Controls the checks that are performed.
226+
* @param enable_pin_feasibility_filter A flag to turn on/off the check for
227+
* pin usage feasibility.
228+
* @param feasible_block_array_size The largest number of feasible blocks
229+
* that can be stored in a cluster. Used
230+
* to allocate an internal structure.
231+
* @param log_verbosity Controls how verbose the log messages will
232+
* be within this class.
233+
*
234+
* TODO: A lot of these arguments are only used to allocate C-style arrays
235+
* since the original author was avoiding dynamic allocations. It may
236+
* be more space efficient (and cleaner) to make these dynamic arrays
237+
* and not pass these arguments in.
177238
*/
178239
ClusterLegalizer(const AtomNetlist& atom_netlist,
179240
const Prepacker& prepacker,
@@ -211,7 +272,12 @@ class ClusterLegalizer {
211272
/*
212273
* @brief Add an unclustered molecule to the given legalization cluster.
213274
*
214-
* If the addition was unsuccessful, the molecule will remain unclustered.
275+
* The ClusterLegalizationStrategy (set either in the constructor or by the
276+
* set_cluster_legalization_strategy method) decides what checks are
277+
* performed when adding a molecule to the cluster.
278+
*
279+
* If the addition was unsuccessful (i.e. a check fails), the molecule will
280+
* remain unclustered.
215281
*
216282
* @param molecule The molecule to add to the cluster.
217283
* @param cluster_id The ID of the cluster to add the molecule to.
@@ -234,8 +300,8 @@ class ClusterLegalizer {
234300
void destroy_cluster(LegalizationClusterId cluster_id);
235301

236302
/*
237-
* @brief Compress the internal storage of clusters. Should be called after
238-
* a cluster is destroyed.
303+
* @brief Compress the internal storage of clusters. Should be called
304+
* eventually after one or more clusters are destroyed.
239305
*
240306
* Similar to the Netlist compress method. Will invalidate all Legalization
241307
* Cluster IDs.
@@ -246,7 +312,7 @@ class ClusterLegalizer {
246312
void compress();
247313

248314
/*
249-
* @brief A list of all cluster IDs in the legalizer.
315+
* @brief A range of all cluster IDs in the legalizer.
250316
*
251317
* If the legalizer has been compressed (or no clusters have been destroyed)
252318
* then all cluster IDs in this list will be valid and represent a non-empty
@@ -288,14 +354,15 @@ class ClusterLegalizer {
288354
void clean_cluster(LegalizationClusterId cluster_id);
289355

290356
/*
291-
* @brief Verify that all atoms have been clustered into a cluster.
357+
* @brief Verify that all atoms have been clustered into some cluster.
292358
*
293359
* This will not verify if all the clusters are fully legal.
294360
*/
295361
void verify();
296362

297363
/*
298-
* @brief Finalize the clustering.
364+
* @brief Finalize the clustering. Required for generating a Clustered
365+
* Netlist.
299366
*
300367
* Before generating a Clustered Netlist, each cluster needs to allocate and
301368
* load a pb_route. This method will generate a pb_route for each cluster
@@ -339,6 +406,14 @@ class ClusterLegalizer {
339406
}
340407

341408
/// @brief Gets the cluster placement stats of the given cluster.
409+
///
410+
/// The cluster placement stats are statistics used to monitor which atoms
411+
/// have been physically clustered into the pb (more specifically what site
412+
/// they will go). This can be used externally to the legalizer to detect
413+
/// if an atom could physically go into a cluster (exists_free_primitive_for_atom_block).
414+
///
415+
/// TODO: Releasing the whole stats can be dangerous. Ideally there should
416+
/// just be a method to see if an atom could physically go in a cluster.
342417
inline t_cluster_placement_stats* get_cluster_placement_stats(LegalizationClusterId cluster_id) const {
343418
VTR_ASSERT_SAFE(cluster_id.is_valid() && (size_t)cluster_id < legalization_clusters_.size());
344419
return &(cluster_placement_stats_[get_cluster_type(cluster_id)->index]);
@@ -358,6 +433,9 @@ class ClusterLegalizer {
358433
}
359434

360435
/// @bried Gets the max size a cluster could physically be.
436+
///
437+
/// This is the maximum number of primitives any cluster could ever have
438+
/// in the architecture.
361439
inline size_t get_max_cluster_size() const {
362440
return max_cluster_size_;
363441
}
@@ -411,7 +489,10 @@ class ClusterLegalizer {
411489

412490
/// @brief Stores the NoC group ID of each atom block. Atom blocks that
413491
/// belong to different NoC groups can't be clustered with each other
414-
/// into the same clustered block.
492+
/// into the same clustered block. Under some optimization settings
493+
/// to improve placement locality / NoC usage. Atoms with different
494+
/// NoC group IDs belong to logic that is disjoint except through
495+
/// NoC traffic.
415496
vtr::vector<AtomBlockId, NocGroupId> atom_noc_grp_id_;
416497

417498
/// @brief Stats keeper for placement information during packing/clustering.
@@ -422,17 +503,17 @@ class ClusterLegalizer {
422503
/// should stored per cluster.
423504
t_cluster_placement_stats* cluster_placement_stats_ = nullptr;
424505

425-
/// @brief The utilization of external input/output pins during packing
426-
/// (between 0 and 1).
506+
/// @brief The maximum fractional utilization of cluster external
507+
/// input/output pins during packing (between 0 and 1).
427508
t_ext_pin_util_targets target_external_pin_util_;
428509

429510
/// @brief The max size of any molecule. This is used to allocate a dynamic
430511
/// array within the legalizer, and in its current form this is a bit
431512
/// expensive to calculate from the prepacker.
432513
size_t max_molecule_size_;
433514

434-
/// @brief The max size a cluster could physically be. This is used to
435-
/// allocate dynamic arrays.
515+
/// @brief The max number of primitives a cluster could physically have.
516+
/// This is used to allocate dynamic arrays.
436517
size_t max_cluster_size_;
437518

438519
/// @brief A vector of routing resource nodes within each logical block type

‎vpr/src/pack/cluster_util.cpp

Lines changed: 13 additions & 123 deletions
Large diffs are not rendered by default.

‎vpr/src/pack/cluster_util.h

Lines changed: 188 additions & 5 deletions
Large diffs are not rendered by default.

‎vpr/src/pack/output_clustering.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
class AtomNetId;
88
class ClusterLegalizer;
99

10+
/// @brief Output the clustering, given by the ClusterLegalizer or a clustered
11+
/// netlist, to a clustered netlist file.
12+
///
13+
/// The clustering can be output from the following sources:
14+
/// 1) From the clustering
15+
/// 2) From another clustered netlist
16+
/// If from_legalizer is true, the ClusterLegalizer will be used to generate the
17+
/// clustered netlist. If from_legalizer is false, the clustered netlist currently
18+
/// in the global scope will be used.
1019
void output_clustering(ClusterLegalizer* cluster_legalizer_ptr,
1120
bool global_clocks,
1221
const std::unordered_set<AtomNetId>& is_clock,

‎vpr/src/pack/pack.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ bool try_pack(t_packer_opts* packer_opts,
200200
t_ext_pin_util pin_util(1.0, 1.0);
201201
// TODO: This line assumes the logic block name is "clb" which
202202
// may not be the case. This may need to be investigated.
203+
// Probably we should do this update of ext_pin_util for
204+
// all types that were overused. Or if that is hard, just
205+
// do it for all block types. Doing it only for a clb
206+
// string is dangerous -VB.
203207
cluster_legalizer.get_target_external_pin_util().set_block_pin_util("clb", pin_util);
204208
}
205209

‎vpr/src/util/vpr_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ int get_max_nets_in_pb_type(const t_pb_type* pb_type);
193193
bool primitive_type_feasible(AtomBlockId blk_id, const t_pb_type* cur_pb_type);
194194
t_pb_graph_pin* get_pb_graph_node_pin_from_model_port_pin(const t_model_ports* model_port, const int model_pin, const t_pb_graph_node* pb_graph_node);
195195
const t_pb_graph_pin* find_pb_graph_pin(const AtomNetlist& netlist, const AtomLookup& netlist_lookup, const AtomPinId pin_id);
196+
/// @brief Gets the pb_graph_node pin at the given pin index for the given
197+
/// pb_graph_node.
196198
t_pb_graph_pin* get_pb_graph_node_pin_from_pb_graph_node(t_pb_graph_node* pb_graph_node, int ipin);
197199
t_pb_graph_pin* get_pb_graph_node_pin_from_block_pin(ClusterBlockId iblock, int ipin);
198200
vtr::vector<ClusterBlockId, t_pb**> alloc_and_load_pin_id_to_pb_mapping();

0 commit comments

Comments
 (0)
Please sign in to comment.