Skip to content

Commit 41e0879

Browse files
authored
Merge pull request verilog-to-routing#1841 from verilog-to-routing/change_place_flow_in_init_place
Change place flow in init place
2 parents 37d5576 + 4f07114 commit 41e0879

File tree

35 files changed

+1846
-1729
lines changed

35 files changed

+1846
-1729
lines changed

vpr/src/base/echo_files.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void alloc_and_load_echo_file_info() {
122122
setEchoFileName(E_ECHO_ENDPOINT_TIMING, "endpoint_timing.echo.json");
123123
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
124124
setEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA, "rr_indexed_data.echo");
125+
setEchoFileName(E_ECHO_COMPRESSED_GRIDS, "compressed_grids.echo");
125126
}
126127

127128
void free_echo_file_info() {

vpr/src/base/echo_files.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ enum e_echo_files {
5252
E_ECHO_ENDPOINT_TIMING,
5353
E_ECHO_LOOKAHEAD_MAP,
5454
E_ECHO_RR_GRAPH_INDEXED_DATA,
55+
E_ECHO_COMPRESSED_GRIDS,
5556

5657
//Timing Graphs
5758
E_ECHO_PRE_PACKING_TIMING_GRAPH,

vpr/src/place/compressed_grid.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,40 @@ int grid_to_compressed_approx(const std::vector<int>& coords, int point) {
142142
return std::distance(coords.begin(), itr - 1);
143143
return std::distance(coords.begin(), itr);
144144
}
145+
146+
/*Print the contents of the compressed grids to an echo file*/
147+
void echo_compressed_grids(char* filename, const std::vector<t_compressed_block_grid>& comp_grids) {
148+
FILE* fp;
149+
fp = vtr::fopen(filename, "w");
150+
151+
auto& device_ctx = g_vpr_ctx.device();
152+
153+
fprintf(fp, "--------------------------------------------------------------\n");
154+
fprintf(fp, "Compressed Grids: \n");
155+
fprintf(fp, "--------------------------------------------------------------\n");
156+
fprintf(fp, "\n");
157+
158+
for (int i = 0; i < (int)comp_grids.size(); i++) {
159+
fprintf(fp, "\n\nGrid type: %s \n", device_ctx.logical_block_types[i].name);
160+
161+
fprintf(fp, "X coordinates: \n");
162+
for (int j = 0; j < (int)comp_grids[i].compressed_to_grid_x.size(); j++) {
163+
fprintf(fp, "%d ", comp_grids[i].compressed_to_grid_x[j]);
164+
}
165+
fprintf(fp, "\n");
166+
167+
fprintf(fp, "Y coordinates: \n");
168+
for (int k = 0; k < (int)comp_grids[i].compressed_to_grid_y.size(); k++) {
169+
fprintf(fp, "%d ", comp_grids[i].compressed_to_grid_y[k]);
170+
}
171+
fprintf(fp, "\n");
172+
173+
fprintf(fp, "Subtiles: \n");
174+
for (int s = 0; s < (int)comp_grids[i].compatible_sub_tiles_for_tile.size(); s++) {
175+
fprintf(fp, "%d ", comp_grids[i].compressed_to_grid_y[s]);
176+
}
177+
fprintf(fp, "\n");
178+
}
179+
180+
fclose(fp);
181+
}

vpr/src/place/compressed_grid.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,13 @@ int grid_to_compressed(const std::vector<int>& coords, int point);
6464
*/
6565
int grid_to_compressed_approx(const std::vector<int>& coords, int point);
6666

67+
/**
68+
* @brief print the contents of the compressed grids to an echo file
69+
*
70+
* @param filename the name of the file to print to
71+
* @param comp_grids the compressed grids that are used during placement
72+
*
73+
*/
74+
void echo_compressed_grids(char* filename, const std::vector<t_compressed_block_grid>& comp_grids);
75+
6776
#endif

vpr/src/place/initial_placement.cpp

Lines changed: 315 additions & 265 deletions
Large diffs are not rendered by default.

vpr/src/place/move_transactions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ e_block_move_result record_block_move(t_pl_blocks_to_be_moved& blocks_affected,
3636
//Moves the blocks in blocks_affected to their new locations
3737
void apply_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
3838
auto& place_ctx = g_vpr_ctx.mutable_placement();
39+
auto& device_ctx = g_vpr_ctx.device();
3940

4041
//Swap the blocks, but don't swap the nets or update place_ctx.grid_blocks
4142
//yet since we don't know whether the swap will be accepted
4243
for (int iblk = 0; iblk < blocks_affected.num_moved_blocks; ++iblk) {
4344
ClusterBlockId blk = blocks_affected.moved_blocks[iblk].block_num;
4445

4546
place_ctx.block_locs[blk].loc = blocks_affected.moved_blocks[iblk].new_loc;
47+
48+
//if physical tile type of old location does not equal physical tile type of new location, sync the new physical pins
49+
if (device_ctx.grid[blocks_affected.moved_blocks[iblk].old_loc.x][blocks_affected.moved_blocks[iblk].old_loc.y].type != device_ctx.grid[blocks_affected.moved_blocks[iblk].new_loc.x][blocks_affected.moved_blocks[iblk].new_loc.y].type) {
50+
place_sync_external_block_connections(blk);
51+
}
4652
}
4753
}
4854

@@ -78,6 +84,7 @@ void commit_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
7884
//Moves the blocks in blocks_affected to their old locations
7985
void revert_move_blocks(t_pl_blocks_to_be_moved& blocks_affected) {
8086
auto& place_ctx = g_vpr_ctx.mutable_placement();
87+
auto& device_ctx = g_vpr_ctx.device();
8188

8289
// Swap the blocks back, nets not yet swapped they don't need to be changed
8390
for (int iblk = 0; iblk < blocks_affected.num_moved_blocks; ++iblk) {
@@ -87,6 +94,11 @@ void revert_move_blocks(t_pl_blocks_to_be_moved& blocks_affected) {
8794

8895
place_ctx.block_locs[blk].loc = old;
8996

97+
//if physical tile type of old location does not equal physical tile type of new location, sync the new physical pins
98+
if (device_ctx.grid[blocks_affected.moved_blocks[iblk].old_loc.x][blocks_affected.moved_blocks[iblk].old_loc.y].type != device_ctx.grid[blocks_affected.moved_blocks[iblk].new_loc.x][blocks_affected.moved_blocks[iblk].new_loc.y].type) {
99+
place_sync_external_block_connections(blk);
100+
}
101+
90102
VTR_ASSERT_SAFE_MSG(place_ctx.grid_blocks[old.x][old.y].blocks[old.sub_tile] == blk, "Grid blocks should only have been updated if swap commited (not reverted)");
91103
}
92104
}

vpr/src/place/place.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ void try_place(const t_placer_opts& placer_opts,
510510

511511
vtr::ScopedStartFinishTimer timer("Placement");
512512

513-
initial_placement(placer_opts.pad_loc_type,
514-
placer_opts.constraints_file.c_str());
513+
initial_placement(placer_opts.pad_loc_type, placer_opts.constraints_file.c_str());
515514

516515
#ifdef ENABLE_ANALYTIC_PLACE
517516
/*
@@ -912,6 +911,11 @@ void try_place(const t_placer_opts& placer_opts,
912911
}
913912
#endif
914913

914+
// Update physical pin values
915+
for (auto block_id : cluster_ctx.clb_nlist.blocks()) {
916+
place_sync_external_block_connections(block_id);
917+
}
918+
915919
check_place(costs, place_delay_model.get(), placer_criticalities.get(),
916920
placer_opts.place_algorithm);
917921

@@ -1088,10 +1092,10 @@ static void placement_inner_loop(const t_annealing_state* state,
10881092
}
10891093
#ifdef VERBOSE
10901094
VTR_LOG("t = %g cost = %g bb_cost = %g timing_cost = %g move = %d\n",
1091-
t, costs->cost, costs->bb_cost, costs->timing_cost, inner_iter);
1095+
state->t, costs->cost, costs->bb_cost, costs->timing_cost, inner_iter);
10921096
if (fabs((costs->bb_cost) - comp_bb_cost(CHECK)) > (costs->bb_cost) * ERROR_TOL)
1093-
VPR_ERROR(VPR_ERROR_PLACE,
1094-
"fabs((*bb_cost) - comp_bb_cost(CHECK)) > (*bb_cost) * ERROR_TOL");
1097+
VPR_ERROR(VPR_ERROR_PLACE, "bb_cost is %g, comp_bb_cost is %g\n", costs->bb_cost, comp_bb_cost(CHECK));
1098+
//"fabs((*bb_cost) - comp_bb_cost(CHECK)) > (*bb_cost) * ERROR_TOL");
10951099
#endif
10961100

10971101
/* Lines below prevent too much round-off error from accumulating
@@ -1101,8 +1105,10 @@ static void placement_inner_loop(const t_annealing_state* state,
11011105
*/
11021106
++(*moves_since_cost_recompute);
11031107
if (*moves_since_cost_recompute > MAX_MOVES_BEFORE_RECOMPUTE) {
1108+
//VTR_LOG("recomputing costs from scratch, old bb_cost is %g\n", costs->bb_cost);
11041109
recompute_costs_from_scratch(placer_opts, delay_model,
11051110
criticalities, costs);
1111+
//VTR_LOG("new_bb_cost is %g\n", costs->bb_cost);
11061112
*moves_since_cost_recompute = 0;
11071113
}
11081114

@@ -1551,7 +1557,7 @@ static e_move_result try_swap(const t_annealing_state* state,
15511557
//VTR_ASSERT(check_macro_placement_consistency() == 0);
15521558
#if 0
15531559
//Check that each accepted swap yields a valid placement
1554-
check_place(*costs, delay_model, place_algorithm);
1560+
check_place(*costs, delay_model, criticalities, place_algorithm);
15551561
#endif
15561562

15571563
return move_outcome;
@@ -2005,9 +2011,9 @@ static double comp_bb_cost(e_cost_methods method) {
20052011
}
20062012

20072013
if (method == CHECK) {
2008-
VTR_LOG("\n");
2009-
VTR_LOG("BB estimate of min-dist (placement) wire length: %.0f\n",
2010-
expected_wirelength);
2014+
/*VTR_LOG("\n");
2015+
* VTR_LOG("BB estimate of min-dist (placement) wire length: %.0f\n",
2016+
* expected_wirelength);*/
20112017
}
20122018
return cost;
20132019
}
@@ -2313,6 +2319,7 @@ static void get_non_updateable_bb(ClusterNetId net_id, t_bb* bb_coord_new) {
23132319

23142320
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
23152321
pnum = net_pin_to_tile_pin_index(net_id, 0);
2322+
23162323
x = place_ctx.block_locs[bnum].loc.x
23172324
+ physical_tile_type(bnum)->pin_width_offset[pnum];
23182325
y = place_ctx.block_locs[bnum].loc.y

vtr_flow/parse/pass_requirements/common/pass_requirements.vpr_route_min_chan_width.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ routed_wirelength;RangeAbs(0.60,1.50,5)
77
#Area metrics
88
logic_block_area_total;Range(0.8,1.3)
99
logic_block_area_used;Range(0.8,1.3)
10-
min_chan_width_routing_area_total;Range(0.8,1.3)
11-
min_chan_width_routing_area_per_tile;Range(0.8,1.3)
10+
min_chan_width_routing_area_total;Range(0.7,1.3)
11+
min_chan_width_routing_area_per_tile;Range(0.7,1.3)
1212

1313
#Run-time metrics
14-
min_chan_width_route_time;RangeAbs(0.10,10.0,2)
14+
min_chan_width_route_time;RangeAbs(0.10,14.0,2)
1515

1616
#Peak memory
1717
#We set a 100MiB minimum threshold since the memory

vtr_flow/parse/pass_requirements/timing/pass_requirements.vpr_route_relaxed_chan_width.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
crit_path_routed_wirelength;Range(0.60,1.50)
66

77
#Area Metrics
8-
crit_path_routing_area_total;Range(0.8,1.3)
9-
crit_path_routing_area_per_tile;Range(0.8,1.3)
8+
crit_path_routing_area_total;Range(0.7,1.3)
9+
crit_path_routing_area_per_tile;Range(0.7,1.3)
1010

1111
#Run-time Metrics
1212
crit_path_route_time;RangeAbs(0.10,10.0,2)

0 commit comments

Comments
 (0)