Skip to content

Commit 42756cd

Browse files
[APPack] Updated Comments
Updated comments and some variables names as per VB review.
1 parent 9667ed0 commit 42756cd

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

vpr/src/base/load_flat_place.cpp

+29-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@
2121
#include "vtr_assert.h"
2222
#include "vtr_log.h"
2323
#include "vtr_vector_map.h"
24+
#include "vtr_version.h"
25+
26+
/**
27+
* @brief Prints the header for the flat placement file. This includes helpful
28+
* information on how to read the file and when it was generated.
29+
*
30+
* @param fp
31+
* File pointer to the file the cluster is printed to.
32+
*/
33+
static void print_flat_placement_file_header(FILE* fp) {
34+
fprintf(fp, "# Flat Placement File\n");
35+
fprintf(fp, "# Auto-generated by VPR %s\n",
36+
vtr::VERSION);
37+
fprintf(fp, "# Created: %s\n",
38+
vtr::BUILD_TIMESTAMP);
39+
fprintf(fp, "#\n");
40+
fprintf(fp, "# This file prints the following information for each atom in the netlist:\n");
41+
fprintf(fp, "# <atom_name> <x> <y> <layer> <atom_sub_tile> <atom_site_idx> #<clb_blk_id> <atom_pb_type>\n");
42+
fprintf(fp, "\n");
43+
}
2444

