Skip to content

Floorplanning during place moves #1704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b13814b
Added floorplan constraint checks to the placement move generators
sfkhalid Apr 7, 2021
1c4d515
added comments and changed cluster_floorplanning_check -> cluster_flo…
sfkhalid Apr 8, 2021
88bc674
Took out commented code
sfkhalid Apr 8, 2021
9009b6c
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid Apr 14, 2021
9e84342
Created a helper function (floorplan_legal) to check the floorplannin…
sfkhalid Apr 14, 2021
2c12618
Ran make format
sfkhalid Apr 14, 2021
c124415
Merge 'floorplanning_during_place_moves' of https://github.com/verilo…
sfkhalid Apr 14, 2021
79378a4
Added ability to write our constraints XML files after placement
sfkhalid Apr 22, 2021
77d32e7
removed extra code in write_place_constraints
sfkhalid Apr 27, 2021
5efca5a
Changed serializer file to write using contexts
sfkhalid Apr 28, 2021
fbe99b5
Locking down blocks to each place
sfkhalid Apr 29, 2021
ebfbc75
Added expand and subtile options
sfkhalid Apr 29, 2021
0f910b8
Made minor change to serializer file to get rid of compiler warnings
sfkhalid Apr 29, 2021
c8fef8e
Made subtile option a bool
sfkhalid Apr 29, 2021
26ba44f
Fixed issue where long atom and partition names were not being printe…
sfkhalid May 4, 2021
c8b2a6b
Fixed issue where subtile value would not be printed if it was zero
sfkhalid May 5, 2021
7b2674d
Added comments and did minor function refactoring to routines related…
sfkhalid May 5, 2021
f3d08c4
Removed some unneeded code and changed some function parameters to co…
sfkhalid May 5, 2021
2e7b05d
Added a lookup for which atoms are in a cluster in clustered_netlist_…
sfkhalid May 6, 2021
4c50e8b
Add comment to describe loop that fills in constraints object for wri…
sfkhalid May 6, 2021
76458b5
Merge branch 'master' into floorplanning_during_place_moves
vaughnbetz May 6, 2021
b352690
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 6, 2021
efc2dec
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 9, 2021
1e80b92
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 10, 2021
7df3f45
Commented ClusterAtomsLookup class
sfkhalid May 10, 2021
cbf5a1c
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 11, 2021
8376186
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 12, 2021
6371351
Merge branch 'master' into floorplanning_during_place_moves
sfkhalid May 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion vpr/src/place/centroid_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "vpr_types.h"
#include "globals.h"
#include "directed_moves_util.h"
#include "place_constraints.h"

e_create_move CentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected, e_move_type& /*move_type*/, float rlim, const t_placer_opts& placer_opts, const PlacerCriticalities* /*criticalities*/) {
/* Pick a random block to be swapped with another random block. */
Expand Down Expand Up @@ -35,5 +36,19 @@ e_create_move CentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& block
return e_create_move::ABORT;
}

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}
17 changes: 16 additions & 1 deletion vpr/src/place/critical_uniform_move_generator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "critical_uniform_move_generator.h"
#include "globals.h"
#include "place_constraints.h"

e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected, e_move_type& /*move_type*/, float rlim, const t_placer_opts& /*placer_opts*/, const PlacerCriticalities* /*criticalities*/) {
auto& place_ctx = g_vpr_ctx.placement();
Expand Down Expand Up @@ -33,5 +34,19 @@ e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved
return e_create_move::ABORT;
}

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}
17 changes: 16 additions & 1 deletion vpr/src/place/feasible_region_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "globals.h"
#include <algorithm>
#include "math.h"
#include "place_constraints.h"

