Skip to content

Commit 4cea938

Browse files
[SQUASH ME] Moved Commit Lookahead Pins into legalizer and comments.
1 parent 06fdf2f commit 4cea938

File tree

4 files changed

+58
-51
lines changed

4 files changed

+58
-51
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <string>
1616
#include <tuple>
1717
#include <vector>
18+
#include "atom_lookup.h"
1819
#include "cluster_placement.h"
1920
#include "cluster_router.h"
2021
#include "globals.h"
@@ -971,6 +972,39 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
971972
atom_ctx.lookup.set_atom_pb(blk_id, nullptr);
972973
}
973974

975+
/* Speculation successful, commit input/output pins used */
976+
static void commit_lookahead_pins_used(t_pb* cur_pb) {
977+
const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type;
978+
979+
if (pb_type->num_modes > 0 && cur_pb->name) {
980+
for (int i = 0; i < cur_pb->pb_graph_node->num_input_pin_class; i++) {
981+
VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->input_pin_class_size[i]);
982+
for (size_t j = 0; j < cur_pb->pb_stats->lookahead_input_pins_used[i].size(); j++) {
983+
VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i][j]);
984+
cur_pb->pb_stats->input_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_input_pins_used[i][j]});
985+
}
986+
}
987+
988+
for (int i = 0; i < cur_pb->pb_graph_node->num_output_pin_class; i++) {
989+
VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->output_pin_class_size[i]);
990+
for (size_t j = 0; j < cur_pb->pb_stats->lookahead_output_pins_used[i].size(); j++) {
991+
VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i][j]);
992+
cur_pb->pb_stats->output_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_output_pins_used[i][j]});
993+
}
994+
}
995+
996+
if (cur_pb->child_pbs) {
997+
for (int i = 0; i < pb_type->modes[cur_pb->mode].num_pb_type_children; i++) {
998+
if (cur_pb->child_pbs[i]) {
999+
for (int j = 0; j < pb_type->modes[cur_pb->mode].pb_type_children[i].num_pb; j++) {
1000+
commit_lookahead_pins_used(&cur_pb->child_pbs[i][j]);
1001+
}
1002+
}
1003+
}
1004+
}
1005+
}
1006+
}
1007+
9741008
/**
9751009
* Cleans up a pb after unsuccessful molecule packing
9761010
*
@@ -1272,14 +1306,23 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
12721306
cluster.molecules.insert(molecule);
12731307

12741308
for (int i = 0; i < molecule_size; i++) {
1275-
if (molecule->atom_block_ids[i]) {
1276-
/* invalidate all molecules that share atom block with current molecule */
1277-
t_pack_molecule* cur_molecule = atom_ctx.prepacker.get_atom_molecule(molecule->atom_block_ids[i]);
1278-
cur_molecule->valid = false;
1279-
1280-
commit_primitive(cluster_placement_stats_ptr, primitives_list[i]);
1281-
}
1309+
AtomBlockId atom_blk_id = molecule->atom_block_ids[i];
1310+
if (!atom_blk_id.is_valid())
1311+
continue;
1312+
1313+
/* invalidate all molecules that share atom block with current molecule */
1314+
t_pack_molecule* cur_molecule = atom_ctx.prepacker.get_atom_molecule(atom_blk_id);
1315+
// TODO: This should really be named better. Something like
1316+
// "is_clustered". and then it should be set to true.
1317+
// Right now, valid implies "not clustered" which is
1318+
// confusing.
1319+
cur_molecule->valid = false;
1320+
1321+
commit_primitive(cluster_placement_stats_ptr, primitives_list[i]);
12821322
}
1323+
1324+
// Update the lookahead pins used.
1325+
commit_lookahead_pins_used(cluster.pb);
12831326
}
12841327
}
12851328

