-
Notifications
You must be signed in to change notification settings - Fork 415
Chan z prefix sum #2781
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
Chan z prefix sum #2781
Changes from 11 commits
400b5a1
4018188
0432740
11ee10f
8bead96
bea400e
01b9cd6
af5659d
736d826
1a3e56d
54fe8d7
df4159b
21c62d8
da92578
052d6b9
e15a796
f2939b1
e213fa1
a0b2c06
6ea8921
596ddaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,10 +149,11 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts, | |
* been recomputed. */ | ||
bb_update_status_.resize(num_nets, NetUpdateState::NOT_UPDATED_YET); | ||
|
||
alloc_and_load_chan_w_factors_for_place_cost_(placer_opts_.place_cost_exp); | ||
alloc_and_load_chan_w_factors_for_place_cost_(); | ||
} | ||
|
||
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_cost_exp) { | ||
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_() { | ||
float place_cost_exp = placer_opts_.place_cost_exp; | ||
auto& device_ctx = g_vpr_ctx.device(); | ||
|
||
const int grid_height = device_ctx.grid.height(); | ||
|
@@ -229,22 +230,32 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c | |
} | ||
|
||
if (device_ctx.grid.get_num_layers() > 1) { | ||
alloc_and_load_for_fast_vertical_cost_update_(place_cost_exp); | ||
alloc_and_load_for_fast_vertical_cost_update_(); | ||
} | ||
} | ||
|
||
void NetCostHandler::alloc_and_load_for_fast_vertical_cost_update_(float place_cost_exp) { | ||
void NetCostHandler::alloc_and_load_for_fast_vertical_cost_update_() { | ||
const auto& device_ctx = g_vpr_ctx.device(); | ||
const auto& rr_graph = device_ctx.rr_graph; | ||
|
||
const size_t grid_height = device_ctx.grid.height(); | ||
const size_t grid_width = device_ctx.grid.width(); | ||
|
||
|
||
chanz_place_cost_fac_ = vtr::NdMatrix<float, 4>({grid_width, grid_height, grid_width, grid_height}, 0.); | ||
acc_tile_num_inter_die_conn_ = vtr::NdMatrix<int, 2>({grid_width, grid_height}, 0.); | ||
|
||
vtr::NdMatrix<float, 2> tile_num_inter_die_conn({grid_width, grid_height}, 0.); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a count, so int is probably better. Float could have some round-off issues with big chips, as this matrix is filled in by adding small numbers to a running count, which can get problematic if the big number ever becomes more than 16 million times or so bigger than the small number (the small number then gets thrown away by round off). |
||
|
||
/* | ||
* To calculate the accumulative number of inter-die connections we first need to get the number of | ||
* inter-die connection per loaction. To be able to work for the cases that RR Graph is read instead | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* of being made from the architecture file, we calculate this number by iterating over RR graph. Once | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* tile_num_inter_die_conn is populated, we can start populating acc_tile_num_inter_die_conn_. First, | ||
* we populate the first row and column. Then, we iterate over the rest of blocks and get the number of | ||
* inter-die connections by adding up the number of inter-die block at that location + the accumulative | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* for the block below and left to it. Then, since the accumulative number of inter-die connection to | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* the block on the lower left connection of the block is added twice, that part needs to be removed. | ||
*/ | ||
for (const auto& src_rr_node : rr_graph.nodes()) { | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (const auto& rr_edge_idx : rr_graph.configurable_edges(src_rr_node)) { | ||
const auto& sink_rr_node = rr_graph.edge_sink_node(src_rr_node, rr_edge_idx); | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -271,24 +282,24 @@ void NetCostHandler::alloc_and_load_for_fast_vertical_cost_update_(float place_c | |
} | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
for (int x_high = 0; x_high < (int)device_ctx.grid.width(); x_high++) { | ||
for (int y_high = 0; y_high < (int)device_ctx.grid.height(); y_high++) { | ||
for (int x_low = 0; x_low <= x_high; x_low++) { | ||
for (int y_low = 0; y_low <= y_high; y_low++) { | ||
int num_inter_die_conn = 0; | ||
for (int x = x_low; x <= x_high; x++) { | ||
for (int y = y_low; y <= y_high; y++) { | ||
num_inter_die_conn += tile_num_inter_die_conn[x][y]; | ||
} | ||
} | ||
int seen_num_tiles = (x_high - x_low + 1) * (y_high - y_low + 1); | ||
chanz_place_cost_fac_[x_high][y_high][x_low][y_low] = seen_num_tiles / static_cast<float>(num_inter_die_conn); | ||
|
||
chanz_place_cost_fac_[x_high][y_high][x_low][y_low] = pow( | ||
(double)chanz_place_cost_fac_[x_high][y_high][x_low][y_low], | ||
(double)place_cost_exp); | ||
} | ||
} | ||
acc_tile_num_inter_die_conn_[0][0] = tile_num_inter_die_conn[0][0]; | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Initialize the first row and column | ||
for (size_t x = 1; x < device_ctx.grid.width(); x++) { | ||
acc_tile_num_inter_die_conn_[x][0] = acc_tile_num_inter_die_conn_[x-1][0] + \ | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tile_num_inter_die_conn[x][0]; | ||
} | ||
|
||
for (size_t y = 1; y < device_ctx.grid.height(); y++) { | ||
acc_tile_num_inter_die_conn_[0][y] = acc_tile_num_inter_die_conn_[0][y-1] + \ | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tile_num_inter_die_conn[0][y]; | ||
} | ||
|
||
for (size_t x_high = 1; x_high < device_ctx.grid.width(); x_high++) { | ||
for (size_t y_high = 1; y_high < device_ctx.grid.height(); y_high++) { | ||
acc_tile_num_inter_die_conn_[x_high][y_high] = acc_tile_num_inter_die_conn_[x_high-1][y_high] + \ | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
acc_tile_num_inter_die_conn_[x_high][y_high-1] + \ | ||
tile_num_inter_die_conn[x_high][y_high] - \ | ||
acc_tile_num_inter_die_conn_[x_high-1][y_high-1]; | ||
} | ||
} | ||
} | ||
|
@@ -1478,7 +1489,7 @@ double NetCostHandler::get_net_cube_bb_cost_(ClusterNetId net_id, bool use_ts) { | |
ncost = (bb.xmax - bb.xmin + 1) * crossing * chanx_place_cost_fac_[bb.ymax][bb.ymin - 1]; | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ncost += (bb.ymax - bb.ymin + 1) * crossing * chany_place_cost_fac_[bb.xmax][bb.xmin - 1]; | ||
if (is_multi_layer) { | ||
ncost += (bb.layer_max - bb.layer_min) * crossing * chanz_place_cost_fac_[bb.xmax][bb.ymax][bb.xmin][bb.ymin]; | ||
ncost += (bb.layer_max - bb.layer_min) * crossing * get_chanz_cost_factor(bb); | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return ncost; | ||
|
@@ -1581,6 +1592,44 @@ double NetCostHandler::get_net_wirelength_from_layer_bb_(ClusterNetId net_id) { | |
return ncost; | ||
} | ||
|
||
float NetCostHandler::get_chanz_cost_factor(const t_bb& bounding_box) { | ||
float place_cost_exp = placer_opts_.place_cost_exp; | ||
int x_high = bounding_box.xmax; | ||
int x_low = bounding_box.xmin; | ||
int y_high = bounding_box.ymax; | ||
int y_low = bounding_box.ymin; | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
int num_inter_dir_conn; | ||
|
||
if (x_low == 0 && y_low == 0) { | ||
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high]; | ||
} else if (x_low == 0) { | ||
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \ | ||
acc_tile_num_inter_die_conn_[x_high][y_low-1]; | ||
} else if (y_low == 0) { | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \ | ||
acc_tile_num_inter_die_conn_[x_low-1][y_high]; | ||
} else { | ||
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \ | ||
acc_tile_num_inter_die_conn_[x_low-1][y_high] - \ | ||
acc_tile_num_inter_die_conn_[x_high][y_low-1] + \ | ||
acc_tile_num_inter_die_conn_[x_low-1][y_low-1]; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that would be cleaner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @soheilshahrouz, if you remember, my initial attempt was to use this data structure, but I encountered some memory issues with it. I’ll create an issue for this and, in another PR, attempt to replace this data structure with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I figured out what the problem was. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I'll try it once the PR is merged. |
||
|
||
int bb_num_tiles = (x_high - x_low + 1) * (y_high - y_low + 1); | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
float z_cost_factor; | ||
if (num_inter_dir_conn == 0) { | ||
return 1.0f; | ||
} else { | ||
z_cost_factor = bb_num_tiles / static_cast<float>(num_inter_dir_conn); | ||
z_cost_factor = pow((double)z_cost_factor, (double)place_cost_exp); | ||
} | ||
|
||
return z_cost_factor; | ||
|
||
} | ||
|
||
double NetCostHandler::recompute_bb_cost_() { | ||
double cost = 0; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.