Skip to content

Fix 3D SIV Delay & Median Move #2490

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 27 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1667eeb
architecture: fix 3d delay of siv full opin
amin1377 Feb 19, 2024
074b2eb
architecture: (2) fix 3d delay of siv full opin
amin1377 Feb 19, 2024
9262224
architecture: update the readme for 3d arch
amin1377 Feb 19, 2024
ad0c69a
vpr: place: add layer_coord to placer context
amin1377 Feb 20, 2024
125f0b1
vpr: place: initialize layer_coord
amin1377 Feb 20, 2024
a40af3f
vpr: place: update median move generator to get median of layers
amin1377 Feb 20, 2024
bdc1d81
vpr: place: update increamental update of median move to include the …
amin1377 Feb 20, 2024
bebec3c
vpr: place: update weighted median move generator bb calculator to co…
amin1377 Feb 20, 2024
27a3705
vpr: place: update weigted median to get the layer of bbs
amin1377 Feb 20, 2024
0e73635
vpr: place: remove unused variable
amin1377 Feb 20, 2024
cf4ad78
vpr: place: assing valid layer to the centroid location passed to fin…
amin1377 Feb 20, 2024
f7dec22
vpr: placement: fix a typo in assertion
amin1377 Feb 22, 2024
097e881
vpr: placement: (2) fix a typo in assertion
amin1377 Feb 22, 2024
a3c8aae
vpr: place: assign a valid value to layer if it is not valie
amin1377 Feb 23, 2024
d8b4882
vpr: place: update median increamental bb update to take a valid laye…
amin1377 Feb 23, 2024
67a8989
make format
amin1377 Feb 23, 2024
e2da960
vpr: place: update get_bb_from_scratch to keep track of bb layer
amin1377 Feb 23, 2024
755e74d
vpr: place: update get_non_updateable_bb to keep track of layer of bb
amin1377 Feb 23, 2024
26d24d4
vpr: place: update update_bb to keep track of layer
amin1377 Feb 23, 2024
66ef6c6
vpr: place: set valid value of old layer if if it is not valid
amin1377 Feb 23, 2024
6f3ee69
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Feb 26, 2024
46b0700
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 16, 2024
c8506c7
[vpr] apply PR comments
amin1377 May 16, 2024
778f336
[vpr][placement] comment on median move generator
amin1377 May 22, 2024
2fa709e
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 22, 2024
1bc8d77
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 28, 2024
bb4073c
Merge branch 'master' into fix_3d_delay
amin1377 May 29, 2024
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
4 changes: 2 additions & 2 deletions vpr/src/place/centroid_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ e_create_move CentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& block
calculate_centroid_loc(b_from, false, centroid, nullptr);

// Centroid location is not necessarily a valid location, and the downstream location expect a valid
// layer for "to" location. So if the layer is not valid, we set it to the same layer as from loc.
to.layer = (centroid.layer < 0) ? from.layer : centroid.layer;
// layer for the centroid location. So if the layer is not valid, we set it to the same layer as from loc.
centroid.layer = (centroid.layer < 0) ? from.layer : centroid.layer;
/* Find a location near the weighted centroid_loc */
if (!find_to_loc_centroid(cluster_from_type, from, centroid, range_limiters, to, b_from)) {
return e_create_move::ABORT;
Expand Down
135 changes: 107 additions & 28 deletions vpr/src/place/median_move_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
#include "placer_globals.h"
#include "move_utils.h"

static bool get_bb_incrementally(ClusterNetId net_id, t_bb& bb_coord_new, int xold, int yold, int xnew, int ynew);
static bool get_bb_incrementally(ClusterNetId net_id,
t_bb& bb_coord_new,
int xold,
int yold,
int layer_old,
int xnew,
int ynew,
int layer_new);

static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_coord_new, ClusterBlockId block_id, bool& skip_net);

Expand All @@ -29,7 +36,7 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
auto& place_move_ctx = g_placer_ctx.mutable_move();

const int num_layers = device_ctx.grid.get_num_layers();
bool is_multi_layer = (num_layers > 1);


t_pl_loc from = place_ctx.block_locs[b_from].loc;
int from_layer = from.layer;
Expand All @@ -43,12 +50,13 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
t_bb coords(OPEN, OPEN, OPEN, OPEN, OPEN, OPEN);
t_bb limit_coords;
ClusterBlockId bnum;
int pnum, xnew, xold, ynew, yold;
int pnum, xnew, xold, ynew, yold, layer_new, layer_old;

//clear the vectors that saves X & Y coords
//reused to save allocation time
place_move_ctx.X_coord.clear();
place_move_ctx.Y_coord.clear();
place_move_ctx.layer_coord.clear();
std::vector<int> layer_blk_cnt(num_layers, 0);

//true if the net is a feedback from the block to itself
Expand Down Expand Up @@ -84,8 +92,11 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
VTR_ASSERT(pnum >= 0);
xold = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
yold = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
layer_old = place_ctx.block_locs[bnum].loc.layer;