@@ -1521,6 +1564,8 @@ void ClusterLegalizer::reset() {
15211564
// Reset the molecule_cluster map
15221565
molecule_cluster.clear();
15231566
// Free and reset the legalization_clusters
1567+
// FIXME: It would make sense if this were to call the destroy method
1568+
// somehow.
15241569
for (LegalizationCluster& cluster : legalization_clusters) {
15251570
// FIXME: Handle destroyed clusters better.
15261571
if (cluster.pb == nullptr)

vpr/src/pack/cluster_legalizer.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ enum class e_block_pack_status {
4646
* @brief A struct containing information about the cluster.
4747
*
4848
* This contains necessary information for legalizing a cluster.
49-
*
50-
* FIXME: The "cluster_" prefix for the members is a bit unnecessary. remove.
5149
*/
5250
struct LegalizationCluster {
5351
/// @brief A list of the molecules in the cluster. By design, a cluster will
5452
/// only contain molecules which have been previously legalized into
5553
/// the cluster.
5654
std::set<t_pack_molecule*> molecules;
5755

58-
/// @brief The physical block this cluster represents.
56+
/// @brief The logical block of this cluster.
5957
/// FIXME: We should be more careful with how this is allocated. Instead of
6058
/// pointers, we really should use IDs and store them in a standard
6159
/// container.
@@ -66,17 +64,18 @@ struct LegalizationCluster {
6664

6765
/// @brief The partition region of legal positions this cluster can be placed.
6866
/// Used to detect if a molecule can physically be placed in a cluster.
67+
/// It is derived from the partition region constraints on the atoms
68+
/// in the cluster (not fundamental but good for performance).
6969
PartitionRegion pr;
7070

7171
/// @brief The NoC group that this cluster is a part of. Is used to check if
7272
/// a candidate primitive is in the same NoC group as the atom blocks
73-
/// that have already been added to the primitive.
73+
/// that have already been added to the primitive. This can be helpful
74+
/// for optimization.
7475
NocGroupId noc_grp_id;
7576

7677
/// @brief The router data of the intra lb router used for this cluster.
77-
// NOTE: This may not actually need to be kept per cluster... Not sure...
78-
// I think this is passed into the subroutines to prevent repetitive work
79-
// in the lb router; but I am not sure...
78+
/// TODO: Improve this description.
8079
t_lb_router_data* router_data;
8180
};
8281

vpr/src/pack/cluster_util.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,6 @@ void update_cluster_stats(const t_pack_molecule* molecule,
12841284

12851285
update_total_gain(alpha, beta, timing_driven, connection_driven,
12861286
atom_pb->parent_pb, attraction_groups);
1287-
1288-
commit_lookahead_pins_used(cb);
12891287
}
12901288

12911289
// if this molecule came from the transitive fanout candidates remove it
@@ -2070,39 +2068,6 @@ float get_molecule_gain(t_pack_molecule* molecule, std::map<AtomBlockId, float>&
20702068
return gain;
20712069
}
20722070

2073-
/* Speculation successful, commit input/output pins used */
2074-
void commit_lookahead_pins_used(t_pb* cur_pb) {
2075-
const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type;
2076-
2077-
if (pb_type->num_modes > 0 && cur_pb->name) {
2078-
for (int i = 0; i < cur_pb->pb_graph_node->num_input_pin_class; i++) {
2079-
VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->input_pin_class_size[i]);
2080-
for (size_t j = 0; j < cur_pb->pb_stats->lookahead_input_pins_used[i].size(); j++) {
2081-
VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i][j]);
2082-
cur_pb->pb_stats->input_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_input_pins_used[i][j]});
2083-
}
2084-
}
2085-
2086-
for (int i = 0; i < cur_pb->pb_graph_node->num_output_pin_class; i++) {
2087-
VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->output_pin_class_size[i]);
2088-
for (size_t j = 0; j < cur_pb->pb_stats->lookahead_output_pins_used[i].size(); j++) {
2089-
VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i][j]);
2090-
cur_pb->pb_stats->output_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_output_pins_used[i][j]});
2091-
}
2092-
}
2093-
2094-
if (cur_pb->child_pbs) {
2095-
for (int i = 0; i < pb_type->modes[cur_pb->mode].num_pb_type_children; i++) {
2096-
if (cur_pb->child_pbs[i]) {
2097-
for (int j = 0; j < pb_type->modes[cur_pb->mode].pb_type_children[i].num_pb; j++) {
2098-
commit_lookahead_pins_used(&cur_pb->child_pbs[i][j]);
2099-
}
2100-
}
2101-
}
2102-
}
2103-
}
2104-
}
2105-
21062071
/**
21072072
* Score unclustered atoms that are two hops away from current cluster
21082073
* For example, consider a cluster that has a FF feeding an adder in another

vpr/src/pack/cluster_util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ void alloc_and_init_clustering(const t_molecule_stats& max_molecule_stats,
143143

144144
void free_pb_stats_recursive(t_pb* pb);
145145

146-
void commit_lookahead_pins_used(t_pb* cur_pb);
147-
148146
t_pack_molecule* get_molecule_by_num_ext_inputs(const int ext_inps,
149147
const enum e_removal_policy remove_flag,
150148
t_cluster_placement_stats* cluster_placement_stats_ptr,

0 commit comments

Comments
 (0)