Skip to content

Commit 2f08e3e

Browse files
author
MohamedElgammal
committed
Use the pre-built atom lookup instead of rebuilding it multiple times
1 parent 69f6bc3 commit 2f08e3e

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

vpr/src/base/vpr_constraints_writer.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <fstream>
1919
#include "vpr_constraints_writer.h"
2020
#include "region.h"
21+
#include "re_cluster_util.h"
2122

2223
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, int horizontal_partitions, int vertical_partitions) {
2324
VprConstraints constraints;
@@ -46,7 +47,6 @@ void write_vpr_floorplan_constraints(const char* file_name, int expand, bool sub
4647
void setup_vpr_floorplan_constraints_one_loc(VprConstraints& constraints, int expand, bool subtile) {
4748
auto& cluster_ctx = g_vpr_ctx.clustering();
4849
auto& place_ctx = g_vpr_ctx.placement();
49-
ClusterAtomsLookup atoms_lookup;
5050

5151
int part_id = 0;
5252
/*
@@ -77,9 +77,9 @@ void setup_vpr_floorplan_constraints_one_loc(VprConstraints& constraints, int ex
7777
part.set_part_region(pr);
7878
constraints.add_partition(part);
7979

80-
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(blk_id);
80+
std::unordered_set<AtomBlockId>* atoms = cluster_to_atoms(blk_id);
8181

82-
for (auto atom_id : atoms) {
82+
for (auto atom_id : *atoms) {
8383
constraints.add_constrained_atom(atom_id, partid);
8484
}
8585
part_id++;
@@ -90,7 +90,6 @@ void setup_vpr_floorplan_constraints_cutpoints(VprConstraints& constraints, int
9090
auto& cluster_ctx = g_vpr_ctx.clustering();
9191
auto& place_ctx = g_vpr_ctx.placement();
9292
auto& device_ctx = g_vpr_ctx.device();
93-
ClusterAtomsLookup atoms_lookup;
9493

9594
//calculate the cutpoint values according to the grid size
9695
//load two arrays - one for horizontal cutpoints and one for vertical
@@ -151,7 +150,7 @@ void setup_vpr_floorplan_constraints_cutpoints(VprConstraints& constraints, int
151150
* appropriate region accordingly
152151
*/
153152
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
154-
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(blk_id);
153+
std::unordered_set<AtomBlockId>* atoms = cluster_to_atoms(blk_id);
155154
int x = place_ctx.block_locs[blk_id].loc.x;
156155
int y = place_ctx.block_locs[blk_id].loc.y;
157156
int width = device_ctx.grid.width();
@@ -183,7 +182,7 @@ void setup_vpr_floorplan_constraints_cutpoints(VprConstraints& constraints, int
183182

184183
VTR_ASSERT(got != region_atoms.end());
185184

186-
for (auto atom_id : atoms) {
185+
for (auto atom_id : *atoms) {
187186
got->second.push_back(atom_id);
188187
}
189188
}

vpr/src/pack/cluster_util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3677,7 +3677,6 @@ t_pb* get_top_level_pb(t_pb* pb) {
36773677
return top_level_pb;
36783678
}
36793679

3680-
36813680
void init_clb_atoms_lookup(vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>>& atoms_lookup) {
36823681
auto& atom_ctx = g_vpr_ctx.atom();
36833682
auto& cluster_ctx = g_vpr_ctx.clustering();

vpr/src/place/place_constraints.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "globals.h"
1212
#include "place_constraints.h"
1313
#include "place_util.h"
14+
#include "re_cluster_util.h"
1415

1516
/*checks that each block's location is compatible with its floorplanning constraints if it has any*/
1617
int check_placement_floorplanning() {
@@ -228,18 +229,17 @@ bool cluster_floorplanning_legal(ClusterBlockId blk_id, const t_pl_loc& loc) {
228229
void load_cluster_constraints() {
229230
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
230231
auto& cluster_ctx = g_vpr_ctx.clustering();
231-
ClusterAtomsLookup atoms_lookup;
232232

233233
floorplanning_ctx.cluster_constraints.resize(cluster_ctx.clb_nlist.blocks().size());
234234

235235
for (auto cluster_id : cluster_ctx.clb_nlist.blocks()) {
236-
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(cluster_id);
236+
std::unordered_set<AtomBlockId>* atoms = cluster_to_atoms(cluster_id);
237237
PartitionRegion empty_pr;
238238
floorplanning_ctx.cluster_constraints[cluster_id] = empty_pr;
239239

240240
//if there are any constrainted atoms in the cluster,
241241
//we update the cluster's PartitionRegion
242-
for (auto atom : atoms) {
242+
for (auto atom : *atoms) {
243243
PartitionId partid = floorplanning_ctx.constraints.get_atom_partition(atom);
244244

245245
if (partid != PartitionId::INVALID()) {

0 commit comments

Comments
 (0)