xold = std::max(std::min(xold, (int)device_ctx.grid.width() - 2), 1); //-2 for no perim channels
yold = std::max(std::min(yold, (int)device_ctx.grid.height() - 2), 1); //-2 for no perim channels
layer_old = std::max(std::min(layer_old, (int)device_ctx.grid.get_num_layers() - 1), 0);

//To calulate the bb incrementally while excluding the moving block
//assume that the moving block is moved to a non-critical coord of the bb
Expand All @@ -101,7 +112,20 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
ynew = net_bb_coords.ymin;
}

if (!get_bb_incrementally(net_id, coords, xold, yold, xnew, ynew)) {
if (net_bb_coords.layer_min == layer_old) {
layer_new = net_bb_coords.layer_max;
} else {
layer_new = net_bb_coords.layer_min;
}

if (!get_bb_incrementally(net_id,
coords,
xold,
yold,
layer_old,
xnew,
ynew,
layer_new)) {
get_bb_from_scratch_excluding_block(net_id, coords, b_from, skip_net);
if (skip_net)
continue;
Expand All @@ -112,34 +136,29 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
place_move_ctx.X_coord.push_back(coords.xmax);
place_move_ctx.Y_coord.push_back(coords.ymin);
place_move_ctx.Y_coord.push_back(coords.ymax);
if (is_multi_layer) {
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
layer_blk_cnt[layer_num] += place_move_ctx.num_sink_pin_layer[size_t(net_id)][layer_num];
}
// If the pin under consideration is of type sink, it shouldn't be added to layer_blk_cnt since the block
// is moving
if (cluster_ctx.clb_nlist.pin_type(pin_id) == PinType::SINK) {
VTR_ASSERT_SAFE(layer_blk_cnt[from_layer] > 0);
layer_blk_cnt[from_layer]--;
}
}
place_move_ctx.layer_coord.push_back(coords.layer_min);
place_move_ctx.layer_coord.push_back(coords.layer_max);
}

if ((place_move_ctx.X_coord.empty()) || (place_move_ctx.Y_coord.empty())) {
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\tMove aborted - X_coord and y_coord are empty\n");
if ((place_move_ctx.X_coord.empty()) || (place_move_ctx.Y_coord.empty()) || (place_move_ctx.layer_coord.empty())) {
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\tMove aborted - X_coord or y_coord or layer_coord are empty\n");
return e_create_move::ABORT;
}

//calculate the median region
std::sort(place_move_ctx.X_coord.begin(), place_move_ctx.X_coord.end());
std::sort(place_move_ctx.Y_coord.begin(), place_move_ctx.Y_coord.end());
std::sort(place_move_ctx.layer_coord.begin(), place_move_ctx.layer_coord.end());

limit_coords.xmin = place_move_ctx.X_coord[floor((place_move_ctx.X_coord.size() - 1) / 2)];
limit_coords.xmax = place_move_ctx.X_coord[floor((place_move_ctx.X_coord.size() - 1) / 2) + 1];

limit_coords.ymin = place_move_ctx.Y_coord[floor((place_move_ctx.Y_coord.size() - 1) / 2)];
limit_coords.ymax = place_move_ctx.Y_coord[floor((place_move_ctx.Y_coord.size() - 1) / 2) + 1];

limit_coords.layer_min = place_move_ctx.layer_coord[floor((place_move_ctx.layer_coord.size() - 1) / 2)];
limit_coords.layer_max = place_move_ctx.layer_coord[floor((place_move_ctx.layer_coord.size() - 1) / 2) + 1];

//arrange the different range limiters
t_range_limiters range_limiters{rlim,
place_move_ctx.first_rlim,
Expand All @@ -149,17 +168,8 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
t_pl_loc median_point;
median_point.x = (limit_coords.xmin + limit_coords.xmax) / 2;
median_point.y = (limit_coords.ymin + limit_coords.ymax) / 2;
median_point.layer = (limit_coords.layer_min + limit_coords.layer_max) / 2;

// Before calling find_to_loc_centroid a valid layer should be assigned to "to" location. If there are multiple layers, the layer
// with highest number of sinks will be used. Otherwise, the same layer as "from" loc is assigned.
if (is_multi_layer) {
int layer_num = std::distance(layer_blk_cnt.begin(), std::max_element(layer_blk_cnt.begin(), layer_blk_cnt.end()));
median_point.layer = layer_num;
to.layer = layer_num;
} else {
median_point.layer = from.layer;
to.layer = from.layer;
}
if (!find_to_loc_centroid(cluster_from_type, from, median_point, range_limiters, to, b_from)) {
return e_create_move::ABORT;
}
Expand Down Expand Up @@ -194,6 +204,9 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
int ymin = OPEN;
int ymax = OPEN;

int layer_min = OPEN;
int layer_max = OPEN;

int pnum;

auto& cluster_ctx = g_vpr_ctx.clustering();
Expand All @@ -208,11 +221,14 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
pnum = net_pin_to_tile_pin_index(net_id, 0);
int src_x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
int src_y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
int src_layer = place_ctx.block_locs[bnum].loc.layer;

xmin = src_x;
ymin = src_y;
xmax = src_x;
ymax = src_y;
layer_min = src_layer;
layer_max = src_layer;
first_block = true;
}

Expand All @@ -225,12 +241,15 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
const auto& block_loc = place_ctx.block_locs[bnum].loc;
int x = block_loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
int y = block_loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
int layer = block_loc.layer;

if (!first_block) {
xmin = x;
ymin = y;
xmax = x;
ymax = y;
layer_max = layer;
layer_min = layer;
first_block = true;
continue;
}
Expand All @@ -245,6 +264,12 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
} else if (y > ymax) {
ymax = y;
}

