Skip to content

Commit 982b15a

Browse files
[APPack] Updated Comments and Small Bug Fix
1 parent af5c4f2 commit 982b15a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

vpr/src/pack/appack_context.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ struct t_appack_options {
8787
std::vector<float> max_unrelated_tile_distance;
8888

8989
// Unrelated clustering occurs after all other candidate selection methods
90-
// have failed. This parameter sets how many time we will attempt unrelated
91-
// clustering between failures of unrelated clustering. If this is set to
92-
// 1, and unrelated clustering failed for a cluster, it will not be attempted
90+
// have failed. This attempts to cluster in molecules that are not attracted
91+
// (using the packer's heuristics) to the molecules within a given cluster.
92+
// This parameter sets how many times we will attempt unrelated
93+
// clustering between failures of unrelated clustering. If a molecule used
94+
// for unrelated clustering failed to cluster it will not be attempted
9395
// again for that cluster (note: if it succeeds, the number of attempts get
9496
// reset).
9597
// NOTE: A similar option exists in the candidate selector class. This was
@@ -131,8 +133,9 @@ struct APPackContext : public Context {
131133
device_grid);
132134
}
133135

134-
// By default, when unrelated clustering is on, search for unrelated molecules
135-
// that are within 1 tile from the centroid of the cluster.
136+
// Set the max unrelated tile distances for all logical block types.
137+
// By default, we set this to a low value to only allow unrelated molecules
138+
// that are very close to the cluster being created.
136139
// NOTE: Molecules within the same tile as the centroid are considered to have
137140
// 0 distance. The distance is computed relative to the bounds of the
138141
// tile containing the centroid.

vpr/src/pack/appack_max_dist_th_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class APPackMaxDistThManager {
139139
/// This is initialized in the constructor and accessed during packing.
140140
std::vector<float> logical_block_dist_thresholds_;
141141

142-
/// @brief This is the maximum minhattan distance possible on the device. This
142+
/// @brief This is the maximum manhattan distance possible on the device. This
143143
/// is the distance of traveling from the bottom-left corner of the device
144144
/// to the top right.
145145
float max_distance_on_device_;

vpr/src/pack/greedy_candidate_selector.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,15 @@ PackMoleculeId GreedyCandidateSelector::get_unrelated_candidate_for_cluster_appa
12961296
continue;
12971297
}
12981298

1299+
// If the distance from the cluster to the current tile is larger than
1300+
// the best molecule's distance plus the farthest distance within the
1301+
// 1x1 tile (2.0), there cannot exist a molecule within the tile with a
1302+
// better distance than what we have found.
1303+
if (dist >= best_distance + 2.0) {
1304+
search_queue.pop();
1305+
break;
1306+
}
1307+
12991308
// If this position has been visited, skip it.
13001309
if (visited[node_loc.x][node_loc.y]) {
13011310
search_queue.pop();
@@ -1352,11 +1361,11 @@ PackMoleculeId GreedyCandidateSelector::get_unrelated_candidate_for_cluster_appa
13521361
// since they should be closer.
13531362
if (node_loc.x >= 1)
13541363
search_queue.push({node_loc.x - 1, node_loc.y, node_loc.layer_num});
1355-
if (node_loc.x <= (int)visited.dim_size(0) - 2)
1364+
if (node_loc.x <= (int)appack_unrelated_clustering_data_.dim_size(0) - 2)
13561365
search_queue.push({node_loc.x + 1, node_loc.y, node_loc.layer_num});
13571366
if (node_loc.y >= 1)
13581367
search_queue.push({node_loc.x, node_loc.y - 1, node_loc.layer_num});
1359-
if (node_loc.y <= (int)visited.dim_size(1) - 2)
1368+
if (node_loc.y <= (int)appack_unrelated_clustering_data_.dim_size(1) - 2)
13601369
search_queue.push({node_loc.x, node_loc.y + 1, node_loc.layer_num});
13611370

13621371
// Pop the position off the queue.

vpr/src/pack/pack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ bool try_pack(const t_packer_opts& packer_opts,
367367
if (appack_ctx.appack_options.use_appack) {
368368
// Only do unrelated clustering on the overused type instances.
369369
for (const auto& p : block_type_utils) {
370-
// Any overutalized block types will use the default options.
370+
// Any overutilized block types will use the default options.
371371
if (p.second > 1.0f)
372372
continue;
373373

374-
// Any underutalized block types should not do unrelated clustering.
374+
// Any underutilized block types should not do unrelated clustering.
375375
// We can turn this off by just setting the max attempts to 0.
376376
// TODO: These may become over-utilized in the future. Should
377377
// investigate turning these on if needed.

0 commit comments

Comments
 (0)