Skip to content

Commit 620034b

Browse files
[Place] Moved PlaceMacros Out of BlkLocRegistry
The PlaceMacros only require the Clustering and atom/arch info to be constructed; after which they are never modified. Since they are unchanged by the placement, they were out of place in the BlkLocRegistry. Moved them to the clustering context since they only make sense once the clusters are loaded. This will make it easier to separate out the initial placement from the SA placer.
1 parent 7f0f9fc commit 620034b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+391
-233
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ class APClusterPlacer {
101101
private:
102102
// Get the macro for the given cluster block.
103103
t_pl_macro get_macro(ClusterBlockId clb_blk_id) {
104-
const auto& place_macros = g_vpr_ctx.placement().blk_loc_registry().place_macros();
105104
// Basically stolen from initial_placement.cpp:place_one_block
106105
// TODO: Make this a cleaner interface and share the code.
107-
int imacro = place_macros.get_imacro_from_iblk(clb_blk_id);
106+
int imacro = place_macros_.get_imacro_from_iblk(clb_blk_id);
108107

109108
// If this block is part of a macro, return it.
110109
if (imacro != -1) {
111-
return place_macros[imacro];
110+
return place_macros_[imacro];
112111
}
113112
// If not, create a "fake" macro with a single element.
114113
t_pl_macro_member macro_member;
@@ -121,20 +120,22 @@ class APClusterPlacer {
121120
return pl_macro;
122121
}
123122

123+
const PlaceMacros& place_macros_;
124+
124125
public:
125126
/**
126127
* @brief Constructor for the APClusterPlacer
127128
*
128129
* Initializes internal and global state necessary to place clusters on the
129130
* FPGA device.
130131
*/
131-
APClusterPlacer() {
132+
APClusterPlacer(const PlaceMacros& place_macros)
133+
: place_macros_(place_macros) {
132134
// FIXME: This was stolen from place/place.cpp
133135
// it used a static method, just taking what I think I will need.
134136
auto& blk_loc_registry = g_vpr_ctx.mutable_placement().mutable_blk_loc_registry();
135-
const auto& directs = g_vpr_ctx.device().arch->directs;
136137

137-
init_placement_context(blk_loc_registry, directs);
138+
init_placement_context(blk_loc_registry);
138139

139140
// stolen from place/place.cpp:alloc_and_load_try_swap_structs
140141
// FIXME: set cube_bb to false by hand, should be passed in.
@@ -149,7 +150,7 @@ class APClusterPlacer {
149150
blk_loc_registry.clear_all_grid_locs();
150151

151152
// Deal with the placement constraints.
152-
propagate_place_constraints(blk_loc_registry.place_macros());
153+
propagate_place_constraints(place_macros_);
153154

154155
mark_fixed_blocks(blk_loc_registry);
155156

@@ -384,6 +385,7 @@ void NaiveFullLegalizer::create_clusters(const PartialPlacement& p_placement) {
384385
}
385386

386387
void NaiveFullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
388+
const PlaceMacros& place_macros,
387389
const PartialPlacement& p_placement) {
388390
// PLACING:
389391
// Create a lookup from the AtomBlockId to the APBlockId
@@ -405,7 +407,7 @@ void NaiveFullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
405407
// Move the clusters to where they want to be first.
406408
// TODO: The fixed clusters should probably be moved first for legality
407409
// reasons.
408-
APClusterPlacer ap_cluster_placer;
410+
APClusterPlacer ap_cluster_placer(place_macros);
409411
std::vector<ClusterBlockId> unplaced_clusters;
410412
for (ClusterBlockId cluster_blk_id : clb_nlist.blocks()) {
411413
// Assume that the cluster will always want to be placed wherever the
@@ -465,9 +467,10 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
465467
// Get the clustering from the global context.
466468
// TODO: Eventually should be returned from the create_clusters method.
467469
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
470+
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
468471

469472
// Place the clusters based on where the atoms want to be placed.
470-
place_clusters(clb_nlist, p_placement);
473+
place_clusters(clb_nlist, place_macros, p_placement);
471474

472475
// Verify that the placement created by the full legalizer is valid.
473476
unsigned num_placement_errors = verify_placement(g_vpr_ctx);
@@ -530,7 +533,9 @@ void APPack::legalize(const PartialPlacement& p_placement) {
530533
// TODO: This should only be the initial placer. Running the full SA would
531534
// be more of a Detailed Placer.
532535
const auto& placement_net_list = (const Netlist<>&)clb_nlist;
536+
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
533537
try_place(placement_net_list,
538+
place_macros,
534539
vpr_setup_.PlacerOpts,
535540
vpr_setup_.RouterOpts,
536541
vpr_setup_.AnalysisOpts,

vpr/src/analytical_place/full_legalizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AtomNetlist;
1919
class ClusteredNetlist;
2020
class DeviceGrid;
2121
class PartialPlacement;
22+
class PlaceMacros;
2223
class Prepacker;
2324
struct t_arch;
2425
struct t_logical_block_type;
@@ -125,6 +126,7 @@ class NaiveFullLegalizer : public FullLegalizer {
125126
* placement.
126127
*/
127128
void place_clusters(const ClusteredNetlist& clb_nlist,
129+
const PlaceMacros& place_macros,
128130
const PartialPlacement& p_placement);
129131

130132
};

vpr/src/base/blk_loc_registry.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net
4545
return this->tile_pin_index(pin_id);
4646
}
4747

48-
const PlaceMacros& BlkLocRegistry::place_macros() const {
49-
return place_macros_;
50-
}
51-
52-
PlaceMacros& BlkLocRegistry::mutable_place_macros() {
53-
return place_macros_;
54-
}
55-
5648
void BlkLocRegistry::set_block_location(ClusterBlockId blk_id, const t_pl_loc& location) {
5749
const auto& device_ctx = g_vpr_ctx.device();
5850
const auto& cluster_ctx = g_vpr_ctx.clustering();
@@ -289,3 +281,4 @@ t_physical_tile_loc BlkLocRegistry::get_coordinate_of_pin(ClusterPinId pin) cons
289281

290282
return tile_loc;
291283
}
284+

vpr/src/base/blk_loc_registry.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "vtr_vector_map.h"
66
#include "vpr_types.h"
77
#include "grid_block.h"
8-
#include "place_macro.h"
98

109
struct t_block_loc;
1110
struct t_pl_blocks_to_be_moved;
@@ -37,13 +36,6 @@ class BlkLocRegistry {
3736
///@brief Clustered pin placement mapping with physical pin
3837
vtr::vector_map<ClusterPinId, int> physical_pins_;
3938

40-
/**
41-
* @brief Contains information about placement macros.
42-
* A placement macro is a set of clustered blocks that must be placed
43-
* in a way that is compliant with relative locations specified by the macro.
44-
*/
45-
PlaceMacros place_macros_;
46-
4739
/// @brief Stores ClusterBlockId of all movable clustered blocks
4840
/// (blocks that are not locked down to a single location)
4941
std::vector<ClusterBlockId> movable_blocks_;
@@ -67,12 +59,6 @@ class BlkLocRegistry {
6759
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
6860
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
6961

70-
///@brief Returns a constant reference to placement macros.
71-
const PlaceMacros& place_macros() const;
72-
73-
///@brief Returns a mutable reference to placement macros.
74-
PlaceMacros& mutable_place_macros();
75-
7662
/// @brief Returns a constant reference to the vector of ClusterBlockIds of all movable clustered blocks.
7763
const std::vector<ClusterBlockId>& movable_blocks() const { return movable_blocks_; }
7864

@@ -170,3 +156,4 @@ class BlkLocRegistry {
170156

171157
e_expected_transaction expected_transaction_;
172158
};
159+

vpr/src/base/place_and_route.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <algorithm>
66

77
#include "FlatPlacementInfo.h"
8+
#include "place_macro.h"
89
#include "vtr_assert.h"
910
#include "vtr_log.h"
1011

@@ -45,6 +46,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
4546
const t_noc_opts& noc_opts,
4647
const t_file_name_opts& filename_opts,
4748
const t_arch* arch,
49+
const PlaceMacros& place_macros,
4850
bool verify_binary_search,
4951
int min_chan_width_hint,
5052
t_det_routing_arch* det_routing_arch,
@@ -166,6 +168,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
166168
if (placer_opts.place_freq == PLACE_ALWAYS) {
167169
placer_opts.place_chan_width = current;
168170
try_place(placement_net_list,
171+
place_macros,
169172
placer_opts,
170173
router_opts,
171174
analysis_opts,
@@ -310,7 +313,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
310313
break;
311314
if (placer_opts.place_freq == PLACE_ALWAYS) {
312315
placer_opts.place_chan_width = current;
313-
try_place(placement_net_list, placer_opts, router_opts, analysis_opts, noc_opts,
316+
try_place(placement_net_list, place_macros, placer_opts, router_opts, analysis_opts, noc_opts,
314317
arch->Chans, det_routing_arch, segment_inf,
315318
arch->directs,
316319
FlatPlacementInfo(), // Pass empty flat placement info.

vpr/src/base/place_and_route.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "RoutingDelayCalculator.h"
1212
#include "rr_graph.h"
1313

14+
class PlaceMacros;
15+
1416
struct t_fmap_cell {
1517
int fs; ///<at this fs
1618
int fc; ///<at this fc
@@ -27,6 +29,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
2729
const t_noc_opts& noc_opts,
2830
const t_file_name_opts& filename_opts,
2931
const t_arch* arch,
32+
const PlaceMacros& place_macros,
3033
bool verify_binary_search,
3134
int min_chan_width_hint,
3235
t_det_routing_arch* det_routing_arch,

vpr/src/base/vpr_api.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
#include <cstdio>
1515
#include <cstring>
1616
#include <cmath>
17+
#include <memory>
1718

1819
#include "FlatPlacementInfo.h"
1920
#include "cluster_util.h"
21+
#include "place_macro.h"
2022
#include "verify_placement.h"
2123
#include "vpr_context.h"
2224
#include "vtr_assert.h"
@@ -392,7 +394,8 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
392394

393395
{ //Place
394396
const auto& placement_net_list = (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;
395-
bool place_success = vpr_place_flow(placement_net_list, vpr_setup, arch);
397+
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
398+
bool place_success = vpr_place_flow(placement_net_list, vpr_setup, arch, place_macros);
396399

397400
if (!place_success) {
398401
return false; //Unimplementable
@@ -417,9 +420,10 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
417420

418421
bool is_flat = vpr_setup.RouterOpts.flat_routing;
419422
const Netlist<>& router_net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().nlist : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;
423+
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
420424
RouteStatus route_status;
421425
{ //Route
422-
route_status = vpr_route_flow(router_net_list, vpr_setup, arch, is_flat);
426+
route_status = vpr_route_flow(router_net_list, vpr_setup, arch, place_macros, is_flat);
423427
}
424428
{ //Analysis
425429
vpr_analysis_flow(router_net_list, vpr_setup, arch, route_status, is_flat);
@@ -705,6 +709,13 @@ void vpr_load_packing(const t_vpr_setup& vpr_setup, const t_arch& arch) {
705709
// print the total number of used physical blocks for each
706710
// physical block type after finishing the packing stage
707711
print_pb_type_count(g_vpr_ctx.clustering().clb_nlist);
712+
713+
// Alloc and load the placement macros.
714+
cluster_ctx.place_macros = std::make_unique<PlaceMacros>(arch.directs,
715+
g_vpr_ctx.device().physical_tile_types,
716+
cluster_ctx.clb_nlist,
717+
g_vpr_ctx.atom().nlist,
718+
g_vpr_ctx.atom().lookup);
708719
}
709720

710721
bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
@@ -741,7 +752,10 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
741752
return true;
742753
}
743754

744-
bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch) {
755+
bool vpr_place_flow(const Netlist<>& net_list,
756+
t_vpr_setup& vpr_setup,
757+
const t_arch& arch,
758+
const PlaceMacros& place_macros) {
745759
VTR_LOG("\n");
746760
const auto& placer_opts = vpr_setup.PlacerOpts;
747761
const auto& filename_opts = vpr_setup.FileNameOpts;
@@ -750,13 +764,13 @@ bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_a
750764
} else {
751765
if (placer_opts.doPlacement == STAGE_DO) {
752766
//Do the actual placement
753-
vpr_place(net_list, vpr_setup, arch);
767+
vpr_place(net_list, vpr_setup, arch, place_macros);
754768

755769
} else {
756770
VTR_ASSERT(placer_opts.doPlacement == STAGE_LOAD);
757771

758772
//Load a previous placement
759-
vpr_load_placement(vpr_setup, arch);
773+
vpr_load_placement(vpr_setup);
760774
}
761775

762776
post_place_sync();
@@ -781,7 +795,10 @@ bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_a
781795
return true;
782796
}
783797

784-
void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch) {
798+
void vpr_place(const Netlist<>& net_list,
799+
t_vpr_setup& vpr_setup,
800+
const t_arch& arch,
801+
const PlaceMacros& place_macros) {
785802
bool is_flat = false;
786803
if (vpr_setup.PlacerOpts.place_algorithm.is_timing_driven()) {
787804
// Prime lookahead cache to avoid adding lookahead computation cost to
@@ -806,6 +823,7 @@ void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch&
806823
}
807824

808825
try_place(net_list,
826+
place_macros,
809827
vpr_setup.PlacerOpts,
810828
vpr_setup.RouterOpts,
811829
vpr_setup.AnalysisOpts,
@@ -828,7 +846,7 @@ void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch&
828846
block_locs);
829847
}
830848

831-
void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
849+
void vpr_load_placement(t_vpr_setup& vpr_setup) {
832850
vtr::ScopedStartFinishTimer timer("Load Placement");
833851

834852
const auto& device_ctx = g_vpr_ctx.device();
@@ -837,7 +855,7 @@ void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
837855
const auto& filename_opts = vpr_setup.FileNameOpts;
838856

839857
//Initialize placement data structures, which will be filled when loading placement
840-
init_placement_context(blk_loc_registry, arch.directs);
858+
init_placement_context(blk_loc_registry);
841859

842860
//Load an existing placement from a file
843861
place_ctx.placement_id = read_place(filename_opts.NetFile.c_str(), filename_opts.PlaceFile.c_str(),
@@ -860,6 +878,7 @@ void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
860878
RouteStatus vpr_route_flow(const Netlist<>& net_list,
861879
t_vpr_setup& vpr_setup,
862880
const t_arch& arch,
881+
const PlaceMacros& place_macros,
863882
bool is_flat) {
864883
VTR_LOG("\n");
865884

@@ -906,7 +925,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
906925
//Do the actual routing
907926
if (NO_FIXED_CHANNEL_WIDTH == chan_width) {
908927
//Find minimum channel width
909-
route_status = vpr_route_min_W(net_list, vpr_setup, arch, timing_info, routing_delay_calc, net_delay, is_flat);
928+
route_status = vpr_route_min_W(net_list, vpr_setup, arch, timing_info, routing_delay_calc, net_delay, place_macros, is_flat);
910929
} else {
911930
//Route at specified channel width
912931
route_status = vpr_route_fixed_W(net_list, vpr_setup, arch, chan_width, timing_info, routing_delay_calc, net_delay, is_flat);
@@ -1036,6 +1055,7 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
10361055
std::shared_ptr<SetupHoldTimingInfo> timing_info,
10371056
std::shared_ptr<RoutingDelayCalculator> delay_calc,
10381057
NetPinsMatrix<float>& net_delay,
1058+
const PlaceMacros& place_macros,
10391059
bool is_flat) {
10401060
// Note that lookahead cache is not primed here because
10411061
// binary_search_place_and_route will change the channel width, and result
@@ -1052,6 +1072,7 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
10521072
vpr_setup.NocOpts,
10531073
vpr_setup.FileNameOpts,
10541074
&arch,
1075+
place_macros,
10551076
router_opts.verify_binary_search,
10561077
router_opts.min_channel_width_hint,
10571078
&vpr_setup.RoutingArch,

0 commit comments

Comments
 (0)