e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected, e_move_type& /*move_type*/, float rlim, const t_placer_opts& placer_opts, const PlacerCriticalities* criticalities) {
auto& place_ctx = g_vpr_ctx.placement();
Expand Down Expand Up @@ -122,5 +123,19 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
return e_create_move::ABORT;
}

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}
2 changes: 1 addition & 1 deletion vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void initial_placement_blocks(std::vector<std::vector<int>>& free_locatio
// Make sure that the position is EMPTY_BLOCK before placing the block down
VTR_ASSERT(place_ctx.grid_blocks[to.x][to.y].blocks[to.sub_tile] == EMPTY_BLOCK_ID);

bool floorplan_good = cluster_floorplanning_check(blk_id, to);
bool floorplan_good = cluster_floorplanning_legal(blk_id, to);

if (floorplan_good) {
place_ctx.grid_blocks[to.x][to.y].blocks[to.sub_tile] = blk_id;
Expand Down
18 changes: 16 additions & 2 deletions vpr/src/place/median_move_generator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "median_move_generator.h"
#include "globals.h"
#include <algorithm>

#include "place_constraints.h"
#include "placer_globals.h"

static bool get_bb_incrementally(ClusterNetId net_id, t_bb* bb_coord_new, int xold, int yold, int xnew, int ynew);
Expand Down Expand Up @@ -122,7 +122,21 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
if (!find_to_loc_centroid(cluster_from_type, from, median_point, range_limiters, to))
return e_create_move::ABORT;

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}

/* Finds the bounding box of a net and stores its coordinates in the *
Expand Down
8 changes: 3 additions & 5 deletions vpr/src/place/move_transactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
/* Stores the information of the move for a block that is *
* moved during placement *
* block_num: the index of the moved block *
* xold: the x_coord that the block is moved from *
* xnew: the x_coord that the block is moved to *
* yold: the y_coord that the block is moved from *
* xnew: the x_coord that the block is moved to */
* old_loc: the location the block is moved from *
* new_loc: the location the block is moved to */
struct t_pl_moved_block {
ClusterBlockId block_num;
t_pl_loc old_loc;
Expand All @@ -26,7 +24,7 @@ struct t_pl_moved_block {
* swapping two blocks. *
* moved blocks: a list of moved blocks data structure with *
* information on the move. *
* [0...num_moved_blocks-1] *
* [0...max_blocks-1] *
* affected_pins: pins affected by this move (used to *
* incrementally invalidate parts of the timing *
* graph. */
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/place/place_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ int check_placement_floorplanning() {
auto& place_ctx = g_vpr_ctx.placement();

for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
auto& loc = place_ctx.block_locs[blk_id].loc;
if (!cluster_floorplanning_check(blk_id, loc)) {
auto loc = place_ctx.block_locs[blk_id].loc;
if (!cluster_floorplanning_legal(blk_id, loc)) {
error++;
VTR_LOG_ERROR("Block %zu is not in correct floorplanning region.\n", size_t(blk_id));
}
Expand Down Expand Up @@ -114,7 +114,7 @@ PartitionRegion constrained_macro_locs(t_pl_macro pl_macro) {
}

/*returns true if location is compatible with floorplanning constraints, false if not*/
bool cluster_floorplanning_check(ClusterBlockId blk_id, t_pl_loc loc) {
bool cluster_floorplanning_legal(ClusterBlockId blk_id, t_pl_loc& loc) {
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();

bool floorplanning_good = false;
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/place/place_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool is_cluster_constrained(ClusterBlockId blk_id);
/*
* Check if the placement location would respect floorplan constraints of the block, if it has any
*/
bool cluster_floorplanning_check(ClusterBlockId blk_id, t_pl_loc loc);
bool cluster_floorplanning_legal(ClusterBlockId blk_id, t_pl_loc& loc);

/*
* Check whether any member of the macro has floorplan constraints
Expand Down
17 changes: 16 additions & 1 deletion vpr/src/place/uniform_move_generator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "uniform_move_generator.h"
#include "globals.h"
#include "place_constraints.h"

e_create_move UniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected, e_move_type& /*move_type*/, float rlim, const t_placer_opts& /*placer_opts*/, const PlacerCriticalities* /*criticalities*/) {
/* Pick a random block to be swapped with another random block. */
Expand Down Expand Up @@ -34,5 +35,19 @@ e_create_move UniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks
VTR_LOG("\n");
#endif

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}
17 changes: 16 additions & 1 deletion vpr/src/place/weighted_centroid_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "globals.h"
#include <algorithm>
#include "directed_moves_util.h"
#include "place_constraints.h"

e_create_move WeightedCentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected, e_move_type& /*move_type*/, float rlim, const t_placer_opts& placer_opts, const PlacerCriticalities* criticalities) {
/* Pick a random block to be swapped with another random block. */
Expand Down Expand Up @@ -35,5 +36,19 @@ e_create_move WeightedCentroidMoveGenerator::propose_move(t_pl_blocks_to_be_move
return e_create_move::ABORT;
}

return ::create_move(blocks_affected, b_from, to);
e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}
19 changes: 18 additions & 1 deletion vpr/src/place/weighted_median_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "globals.h"
#include <algorithm>
#include "math.h"
#include "place_constraints.h"

#define CRIT_MULT_FOR_W_MEDIAN 10

Expand Down Expand Up @@ -101,7 +102,23 @@ e_create_move WeightedMedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
if (!find_to_loc_centroid(cluster_from_type, from, w_median_point, range_limiters, to)) {
return e_create_move::ABORT;
}
return ::create_move(blocks_affected, b_from, to);
//return ::create_move(blocks_affected, b_from, to);

e_create_move create_move;
create_move = ::create_move(blocks_affected, b_from, to);

//Check if the move is legal from a floorplan perspective
//Check that all of the blocks affected by the move would still be in a legal floorplan region after the swap
bool floorplan_legal = true;
for (int i = 0; i < blocks_affected.num_moved_blocks; i++) {
floorplan_legal = cluster_floorplanning_legal(blocks_affected.moved_blocks[i].block_num, blocks_affected.moved_blocks[i].new_loc);
if (!floorplan_legal) {
VTR_LOG("Move aborted for block %zu, location tried was x: %d, y: %d, subtile: %d \n", size_t(blocks_affected.moved_blocks[i].block_num), blocks_affected.moved_blocks[i].new_loc.x, blocks_affected.moved_blocks[i].new_loc.y, blocks_affected.moved_blocks[i].new_loc.sub_tile);
return e_create_move::ABORT;
}
}

return create_move;
}

/**
Expand Down