2545
/**
2646
* @brief Prints flat placement file entries for the atoms in one placed
@@ -76,6 +96,9 @@ void write_flat_placement(const char* flat_place_file_path,
7696
// Create a file in write mode for the flat placement.
7797
FILE* fp = fopen(flat_place_file_path, "w");
7898

99+
// Add a header to the flat placement file.
100+
print_flat_placement_file_header(fp);
101+
79102
// For each cluster, write out the atoms in the cluster at this cluster's
80103
// location.
81104
for (ClusterBlockId iblk : cluster_netlist.blocks()) {
@@ -181,7 +204,7 @@ void log_flat_placement_reconstruction_info(
181204
const FlatPlacementInfo& flat_placement_info,
182205
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs,
183206
const vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>>& atoms_lookup,
184-
const AtomLookup& lookup,
207+
const AtomLookup& cluster_of_atom_lookup,
185208
const AtomNetlist& atom_netlist,
186209
const ClusteredNetlist& clustered_netlist) {
187210
// Go through each cluster and see how many clusters have atoms that
@@ -217,6 +240,8 @@ void log_flat_placement_reconstruction_info(
217240
// If the atom's flat placement more than half a block in any
218241
// direction from the flat placement centroid, then it does not
219242
// want to be in this cluster.
243+
// FIXME: This should take into account large blocks somehow, just
244+
// being 0.5 tiles away may not be sufficient.
220245
if (std::abs(centroid_x - flat_placement_info.blk_x_pos[atom_blk_id]) > 0.5f ||
221246
std::abs(centroid_y - flat_placement_info.blk_y_pos[atom_blk_id]) > 0.5f ||
222247
std::abs(centroid_layer - flat_placement_info.blk_layer[atom_blk_id]) > 0.5f ||
@@ -245,10 +270,12 @@ void log_flat_placement_reconstruction_info(
245270
int blk_layer = flat_placement_info.blk_layer[atom_blk_id];
246271

247272
// Get the (x, y, layer) position of the cluster that contains this block.
248-
ClusterBlockId atom_clb_id = lookup.atom_clb(atom_blk_id);
273+
ClusterBlockId atom_clb_id = cluster_of_atom_lookup.atom_clb(atom_blk_id);
249274
const t_block_loc& clb_loc = block_locs[atom_clb_id];
250275

251276
// Compute the distance between these two positions.
277+
// FIXME: This will overreport large blocks. This should really be
278+
// the distance outside of the tile you want to be placed in.
252279
float dx = blk_x - clb_loc.loc.x;
253280
float dy = blk_y - clb_loc.loc.y;
254281
float dlayer = blk_layer - clb_loc.loc.layer;

vpr/src/base/load_flat_place.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch);
7272
* The location of each cluster in the netlist.
7373
* @param atoms_lookup
7474
* A lookup between each cluster and the atoms it contains.
75-
* @param lookup
75+
* @param cluster_of_atom_lookup
7676
* A lookup between each atom and the cluster that contains it.
7777
* @param atom_netlist
7878
* The netlist of atoms the flat placement was over.
@@ -84,7 +84,7 @@ void log_flat_placement_reconstruction_info(
8484
const FlatPlacementInfo& flat_placement_info,
8585
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs,
8686
const vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>>& atoms_lookup,
87-
const AtomLookup& lookup,
87+
const AtomLookup& cluster_of_atom_lookup,
8888
const AtomNetlist& atom_netlist,
8989
const ClusteredNetlist& clustered_netlist);
9090

vpr/src/base/vpr_context.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct AtomContext : public Context {
8181
/// @brief Mappings to/from the Atom Netlist to physically described .blif models
8282
AtomLookup lookup;
8383

84-
/// @brief Placement information on each atom known before packing and
85-
/// placement.
84+
/// @brief Placement information on each atom known (from a file or another
85+
/// algorithm) before packing and the cluster-level placement.
8686
FlatPlacementInfo flat_placement_info;
8787
};
8888

vpr/src/pack/greedy_candidate_selector.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class GreedyCandidateSelector {
405405

406406
/**
407407
* @brief Add molecules that are "close" to the seed molecule in the flat
408-
* placement tot he list of feasible blocks.
408+
* placement to the list of feasible blocks.
409409
*/
410410
void add_cluster_molecule_candidates_by_flat_placement(
411411
ClusterGainStats& cluster_gain_stats,
@@ -547,10 +547,15 @@ class GreedyCandidateSelector {
547547
* flat placement information for clustering.
548548
*/
549549
struct FlatTileMoleculeList {
550-
// A list of molecules in the undefined sub-tile at this tile.
551-
std::vector<t_pack_molecule*> undefined_sub_tile_mols;
552-
// A list of molecule in each sub_tile at this tile.
550+
// A list of molecule in each sub_tile at this tile. Where each index
551+
// in the first dimension is the subtile [0, num_sub_tiles - 1].
553552
std::vector<std::vector<t_pack_molecule*>> sub_tile_mols;
553+
554+
// A list of molecules in the undefined sub-tile at this tile. An
555+
// undefined sub-tile is the location molecules go when the sub-tile
556+
// in the flat placement is unspecified for this atom.
557+
// Currently unused, but can be used to support that feature.
558+
std::vector<t_pack_molecule*> undefined_sub_tile_mols;
554559
};
555560

556561
/// @brief Pre-computed information on the flat placement. Lists all of the

vpr/src/place/initial_placement.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
560560
find_centroid_loc_from_flat_placement(pl_macro, centroid_loc, flat_placement_info);
561561
// If a centroid could not be found, or if the tile is not legal
562562
// fall-back on the centroid of the neighbor blocks of this block.
563+
// TODO: This may be more disruptive than needed for flat placement
564+
// reconstruction. Ideally, we would search for a new tile
565+
// location near the flat placement centroid.
563566
if (!is_loc_on_chip({centroid_loc.x, centroid_loc.y, centroid_loc.layer}) ||
564567
!is_loc_legal(centroid_loc, pr, block_type)) {
565568
unplaced_blocks_to_update_their_score = find_centroid_loc(pl_macro, centroid_loc, blk_loc_registry);

vtr_flow/tasks/regression_tests/vtr_reg_strong/strong_flat_placement/read_write/constraints/old_placement.fplace

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Flat Placement File
2+
# Auto-generated by VPR 9.0.0-dev+v8.0.0-12075-g53e90e62b-dirty
3+
# Created: 2025-01-28T09:59:25
4+
#
5+
# This file prints the following information for each atom in the netlist:
6+
# <atom_name> <x> <y> <layer> <atom_sub_tile> <atom_site_idx> #<clb_blk_id> <atom_pb_type>
7+
18
n523 6 8 0 0 3 #0 lut
29
n522 6 8 0 0 5 #0 lut
310
n520 6 8 0 0 2 #0 lut

0 commit comments

Comments
 (0)