if (layer < layer_min) {
layer_min = layer;
} else if (layer > layer_max) {
layer_max = layer;
}
}

/* Now I've found the coordinates of the bounding box. There are no *
Expand All @@ -256,8 +281,10 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
* is 0). See route_common.cpp for a channel diagram. */
bb_coord_new.xmin = std::max(std::min<int>(xmin, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
bb_coord_new.ymin = std::max(std::min<int>(ymin, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
bb_coord_new.layer_min = std::max(std::min<int>(layer_min, device_ctx.grid.get_num_layers() - 1), 0);
bb_coord_new.xmax = std::max(std::min<int>(xmax, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
bb_coord_new.ymax = std::max(std::min<int>(ymax, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
bb_coord_new.layer_max = std::max(std::min<int>(layer_max, device_ctx.grid.get_num_layers() - 1), 0);
}

/*
Expand All @@ -273,16 +300,26 @@ static void get_bb_from_scratch_excluding_block(ClusterNetId net_id, t_bb& bb_co
* the pins always lie on the outside of the bounding box. *
* The x and y coordinates are the pin's x and y coordinates. */
/* IO blocks are considered to be one cell in for simplicity. */
static bool get_bb_incrementally(ClusterNetId net_id, t_bb& bb_coord_new, int xold, int yold, int xnew, int ynew) {
static bool get_bb_incrementally(ClusterNetId net_id,
t_bb& bb_coord_new,
int xold,
int yold,
int layer_old,
int xnew,
int ynew,
int layer_new) {
//TODO: account for multiple physical pin instances per logical pin

auto& device_ctx = g_vpr_ctx.device();
auto& place_move_ctx = g_placer_ctx.move();

xnew = std::max(std::min<int>(xnew, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
ynew = std::max(std::min<int>(ynew, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
layer_new = std::max(std::min<int>(layer_new, device_ctx.grid.get_num_layers() - 1), 0);

xold = std::max(std::min<int>(xold, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
yold = std::max(std::min<int>(yold, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
layer_old = std::max(std::min<int>(layer_old, device_ctx.grid.get_num_layers() - 1), 0);

t_bb union_bb_edge;
t_bb union_bb;
Expand Down Expand Up @@ -410,5 +447,47 @@ static bool get_bb_incrementally(ClusterNetId net_id, t_bb& bb_coord_new, int xo
bb_coord_new.ymin = curr_bb_coord.ymin;
bb_coord_new.ymax = curr_bb_coord.ymax;
}

if (layer_new < layer_old) {
if (layer_old == curr_bb_coord.layer_max) {
if (curr_bb_edge.layer_max == 1) {
return false;
} else {
bb_coord_new.layer_max = curr_bb_coord.layer_max;
}
} else {
bb_coord_new.layer_max = curr_bb_coord.layer_max;
}

if (layer_new < curr_bb_coord.layer_min) {
bb_coord_new.layer_min = layer_new;
} else if (layer_new == curr_bb_coord.layer_min) {
bb_coord_new.layer_min = layer_new;
} else {
bb_coord_new.layer_min = curr_bb_coord.layer_min;
}

} else if (layer_new > layer_old) {
if (layer_old == curr_bb_coord.layer_min) {
if (curr_bb_edge.layer_min == 1) {
return false;
} else {
bb_coord_new.layer_min = curr_bb_coord.layer_min;
}
} else {
bb_coord_new.layer_min = curr_bb_coord.layer_min;
}

if (layer_new > curr_bb_coord.layer_max) {
bb_coord_new.layer_max = layer_new;
} else if (layer_new == curr_bb_coord.layer_max) {
bb_coord_new.layer_max = layer_new;
} else {
bb_coord_new.layer_max = curr_bb_coord.layer_max;
}
} else {
bb_coord_new.layer_min = curr_bb_coord.layer_min;
bb_coord_new.layer_max = curr_bb_coord.layer_max;
}
return true;
}
2 changes: 1 addition & 1 deletion vpr/src/place/move_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
ClusterBlockId b_from) {
//Retrieve the compressed block grid for this block type
const auto& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[blk_type->index];
const int to_layer_num = to_loc.layer;
const int to_layer_num = centroid.layer;
VTR_ASSERT(to_layer_num >= 0);
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();

Expand Down
2 changes: 2 additions & 0 deletions vpr/src/place/move_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ struct t_bb_cost {
t_edge_cost xmax = {0, 0.0};
t_edge_cost ymin = {0, 0.0};
t_edge_cost ymax = {0, 0.0};
t_edge_cost layer_min = {0, 0.};
t_edge_cost layer_max = {0, 0.};
};

/**
Expand Down
Loading