Skip to content

Commit fc08053

Browse files
authored
Merge pull request #2898 from AlexandreSinger/feature-cluster-legalizer
[Pack] Cleaned Up Cluster Legalizer Constructor
2 parents a33fa95 + b33d1d0 commit fc08053

9 files changed

+35
-165
lines changed

vpr/src/analytical_place/analytical_placement_flow.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
100100
prepacker,
101101
vpr_setup,
102102
*device_ctx.arch,
103-
device_ctx.grid,
104-
device_ctx.logical_block_types);
103+
device_ctx.grid);
105104
full_legalizer->legalize(p_placement);
106105
}
107106

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,22 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
5454
const Prepacker& prepacker,
5555
t_vpr_setup& vpr_setup,
5656
const t_arch& arch,
57-
const DeviceGrid& device_grid,
58-
const std::vector<t_logical_block_type>& logical_block_types) {
57+
const DeviceGrid& device_grid) {
5958
switch (full_legalizer_type) {
6059
case e_ap_full_legalizer::Naive:
6160
return std::make_unique<NaiveFullLegalizer>(ap_netlist,
6261
atom_netlist,
6362
prepacker,
6463
vpr_setup,
6564
arch,
66-
device_grid,
67-
logical_block_types);
65+
device_grid);
6866
case e_ap_full_legalizer::APPack:
6967
return std::make_unique<APPack>(ap_netlist,
7068
atom_netlist,
7169
prepacker,
7270
vpr_setup,
7371
arch,
74-
device_grid,
75-
logical_block_types);
72+
device_grid);
7673
default:
7774
VPR_FATAL_ERROR(VPR_ERROR_AP,
7875
"Unrecognized full legalizer type");
@@ -285,15 +282,11 @@ void NaiveFullLegalizer::create_clusters(const PartialPlacement& p_placement) {
285282
t_pack_high_fanout_thresholds high_fanout_thresholds(vpr_setup_.PackerOpts.high_fanout_threshold);
286283
ClusterLegalizer cluster_legalizer(atom_netlist_,
287284
prepacker_,
288-
logical_block_types_,
289285
vpr_setup_.PackerRRGraph,
290-
arch_.models,
291-
arch_.model_library,
292286
vpr_setup_.PackerOpts.target_external_pin_util,
293287
high_fanout_thresholds,
294288
ClusterLegalizationStrategy::FULL,
295289
vpr_setup_.PackerOpts.enable_pin_feasibility_filter,
296-
vpr_setup_.PackerOpts.feasible_block_array_size,
297290
vpr_setup_.PackerOpts.pack_verbosity);
298291
// Create clusters for each tile.
299292
// Start by giving each root tile a unique ID.
@@ -522,8 +515,6 @@ void APPack::legalize(const PartialPlacement& p_placement) {
522515
&vpr_setup_.AnalysisOpts,
523516
arch_,
524517
vpr_setup_.RoutingArch,
525-
vpr_setup_.user_models,
526-
vpr_setup_.library_models,
527518
vpr_setup_.PackerRRGraph,
528519
flat_placement_info);
529520

vpr/src/analytical_place/full_legalizer.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#pragma once
1111

1212
#include <memory>
13-
#include <vector>
1413
#include "ap_flow_enums.h"
1514

1615
// Forward declarations
@@ -22,7 +21,6 @@ class PartialPlacement;
2221
class PlaceMacros;
2322
class Prepacker;
2423
struct t_arch;
25-
struct t_logical_block_type;
2624
struct t_vpr_setup;
2725

2826
/**
@@ -41,15 +39,13 @@ class FullLegalizer {
4139
const Prepacker& prepacker,
4240
t_vpr_setup& vpr_setup,
4341
const t_arch& arch,
44-
const DeviceGrid& device_grid,
45-
const std::vector<t_logical_block_type>& logical_block_types)
42+
const DeviceGrid& device_grid)
4643
: ap_netlist_(ap_netlist),
4744
atom_netlist_(atom_netlist),
4845
prepacker_(prepacker),
4946
vpr_setup_(vpr_setup),
5047
arch_(arch),
51-
device_grid_(device_grid),
52-
logical_block_types_(logical_block_types) {}
48+
device_grid_(device_grid) {}
5349

5450
/**
5551
* @brief Perform legalization on the given partial placement solution
@@ -79,9 +75,6 @@ class FullLegalizer {
7975

8076
/// @brief The device grid which records where clusters can be placed.
8177
const DeviceGrid& device_grid_;
82-
83-
/// @brief A list of the logical block types in the architecture.
84-
const std::vector<t_logical_block_type>& logical_block_types_;
8578
};
8679

8780
std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_legalizer_type,
@@ -90,8 +83,7 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
9083
const Prepacker& prepacker,
9184
t_vpr_setup& vpr_setup,
9285
const t_arch& arch,
93-
const DeviceGrid& device_grid,
94-
const std::vector<t_logical_block_type>& logical_block_types);
86+
const DeviceGrid& device_grid);
9587

9688
/**
9789
* @brief The Naive Full Legalizer.

vpr/src/base/vpr_api.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
648648

649649
return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
650650
arch, vpr_setup.RoutingArch,
651-
vpr_setup.user_models,
652-
vpr_setup.library_models,
653651
vpr_setup.PackerRRGraph, g_vpr_ctx.atom().flat_placement_info);
654652
}
655653

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ constexpr bool VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR = true;
9393
constexpr bool VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR = false;
9494
#endif
9595

96-
#define MAX_SHORT 32767
97-
9896
/* Values large enough to be way out of range for any data, but small enough
9997
* to allow a small number to be added to them without going out of range. */
10098
#define HUGE_POSITIVE_FLOAT 1.e30

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,6 @@
3838
#include "vtr_vector.h"
3939
#include "vtr_vector_map.h"
4040

41-
/**
42-
* @brief Counts the total number of logic models that the architecture can
43-
* implement.
44-
*
45-
* @param user_models A linked list of logic models.
46-
* @return The total number of models in the linked list
47-
*/
48-
static size_t count_models(const t_model* user_models) {
49-
if (user_models == nullptr)
50-
return 0;
51-
52-
size_t n_models = 0;
53-
const t_model* cur_model = user_models;
54-
while (cur_model != nullptr) {
55-
n_models++;
56-
cur_model = cur_model->next;
57-
}
58-
59-
return n_models;
60-
}
61-
62-
/*
63-
* @brief Gets the max cluster size that any logical block can have.
64-
*
65-
* This is the maximum number of primitives any cluster can contain.
66-
*/
67-
static size_t calc_max_cluster_size(const std::vector<t_logical_block_type>& logical_block_types) {
68-
size_t max_cluster_size = 0;
69-
for (const t_logical_block_type& blk_type : logical_block_types) {
70-
if (is_empty_type(&blk_type))
71-
continue;
72-
int cur_cluster_size = get_max_primitives_in_pb_type(blk_type.pb_type);
73-
max_cluster_size = std::max<int>(max_cluster_size, cur_cluster_size);
74-
}
75-
return max_cluster_size;
76-
}
77-
7841
/*
7942
* @brief Allocates the stats stored within the pb of a cluster.
8043
*
@@ -471,15 +434,11 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
471434
const AtomBlockId blk_id,
472435
t_pb* cb,
473436
t_pb** parent,
474-
const int max_models,
475-
const int max_cluster_size,
476437
const LegalizationClusterId cluster_id,
477438
vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster,
478-
const t_intra_cluster_placement_stats* cluster_placement_stats_ptr,
479439
const PackMoleculeId molecule_id,
480440
t_lb_router_data* router_data,
481441
int verbosity,
482-
const int feasible_block_array_size,
483442
const Prepacker& prepacker,
484443
const vtr::vector_map<MoleculeChainId, t_clustering_chain_info>& clustering_chain_info) {
485444
const AtomContext& atom_ctx = g_vpr_ctx.atom();
@@ -493,10 +452,10 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
493452
if (pb_graph_node->parent_pb_graph_node != cb->pb_graph_node) {
494453
t_pb* my_parent = nullptr;
495454
block_pack_status = try_place_atom_block_rec(pb_graph_node->parent_pb_graph_node, blk_id, cb,
496-
&my_parent, max_models, max_cluster_size, cluster_id,
455+
&my_parent, cluster_id,
497456
atom_cluster,
498-
cluster_placement_stats_ptr, molecule_id, router_data,
499-
verbosity, feasible_block_array_size,
457+
molecule_id, router_data,
458+
verbosity,
500459
prepacker, clustering_chain_info);
501460
parent_pb = my_parent;
502461
} else {
@@ -1272,15 +1231,11 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(PackMoleculeId molecule_
12721231
atom_blk_id,
12731232
cluster.pb,
12741233
&parent,
1275-
num_models_,
1276-
max_cluster_size_,
12771234
cluster_id,
12781235
atom_cluster_,
1279-
cluster.placement_stats,
12801236
molecule_id,
12811237
cluster.router_data,
12821238
log_verbosity_,
1283-
feasible_block_array_size_,
12841239
prepacker_,
12851240
clustering_chain_info_);
12861241
}
@@ -1644,15 +1599,11 @@ bool ClusterLegalizer::check_cluster_legality(LegalizationClusterId cluster_id)
16441599

16451600
ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
16461601
const Prepacker& prepacker,
1647-
const std::vector<t_logical_block_type>& logical_block_types,
16481602
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
1649-
const t_model* user_models,
1650-
const t_model* library_models,
16511603
const std::vector<std::string>& target_external_pin_util_str,
16521604
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
16531605
ClusterLegalizationStrategy cluster_legalization_strategy,
16541606
bool enable_pin_feasibility_filter,
1655-
int feasible_block_array_size,
16561607
int log_verbosity) : prepacker_(prepacker) {
16571608
// Verify that the inputs are valid.
16581609
VTR_ASSERT_SAFE(lb_type_rr_graphs != nullptr);
@@ -1669,14 +1620,8 @@ ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
16691620
clustering_chain_info_.resize(prepacker_.get_num_molecule_chains());
16701621
// Pre-compute the max size of any molecule.
16711622
max_molecule_size_ = prepacker.get_max_molecule_size();
1672-
// Calculate the max cluster size
1673-
// - Limit maximum number of elements for each cluster to MAX_SHORT
1674-
max_cluster_size_ = calc_max_cluster_size(logical_block_types);
1675-
VTR_ASSERT(max_cluster_size_ < MAX_SHORT);
16761623
// Get a reference to the rr graphs.
16771624
lb_type_rr_graphs_ = lb_type_rr_graphs;
1678-
// Get the number of models in the architecture.
1679-
num_models_ = count_models(user_models) + count_models(library_models);
16801625
// Find all NoC router atoms.
16811626
std::vector<AtomBlockId> noc_atoms = find_noc_router_atoms(atom_netlist);
16821627
update_noc_reachability_partitions(noc_atoms,
@@ -1686,7 +1631,6 @@ ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
16861631
// Copy the options passed by the user
16871632
cluster_legalization_strategy_ = cluster_legalization_strategy;
16881633
enable_pin_feasibility_filter_ = enable_pin_feasibility_filter;
1689-
feasible_block_array_size_ = feasible_block_array_size;
16901634
log_verbosity_ = log_verbosity;
16911635
}
16921636

0 commit comments

Comments
 (0)