Skip to content

Commit b53162c

Browse files
[Place] Moved Place Macros From Clustering to Placement Context
Vaughn thought that the place macros made more sense in the placement context instead of the clustering context.
1 parent 620034b commit b53162c

13 files changed

+63
-67
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,16 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
467467
// Get the clustering from the global context.
468468
// TODO: Eventually should be returned from the create_clusters method.
469469
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
470-
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
470+
471+
// Alloc and load the placement macros.
472+
VTR_ASSERT(!g_vpr_ctx.placement().place_macros);
473+
g_vpr_ctx.mutable_placement().place_macros = std::make_unique<PlaceMacros>(g_vpr_ctx.device().arch->directs,
474+
g_vpr_ctx.device().physical_tile_types,
475+
g_vpr_ctx.clustering().clb_nlist,
476+
g_vpr_ctx.atom().nlist,
477+
g_vpr_ctx.atom().lookup);
478+
479+
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
471480

472481
// Place the clusters based on where the atoms want to be placed.
473482
place_clusters(clb_nlist, place_macros, p_placement);
@@ -533,9 +542,7 @@ void APPack::legalize(const PartialPlacement& p_placement) {
533542
// TODO: This should only be the initial placer. Running the full SA would
534543
// be more of a Detailed Placer.
535544
const auto& placement_net_list = (const Netlist<>&)clb_nlist;
536-
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
537545
try_place(placement_net_list,
538-
place_macros,
539546
vpr_setup_.PlacerOpts,
540547
vpr_setup_.RouterOpts,
541548
vpr_setup_.AnalysisOpts,

vpr/src/base/place_and_route.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
4646
const t_noc_opts& noc_opts,
4747
const t_file_name_opts& filename_opts,
4848
const t_arch* arch,
49-
const PlaceMacros& place_macros,
5049
bool verify_binary_search,
5150
int min_chan_width_hint,
5251
t_det_routing_arch* det_routing_arch,
@@ -168,7 +167,6 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
168167
if (placer_opts.place_freq == PLACE_ALWAYS) {
169168
placer_opts.place_chan_width = current;
170169
try_place(placement_net_list,
171-
place_macros,
172170
placer_opts,
173171
router_opts,
174172
analysis_opts,
@@ -313,7 +311,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
313311
break;
314312
if (placer_opts.place_freq == PLACE_ALWAYS) {
315313
placer_opts.place_chan_width = current;
316-
try_place(placement_net_list, place_macros, placer_opts, router_opts, analysis_opts, noc_opts,
314+
try_place(placement_net_list, placer_opts, router_opts, analysis_opts, noc_opts,
317315
arch->Chans, det_routing_arch, segment_inf,
318316
arch->directs,
319317
FlatPlacementInfo(), // Pass empty flat placement info.

vpr/src/base/place_and_route.h

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

14-
class PlaceMacros;
15-
1614
struct t_fmap_cell {
1715
int fs; ///<at this fs
1816
int fc; ///<at this fc
@@ -29,7 +27,6 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
2927
const t_noc_opts& noc_opts,
3028
const t_file_name_opts& filename_opts,
3129
const t_arch* arch,
32-
const PlaceMacros& place_macros,
3330
bool verify_binary_search,
3431
int min_chan_width_hint,
3532
t_det_routing_arch* det_routing_arch,

vpr/src/base/vpr_api.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#include <cstring>
1616
#include <cmath>
1717
#include <memory>
18+
#include <vector>
1819

1920
#include "FlatPlacementInfo.h"
2021
#include "cluster_util.h"
22+
#include "physical_types.h"
2123
#include "place_macro.h"
2224
#include "verify_placement.h"
2325
#include "vpr_context.h"
@@ -394,8 +396,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
394396

395397
{ //Place
396398
const auto& placement_net_list = (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;
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);
399+
bool place_success = vpr_place_flow(placement_net_list, vpr_setup, arch);
399400

400401
if (!place_success) {
401402
return false; //Unimplementable
@@ -420,10 +421,9 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
420421

421422
bool is_flat = vpr_setup.RouterOpts.flat_routing;
422423
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;
424424
RouteStatus route_status;
425425
{ //Route
426-
route_status = vpr_route_flow(router_net_list, vpr_setup, arch, place_macros, is_flat);
426+
route_status = vpr_route_flow(router_net_list, vpr_setup, arch, is_flat);
427427
}
428428
{ //Analysis
429429
vpr_analysis_flow(router_net_list, vpr_setup, arch, route_status, is_flat);
@@ -709,13 +709,6 @@ void vpr_load_packing(const t_vpr_setup& vpr_setup, const t_arch& arch) {
709709
// print the total number of used physical blocks for each
710710
// physical block type after finishing the packing stage
711711
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);
719712
}
720713

721714
bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
@@ -754,8 +747,7 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
754747

755748
bool vpr_place_flow(const Netlist<>& net_list,
756749
t_vpr_setup& vpr_setup,
757-
const t_arch& arch,
758-
const PlaceMacros& place_macros) {
750+
const t_arch& arch) {
759751
VTR_LOG("\n");
760752
const auto& placer_opts = vpr_setup.PlacerOpts;
761753
const auto& filename_opts = vpr_setup.FileNameOpts;
@@ -764,13 +756,13 @@ bool vpr_place_flow(const Netlist<>& net_list,
764756
} else {
765757
if (placer_opts.doPlacement == STAGE_DO) {
766758
//Do the actual placement
767-
vpr_place(net_list, vpr_setup, arch, place_macros);
759+
vpr_place(net_list, vpr_setup, arch);
768760

769761
} else {
770762
VTR_ASSERT(placer_opts.doPlacement == STAGE_LOAD);
771763

772764
//Load a previous placement
773-
vpr_load_placement(vpr_setup);
765+
vpr_load_placement(vpr_setup, arch.directs);
774766
}
775767

776768
post_place_sync();
@@ -797,8 +789,7 @@ bool vpr_place_flow(const Netlist<>& net_list,
797789

798790
void vpr_place(const Netlist<>& net_list,
799791
t_vpr_setup& vpr_setup,
800-
const t_arch& arch,
801-
const PlaceMacros& place_macros) {
792+
const t_arch& arch) {
802793
bool is_flat = false;
803794
if (vpr_setup.PlacerOpts.place_algorithm.is_timing_driven()) {
804795
// Prime lookahead cache to avoid adding lookahead computation cost to
@@ -823,7 +814,6 @@ void vpr_place(const Netlist<>& net_list,
823814
}
824815

825816
try_place(net_list,
826-
place_macros,
827817
vpr_setup.PlacerOpts,
828818
vpr_setup.RouterOpts,
829819
vpr_setup.AnalysisOpts,
@@ -846,7 +836,8 @@ void vpr_place(const Netlist<>& net_list,
846836
block_locs);
847837
}
848838

849-
void vpr_load_placement(t_vpr_setup& vpr_setup) {
839+
void vpr_load_placement(t_vpr_setup& vpr_setup,
840+
const std::vector<t_direct_inf> directs) {
850841
vtr::ScopedStartFinishTimer timer("Load Placement");
851842

852843
const auto& device_ctx = g_vpr_ctx.device();
@@ -857,6 +848,13 @@ void vpr_load_placement(t_vpr_setup& vpr_setup) {
857848
//Initialize placement data structures, which will be filled when loading placement
858849
init_placement_context(blk_loc_registry);
859850

851+
// Alloc and load the placement macros.
852+
place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,
853+
device_ctx.physical_tile_types,
854+
g_vpr_ctx.clustering().clb_nlist,
855+
g_vpr_ctx.atom().nlist,
856+
g_vpr_ctx.atom().lookup);
857+
860858
//Load an existing placement from a file
861859
place_ctx.placement_id = read_place(filename_opts.NetFile.c_str(), filename_opts.PlaceFile.c_str(),
862860
blk_loc_registry,
@@ -878,7 +876,6 @@ void vpr_load_placement(t_vpr_setup& vpr_setup) {
878876
RouteStatus vpr_route_flow(const Netlist<>& net_list,
879877
t_vpr_setup& vpr_setup,
880878
const t_arch& arch,
881-
const PlaceMacros& place_macros,
882879
bool is_flat) {
883880
VTR_LOG("\n");
884881

@@ -925,7 +922,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
925922
//Do the actual routing
926923
if (NO_FIXED_CHANNEL_WIDTH == chan_width) {
927924
//Find minimum channel width
928-
route_status = vpr_route_min_W(net_list, vpr_setup, arch, timing_info, routing_delay_calc, net_delay, place_macros, is_flat);
925+
route_status = vpr_route_min_W(net_list, vpr_setup, arch, timing_info, routing_delay_calc, net_delay, is_flat);
929926
} else {
930927
//Route at specified channel width
931928
route_status = vpr_route_fixed_W(net_list, vpr_setup, arch, chan_width, timing_info, routing_delay_calc, net_delay, is_flat);
@@ -1055,7 +1052,6 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
10551052
std::shared_ptr<SetupHoldTimingInfo> timing_info,
10561053
std::shared_ptr<RoutingDelayCalculator> delay_calc,
10571054
NetPinsMatrix<float>& net_delay,
1058-
const PlaceMacros& place_macros,
10591055
bool is_flat) {
10601056
// Note that lookahead cache is not primed here because
10611057
// binary_search_place_and_route will change the channel width, and result
@@ -1072,7 +1068,6 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
10721068
vpr_setup.NocOpts,
10731069
vpr_setup.FileNameOpts,
10741070
&arch,
1075-
place_macros,
10761071
router_opts.verify_binary_search,
10771072
router_opts.min_channel_width_hint,
10781073
&vpr_setup.RoutingArch,

vpr/src/base/vpr_api.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141

4242
#include "vpr_error.h"
4343

44-
class PlaceMacros;
45-
4644
/*
4745
* Main VPR Operations
4846
*/
@@ -75,25 +73,23 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch);
7573
///@brief Perform, load or skip the placement stage
7674
bool vpr_place_flow(const Netlist<>& net_list,
7775
t_vpr_setup& vpr_setup,
78-
const t_arch& arch,
79-
const PlaceMacros& place_macros);
76+
const t_arch& arch);
8077

8178
///@brief Perform placement
8279
void vpr_place(const Netlist<>& net_list,
8380
t_vpr_setup& vpr_setup,
84-
const t_arch& arch,
85-
const PlaceMacros& place_macros);
81+
const t_arch& arch);
8682

8783
///@brief Loads a previous placement
88-
void vpr_load_placement(t_vpr_setup& vpr_setup);
84+
void vpr_load_placement(t_vpr_setup& vpr_setup,
85+
const std::vector<t_direct_inf> directs);
8986

9087
/* Routing */
9188

9289
///@brief Perform, load or skip the routing stage
9390
RouteStatus vpr_route_flow(const Netlist<>& net_list,
9491
t_vpr_setup& vpr_setup,
9592
const t_arch& arch,
96-
const PlaceMacros& place_macros,
9793
bool is_flat);
9894

9995
///@brief Perform routing at a fixed channel width)
@@ -113,7 +109,6 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
113109
std::shared_ptr<SetupHoldTimingInfo> timing_info,
114110
std::shared_ptr<RoutingDelayCalculator> delay_calc,
115111
NetPinsMatrix<float>& net_delay,
116-
const PlaceMacros& place_macros,
117112
bool is_flat);
118113

119114
///@brief Loads a previous routing

vpr/src/base/vpr_context.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,6 @@ struct ClusteringContext : public Context {
301301
/// clustered block [0 .. num_clustered_blocks-1]
302302
/// This is populated when the packing is loaded.
303303
vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>> atoms_lookup;
304-
305-
/// @brief Collection of all the placement macros in the netlist. A placement
306-
/// macro is a set of clustered blocks that must be placed in a way
307-
/// that is compliant with relative locations specified by the macro.
308-
/// Macros are used during placement and are not modified after they
309-
/// are created.
310-
/// This is created when the packing is loaded.
311-
std::unique_ptr<PlaceMacros> place_macros;
312304
};
313305

314306
/**
@@ -371,6 +363,16 @@ struct PlacementContext : public Context {
371363
*/
372364
void unlock_loc_vars() { VTR_ASSERT_SAFE(!loc_vars_are_accessible_); loc_vars_are_accessible_ = true; }
373365

366+
/**
367+
* @brief Collection of all the placement macros in the netlist. A placement
368+
* macro is a set of clustered blocks that must be placed in a way
369+
* that is compliant with relative locations specified by the macro.
370+
* Macros are used during placement and are not modified after they
371+
* are created.
372+
* This is created at the start of placement.
373+
*/
374+
std::unique_ptr<PlaceMacros> place_macros;
375+
374376
/**
375377
* @brief Compressed grid space for each block type
376378
*

vpr/src/draw/draw_basic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ void draw_placement_macros(ezgl::renderer* g) {
777777

778778
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
779779

780-
VTR_ASSERT(g_vpr_ctx.clustering().place_macros);
781-
const PlaceMacros& place_macros = *g_vpr_ctx.clustering().place_macros;
780+
VTR_ASSERT(g_vpr_ctx.placement().place_macros);
781+
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
782782

783783
for (const t_pl_macro& pl_macro : place_macros.macros()) {
784784

vpr/src/place/place.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static bool is_cube_bb(const e_place_bounding_box_mode place_bb_mode,
3333

3434
/*****************************************************************************/
3535
void try_place(const Netlist<>& net_list,
36-
const PlaceMacros& place_macros,
3736
const t_placer_opts& placer_opts,
3837
const t_router_opts& router_opts,
3938
const t_analysis_opts& analysis_opts,
@@ -91,6 +90,13 @@ void try_place(const Netlist<>& net_list,
9190
place_ctx.lock_loc_vars();
9291
place_ctx.compressed_block_grids = create_compressed_block_grids();
9392

93+
// Alloc and load the placement macros.
94+
place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,
95+
device_ctx.physical_tile_types,
96+
cluster_ctx.clb_nlist,
97+
atom_ctx.nlist,
98+
atom_ctx.lookup);
99+
94100
/* Start measuring placement time. The measured execution time will be printed
95101
* when this object goes out of scope at the end of this function.
96102
*/
@@ -101,7 +107,7 @@ void try_place(const Netlist<>& net_list,
101107
// Enables fast look-up of atom pins connect to CLB pins
102108
ClusteredPinAtomPinsLookup netlist_pin_lookup(cluster_ctx.clb_nlist, atom_ctx.nlist, pb_gpin_lookup);
103109

104-
Placer placer(net_list, place_macros, placer_opts, analysis_opts, noc_opts, pb_gpin_lookup, netlist_pin_lookup,
110+
Placer placer(net_list, placer_opts, analysis_opts, noc_opts, pb_gpin_lookup, netlist_pin_lookup,
105111
flat_placement_info, place_delay_model, cube_bb, is_flat, /*quiet=*/false);
106112

107113
placer.place();

vpr/src/place/place.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
#include "vpr_types.h"
55

66
class FlatPlacementInfo;
7-
class PlaceMacros;
87

98
void try_place(const Netlist<>& net_list,
10-
const PlaceMacros& place_macros,
119
const t_placer_opts& placer_opts,
1210
const t_router_opts& router_opts,
1311
const t_analysis_opts& analysis_opts,

vpr/src/place/placement_log_printer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void PlacementLogPrinter::print_initial_placement_stats() const {
197197
}
198198

199199
const BlkLocRegistry& blk_loc_registry = placer_.placer_state_.blk_loc_registry();
200-
const PlaceMacros& place_macros = placer_.place_macros_;
200+
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
201201
size_t num_macro_members = 0;
202202
for (const t_pl_macro& macro : place_macros.macros()) {
203203
num_macro_members += macro.members.size();

0 commit comments

Comments
 (0)