Skip to content

Commit a85ecc4

Browse files
enum class e_pad_loc_type and more comments
1 parent 25e803c commit a85ecc4

12 files changed

+86
-40
lines changed

vpr/src/base/ShowSetup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,10 @@ static void ShowPlacerOpts(const t_placer_opts& PlacerOpts,
526526

527527
VTR_LOG("PlacerOpts.pad_loc_type: ");
528528
switch (PlacerOpts.pad_loc_type) {
529-
case FREE:
529+
case e_pad_loc_type::FREE:
530530
VTR_LOG("FREE\n");
531531
break;
532-
case RANDOM:
532+
case e_pad_loc_type::RANDOM:
533533
VTR_LOG("RANDOM\n");
534534
break;
535535
default:

vpr/src/base/read_options.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ struct ParseFixPins {
532532
ConvertedValue<e_pad_loc_type> from_str(const std::string& str) {
533533
ConvertedValue<e_pad_loc_type> conv_value;
534534
if (str == "free")
535-
conv_value.set_value(FREE);
535+
conv_value.set_value(e_pad_loc_type::FREE);
536536
else if (str == "random")
537-
conv_value.set_value(RANDOM);
537+
conv_value.set_value(e_pad_loc_type::RANDOM);
538538
else {
539539
std::stringstream msg;
540540
msg << "Invalid conversion from '" << str << "' to e_router_algorithm (expected one of: " << argparse::join(default_choices(), ", ") << ")";
@@ -545,10 +545,10 @@ struct ParseFixPins {
545545

546546
ConvertedValue<std::string> to_str(e_pad_loc_type val) {
547547
ConvertedValue<std::string> conv_value;
548-
if (val == FREE)
548+
if (val == e_pad_loc_type::FREE)
549549
conv_value.set_value("free");
550550
else {
551-
VTR_ASSERT(val == RANDOM);
551+
VTR_ASSERT(val == e_pad_loc_type::RANDOM);
552552
conv_value.set_value("random");
553553
}
554554
return conv_value;

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ class t_place_algorithm {
11271127
e_place_algorithm algo = e_place_algorithm::CRITICALITY_TIMING_PLACE;
11281128
};
11291129

1130-
enum e_pad_loc_type {
1130+
enum class e_pad_loc_type {
11311131
FREE,
11321132
RANDOM
11331133
};

vpr/src/place/centroid_move_generator.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ e_create_move CentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& block
4747
const auto& block_locs = placer_ctx.block_locs();
4848
const auto& device_ctx = g_vpr_ctx.device();
4949
const auto& cluster_ctx = g_vpr_ctx.clustering();
50-
auto& place_move_ctx = placer_ctx.mutable_move();
50+
const auto& place_move_ctx = placer_ctx.move();
5151
const auto& place_loc_vars = placer_ctx.place_loc_vars();
5252

5353
// Find a movable block based on blk_type
54-
ClusterBlockId b_from = propose_block_to_move(placer_opts, proposed_action.logical_blk_type_index, false, nullptr, nullptr, placer_ctx);
54+
ClusterBlockId b_from = propose_block_to_move(placer_opts,
55+
proposed_action.logical_blk_type_index,
56+
/*highly_crit_block=*/false,
57+
/*net_from=*/nullptr,
58+
/*pin_from=*/nullptr,
59+
placer_ctx);
5560

5661
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug,
5762
"Centroid Move Choose Block %d - rlim %f\n",

vpr/src/place/critical_uniform_move_generator.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved
1212
const t_placer_opts& placer_opts,
1313
const PlacerCriticalities* /*criticalities*/) {
1414
auto& cluster_ctx = g_vpr_ctx.clustering();
15-
auto& placer_ctx = placer_ctx_.get();
15+
const auto& placer_ctx = placer_ctx_.get();
1616
const auto& block_locs = placer_ctx.block_locs();
17+
const auto& place_loc_vars = placer_ctx.place_loc_vars();
1718

1819
ClusterNetId net_from;
1920
int pin_from;
2021
//Find a movable block based on blk_type
21-
ClusterBlockId b_from = propose_block_to_move(placer_opts, proposed_action.logical_blk_type_index, true, &net_from, &pin_from, placer_ctx);
22+
ClusterBlockId b_from = propose_block_to_move(placer_opts,
23+
proposed_action.logical_blk_type_index,
24+
/*highly_crit_block=*/true,
25+
&net_from,
26+
&pin_from,
27+
placer_ctx);
28+
2229
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Critical Uniform Move Choose Block %d - rlim %f\n", size_t(b_from), rlim);
2330

2431
if (!b_from) { //No movable block found
@@ -33,11 +40,11 @@ e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved
3340

3441
t_pl_loc to;
3542
to.layer = from.layer;
36-
if (!find_to_loc_uniform(cluster_from_type, rlim, from, to, b_from, placer_ctx.place_loc_vars())) {
43+
if (!find_to_loc_uniform(cluster_from_type, rlim, from, to, b_from, place_loc_vars)) {
3744
return e_create_move::ABORT;
3845
}
3946

40-
e_create_move create_move = ::create_move(blocks_affected, b_from, to, placer_ctx.place_loc_vars());
47+
e_create_move create_move = ::create_move(blocks_affected, b_from, to, place_loc_vars);
4148

4249
//Check that all the blocks affected by the move would still be in a legal floorplan region after the swap
4350
if (!floorplan_legal(blocks_affected)) {

vpr/src/place/feasible_region_move_generator.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
2424
ClusterNetId net_from;
2525
int pin_from;
2626
//Find a movable block based on blk_type
27-
ClusterBlockId b_from = propose_block_to_move(placer_opts, proposed_action.logical_blk_type_index, true, &net_from, &pin_from, placer_ctx);
27+
ClusterBlockId b_from = propose_block_to_move(placer_opts,
28+
proposed_action.logical_blk_type_index,
29+
/*highly_crit_block=*/true,
30+
&net_from,
31+
&pin_from,
32+
placer_ctx);
33+
2834
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Feasible Region Move Choose Block %di - rlim %f\n", size_t(b_from), rlim);
2935

3036
if (!b_from) { //No movable block found

vpr/src/place/initial_noc_placement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ static void place_constrained_noc_router(ClusterBlockId router_blk_id,
8888

8989
bool macro_placed = false;
9090
for (int i_try = 0; i_try < MAX_NUM_TRIES_TO_PLACE_MACROS_RANDOMLY && !macro_placed; i_try++) {
91-
macro_placed = try_place_macro_randomly(pl_macro, pr, block_type, FREE, place_loc_vars);
91+
macro_placed = try_place_macro_randomly(pl_macro, pr, block_type, e_pad_loc_type::FREE, place_loc_vars);
9292
}
9393

9494
if (!macro_placed) {
95-
macro_placed = try_place_macro_exhaustively(pl_macro, pr, block_type, FREE, place_loc_vars);
95+
macro_placed = try_place_macro_exhaustively(pl_macro, pr, block_type, e_pad_loc_type::FREE, place_loc_vars);
9696
}
9797

9898
if (!macro_placed) {

vpr/src/place/initial_placement.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void clear_all_grid_locs(PlaceLocVars& place_loc_avrs);
6868
*/
6969
static bool place_macro(int macros_max_num_tries,
7070
const t_pl_macro& pl_macro,
71-
enum e_pad_loc_type pad_loc_type,
71+
e_pad_loc_type pad_loc_type,
7272
std::vector<t_grid_empty_locs_block_type>* blk_types_empty_locs_in_grid,
7373
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
7474
PlaceLocVars& place_loc_avrs);
@@ -135,7 +135,7 @@ static std::vector<t_grid_empty_locs_block_type> init_blk_types_empty_locations(
135135
*/
136136
static inline void fix_IO_block_types(const t_pl_macro& pl_macro,
137137
t_pl_loc loc,
138-
enum e_pad_loc_type pad_loc_type,
138+
e_pad_loc_type pad_loc_type,
139139
vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
140140

141141
/**
@@ -193,7 +193,7 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
193193
static bool try_centroid_placement(const t_pl_macro& pl_macro,
194194
const PartitionRegion& pr,
195195
t_logical_block_type_ptr block_type,
196-
enum e_pad_loc_type pad_loc_type,
196+
e_pad_loc_type pad_loc_type,
197197
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
198198
PlaceLocVars& place_loc_avrs);
199199

@@ -213,7 +213,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
213213
static bool try_dense_placement(const t_pl_macro& pl_macro,
214214
const PartitionRegion& pr,
215215
t_logical_block_type_ptr block_type,
216-
enum e_pad_loc_type pad_loc_type,
216+
e_pad_loc_type pad_loc_type,
217217
std::vector<t_grid_empty_locs_block_type>* blk_types_empty_locs_in_grid,
218218
PlaceLocVars& place_loc_avrs);
219219

@@ -225,7 +225,7 @@ static bool try_dense_placement(const t_pl_macro& pl_macro,
225225
*/
226226
static void place_all_blocks(const t_placer_opts& placer_opts,
227227
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
228-
enum e_pad_loc_type pad_loc_type,
228+
e_pad_loc_type pad_loc_type,
229229
const char* constraints_file,
230230
PlaceLocVars& place_loc_avrs);
231231

@@ -479,7 +479,7 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
479479
static bool try_centroid_placement(const t_pl_macro& pl_macro,
480480
const PartitionRegion& pr,
481481
t_logical_block_type_ptr block_type,
482-
enum e_pad_loc_type pad_loc_type,
482+
e_pad_loc_type pad_loc_type,
483483
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
484484
PlaceLocVars& place_loc_vars) {
485485
auto& block_locs = place_loc_vars.mutable_block_locs();
@@ -625,14 +625,14 @@ static std::vector<t_grid_empty_locs_block_type> init_blk_types_empty_locations(
625625

626626
static inline void fix_IO_block_types(const t_pl_macro& pl_macro,
627627
t_pl_loc loc,
628-
enum e_pad_loc_type pad_loc_type,
628+
e_pad_loc_type pad_loc_type,
629629
vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
630630
const auto& device_ctx = g_vpr_ctx.device();
631631

632632
//If the user marked the IO block pad_loc_type as RANDOM, that means it should be randomly
633633
//placed and then stay fixed to that location, which is why the macro members are marked as fixed.
634634
const auto& type = device_ctx.grid.get_physical_type({loc.x, loc.y, loc.layer});
635-
if (is_io_type(type) && pad_loc_type == RANDOM) {
635+
if (is_io_type(type) && pad_loc_type == e_pad_loc_type::RANDOM) {
636636
for (const t_pl_macro_member& pl_macro_member : pl_macro.members) {
637637
block_locs[pl_macro_member.blk_index].is_fixed = true;
638638
}
@@ -642,7 +642,7 @@ static inline void fix_IO_block_types(const t_pl_macro& pl_macro,
642642
bool try_place_macro_randomly(const t_pl_macro& pl_macro,
643643
const PartitionRegion& pr,
644644
t_logical_block_type_ptr block_type,
645-
enum e_pad_loc_type pad_loc_type,
645+
e_pad_loc_type pad_loc_type,
646646
PlaceLocVars& place_loc_vars) {
647647
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
648648

@@ -722,7 +722,7 @@ bool try_place_macro_randomly(const t_pl_macro& pl_macro,
722722
bool try_place_macro_exhaustively(const t_pl_macro& pl_macro,
723723
const PartitionRegion& pr,
724724
t_logical_block_type_ptr block_type,
725-
enum e_pad_loc_type pad_loc_type,
725+
e_pad_loc_type pad_loc_type,
726726
PlaceLocVars& place_loc_vars) {
727727
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
728728
auto& block_locs = place_loc_vars.mutable_block_locs();
@@ -812,7 +812,7 @@ bool try_place_macro_exhaustively(const t_pl_macro& pl_macro,
812812
static bool try_dense_placement(const t_pl_macro& pl_macro,
813813
const PartitionRegion& pr,
814814
t_logical_block_type_ptr block_type,
815-
enum e_pad_loc_type pad_loc_type,
815+
e_pad_loc_type pad_loc_type,
816816
std::vector<t_grid_empty_locs_block_type>* blk_types_empty_locs_in_grid,
817817
PlaceLocVars& place_loc_vars) {
818818
t_pl_loc loc;

vpr/src/place/initial_placement.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct t_block_score {
3333

3434
/**
3535
* @brief keeps track of available empty locations of a specific block type during initial placement.
36-
* Used to densly place macros that failed to be placed in the first initial placement iteration (random placement)
36+
* Used to densely place macros that failed to be placed in the first initial placement iteration (random placement)
3737
*/
3838
struct t_grid_empty_locs_block_type {
3939
/*
@@ -52,17 +52,19 @@ struct t_grid_empty_locs_block_type {
5252
* @brief tries to place a macro at a random location
5353
*
5454
* @param pl_macro The macro to be placed.
55-
* @param pr The PartitionRegion of the macro - represents its floorplanning constraints, is the size of the whole chip if the macro is not
56-
* constrained.
55+
* @param pr The PartitionRegion of the macro - represents its floorplanning constraints,
56+
* is the size of the whole chip if the macro is not constrained.
5757
* @param block_type Logical block type of the macro blocks.
5858
* @param pad_loc_type Used to check whether an io block needs to be marked as fixed.
59+
* @param place_loc_vars Placement block location information. To be filled with the location
60+
* where pl_macro is placed.
5961
*
6062
* @return true if the macro gets placed, false if not.
6163
*/
6264
bool try_place_macro_randomly(const t_pl_macro& pl_macro,
6365
const PartitionRegion& pr,
6466
t_logical_block_type_ptr block_type,
65-
enum e_pad_loc_type pad_loc_type,
67+
e_pad_loc_type pad_loc_type,
6668
PlaceLocVars& place_loc_vars);
6769

6870

@@ -74,13 +76,15 @@ bool try_place_macro_randomly(const t_pl_macro& pl_macro,
7476
* constrained.
7577
* @param block_type Logical block type of the macro blocks.
7678
* @param pad_loc_type Used to check whether an io block needs to be marked as fixed.
79+
* @param place_loc_vars Placement block location information. To be filled with the location
80+
* where pl_macro is placed.
7781
*
7882
* @return true if the macro gets placed, false if not.
7983
*/
8084
bool try_place_macro_exhaustively(const t_pl_macro& pl_macro,
8185
const PartitionRegion& pr,
8286
t_logical_block_type_ptr block_type,
83-
enum e_pad_loc_type pad_loc_type,
87+
e_pad_loc_type pad_loc_type,
8488
PlaceLocVars& place_loc_vars);
8589

8690
/**
@@ -89,6 +93,8 @@ bool try_place_macro_exhaustively(const t_pl_macro& pl_macro,
8993
*
9094
* @param pl_macro The macro to be placed.
9195
* @param head_pos The location of the macro head member.
96+
* @param place_loc_vars Placement block location information. To be filled with the location
97+
* where pl_macro is placed.
9298
*
9399
* @return true if macro was placed, false if not.
94100
*/
@@ -100,6 +106,8 @@ bool try_place_macro(const t_pl_macro& pl_macro,
100106
* @brief Checks whether the block is already placed
101107
*
102108
* @param blk_id block id of the block to be checked
109+
* @param place_loc_vars Placement block location information. To be filled with the location
110+
* where pl_macro is placed.
103111
*
104112
* @return true if the block was placed, false if not.
105113
*/
@@ -117,8 +125,10 @@ bool is_block_placed(ClusterBlockId blk_id,
117125
* @param placer_opts Required by the function that set the status of f_placer_debug.
118126
* Also used to access pad_loc_type to see if a block needs to be marked fixed.
119127
* @param constraints_file Used to read block locations if any constraints is available.
120-
* @param noc_enabled Used to check whether the user turned on the noc
121-
* optimization during placement.
128+
* @param noc_opts Contains information about if the NoC optimization is enabled
129+
* and NoC-related weighting factors.
130+
* @param place_loc_vars Placement block location information. To be filled with the location
131+
* where pl_macro is placed.
122132
*/
123133
void initial_placement(const t_placer_opts& placer_opts,
124134
const char* constraints_file,
@@ -131,12 +141,15 @@ void initial_placement(const t_placer_opts& placer_opts,
131141
* @param blk_id The block that should be placed.
132142
* @param pad_loc_type Used to check whether an io block needs to be marked as fixed.
133143
* @param blk_types_empty_locs_in_grid First location (lowest y) and number of remaining blocks in each column for the blk_id type
134-
*
144+
* @param block_scores Scores assign to different blocks to determine which one should be placed first.
145+
* @param place_loc_vars Placement block location information. To be filled with the location
146+
* where pl_macro is placed.
135147
*
136148
* @return true if the block gets placed, false if not.
137149
*/
138150
bool place_one_block(const ClusterBlockId blk_id,
139-
enum e_pad_loc_type pad_loc_type,
140-
std::vector<t_grid_empty_locs_block_type>* blk_types_empty_locs_in_grid, vtr::vector<ClusterBlockId, t_block_score>* block_scores,
151+
e_pad_loc_type pad_loc_type,
152+
std::vector<t_grid_empty_locs_block_type>* blk_types_empty_locs_in_grid,
153+
vtr::vector<ClusterBlockId, t_block_score>* block_scores,
141154
PlaceLocVars& place_loc_vars);
142155
#endif

vpr/src/place/uniform_move_generator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ e_create_move UniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks
1717
const auto& place_loc_vars = placer_ctx.place_loc_vars();
1818

1919
//Find a movable block based on blk_type
20-
ClusterBlockId b_from = propose_block_to_move(placer_opts, proposed_action.logical_blk_type_index, false, nullptr, nullptr, placer_ctx);
20+
ClusterBlockId b_from = propose_block_to_move(placer_opts,
21+
proposed_action.logical_blk_type_index,
22+
/*highly_crit_block=*/false,
23+
/*net_from=*/nullptr,
24+
/*pin_from=*/nullptr,
25+
placer_ctx);
2126

2227
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Uniform Move Choose Block %d - rlim %f\n", size_t(b_from), rlim);
2328

vpr/src/place/weighted_centroid_move_generator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ e_create_move WeightedCentroidMoveGenerator::propose_move(t_pl_blocks_to_be_move
2020
const auto& place_loc_vars = placer_ctx.place_loc_vars();
2121

2222
//Find a movable block based on blk_type
23-
ClusterBlockId b_from = propose_block_to_move(placer_opts, proposed_action.logical_blk_type_index, false, nullptr, nullptr, placer_ctx);
23+
ClusterBlockId b_from = propose_block_to_move(placer_opts,
24+
proposed_action.logical_blk_type_index,
25+
/*highly_crit_block=*/false,
26+
/*net_from=*/nullptr,
27+
/*pin_from=*/nullptr,
28+
placer_ctx);
2429

2530
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Weighted Centroid Move Choose Block %d - rlim %f\n", size_t(b_from), rlim);
2631

0 commit comments

Comments
 (0)