Skip to content

Commit f520da9

Browse files
Merge branch 'master' into diff_switches_for_inc_dec_wires
2 parents a48ed5f + 49de5fb commit f520da9

29 files changed

+613
-539
lines changed

.github/workflows/nightly_test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
name: NightlyTest
22

33
on:
4+
# We want to run the CI when anything is pushed to master.
5+
# Since master is a protected branch this only happens when a PR is merged.
6+
# This is a double check in case the PR was stale and had some issues.
7+
push:
8+
branches:
9+
- master
10+
paths-ignore: # Prevents from running if only docs are updated
11+
- 'doc/**'
12+
- '**/*README*'
13+
- '**.md'
14+
- '**.rst'
15+
pull_request:
16+
paths-ignore: # Prevents from running if only docs are updated
17+
- 'doc/**'
18+
- '**/*README*'
19+
- '**.md'
20+
- '**.rst'
21+
workflow_dispatch:
422
schedule:
523
- cron: '0 0 * * *' # daily
624

doc/src/vpr/command_line_usage.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,15 @@ The following options are only valid when the router is in timing-driven mode (t
13061306

13071307
**Default:** ``1.2``
13081308

1309+
.. option:: --astar_offset <float>
1310+
1311+
Sets how aggressive the directed search used by the timing-driven router is.
1312+
It is a subtractive adjustment to the lookahead heuristic.
1313+
1314+
Values between 0 and 1e-9 are resonable; higher values may increase quality at the expense of run-time.
1315+
1316+
**Default:** ``0.0``
1317+
13091318
.. option:: --router_profiler_astar_fac <float>
13101319

13111320
Controls the directedness of the timing-driven router's exploration when doing router delay profiling of an architecture.

vpr/src/base/SetupVPR.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ static void SetupRoutingArch(const t_arch& Arch,
423423
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
424424
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
425425
RouterOpts->astar_fac = Options.astar_fac;
426+
RouterOpts->astar_offset = Options.astar_offset;
426427
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
427428
RouterOpts->bb_factor = Options.bb_factor;
428429
RouterOpts->criticality_exp = Options.criticality_exp;
@@ -639,6 +640,8 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)
639640

640641
PlacerOpts->write_initial_place_file = Options.write_initial_place_file;
641642

643+
PlacerOpts->read_initial_place_file = Options.read_initial_place_file;
644+
642645
PlacerOpts->pad_loc_type = Options.pad_loc_type;
643646

644647
PlacerOpts->place_chan_width = Options.PlaceChanWidth;

vpr/src/base/ShowSetup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
382382

383383
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
384384
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
385+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
385386
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
386387
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
387388
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
@@ -735,4 +736,4 @@ static void ShowNocOpts(const t_noc_opts& NocOpts) {
735736
VTR_LOG("NocOpts.noc_sat_routing_num_workers: %d\n", NocOpts.noc_sat_routing_num_workers);
736737
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_placement_file_name.c_str());
737738
VTR_LOG("\n");
738-
}
739+
}

vpr/src/base/read_options.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
16321632
.metavar("INITIAL_PLACE_FILE")
16331633
.show_in(argparse::ShowIn::HELP_ONLY);
16341634

1635+
file_grp.add_argument(args.read_initial_place_file, "--read_initial_place_file")
1636+
.help("Reads the initial placement and continues the rest of the placement process from there.")
1637+
.metavar("INITIAL_PLACE_FILE")
1638+
.show_in(argparse::ShowIn::HELP_ONLY);
1639+
16351640
file_grp.add_argument(args.read_vpr_constraints_file, "--read_vpr_constraints")
16361641
.help("Reads the floorplanning constraints that packing and placement must respect from the specified XML file.")
16371642
.show_in(argparse::ShowIn::HELP_ONLY);
@@ -2499,6 +2504,14 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
24992504
.default_value("1.2")
25002505
.show_in(argparse::ShowIn::HELP_ONLY);
25012506

2507+
route_timing_grp.add_argument(args.astar_offset, "--astar_offset")
2508+
.help(
2509+
"Controls the directedness of the timing-driven router's exploration."
2510+
" It is a subtractive adjustment to the lookahead heuristic."
2511+
" Values between 0 and 1e-9 are resonable; higher values may increase quality at the expense of run-time.")
2512+
.default_value("0.0")
2513+
.show_in(argparse::ShowIn::HELP_ONLY);
2514+
25022515
route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
25032516
.help(
25042517
"Controls the directedness of the timing-driven router's exploration"

vpr/src/base/read_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct t_options {
2929
argparse::ArgValue<std::string> write_rr_graph_file;
3030
argparse::ArgValue<std::string> read_rr_graph_file;
3131
argparse::ArgValue<std::string> write_initial_place_file;
32+
argparse::ArgValue<std::string> read_initial_place_file;
3233
argparse::ArgValue<std::string> read_vpr_constraints_file;
3334
argparse::ArgValue<std::string> write_vpr_constraints_file;
3435
argparse::ArgValue<std::string> write_constraints_file;
@@ -220,6 +221,7 @@ struct t_options {
220221

221222
/* Timing-driven router options only */
222223
argparse::ArgValue<float> astar_fac;
224+
argparse::ArgValue<float> astar_offset;
223225
argparse::ArgValue<float> router_profiler_astar_fac;
224226
argparse::ArgValue<float> max_criticality;
225227
argparse::ArgValue<float> criticality_exp;

vpr/src/base/read_place.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ void read_place_body(std::ifstream& placement_file,
305305
loc.layer = block_layer;
306306

307307
if (seen_blocks[blk_id] == 0) {
308+
if (is_place_file && place_ctx.block_locs[blk_id].is_fixed) {
309+
const auto& contraint_loc = place_ctx.block_locs[blk_id].loc;
310+
if (loc != contraint_loc) {
311+
VPR_THROW(VPR_ERROR_PLACE,
312+
"The new location assigned to cluster #%d is (%d,%d,%d,%d), which is inconsistent with the location specified in the constraint file (%d,%d,%d,%d).",
313+
blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, contraint_loc.x, contraint_loc.y, contraint_loc.layer, contraint_loc.sub_tile);
314+
}
315+
}
308316
set_block_location(blk_id, loc);
309317
}
310318

vpr/src/base/vpr_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ struct t_placer_opts {
12361236
enum e_pad_loc_type pad_loc_type;
12371237
std::string constraints_file;
12381238
std::string write_initial_place_file;
1239+
std::string read_initial_place_file;
12391240
enum pfreq place_freq;
12401241
int recompute_crit_iter;
12411242
int inner_loop_recompute_divider;
@@ -1343,6 +1344,8 @@ struct t_placer_opts {
13431344
* an essentially breadth-first search, astar_fac = 1 is near *
13441345
* the usual astar algorithm and astar_fac > 1 are more *
13451346
* aggressive. *
1347+
* astar_offset: Offset that is subtracted from the lookahead (expected *
1348+
* future costs) in the timing-driven router. *
13461349
* max_criticality: The maximum criticality factor (from 0 to 1) any sink *
13471350
* will ever have (i.e. clip criticality to this number). *
13481351
* criticality_exp: Set criticality to (path_length(sink) / longest_path) ^ *
@@ -1431,6 +1434,7 @@ struct t_router_opts {
14311434
enum e_router_algorithm router_algorithm;
14321435
enum e_base_cost_type base_cost_type;
14331436
float astar_fac;
1437+
float astar_offset;
14341438
float router_profiler_astar_fac;
14351439
float max_criticality;
14361440
float criticality_exp;

vpr/src/pack/cluster_placement.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
140140
continue;
141141
}
142142

143-
144143
/* check for force site match, if applicable */
145144
if (force_site > -1) {
145+
/* check that the forced site index is within the available range */
146+
int max_site = it->second->pb_graph_node->total_primitive_count - 1;
147+
if (force_site > max_site) {
148+
VTR_LOG("The specified primitive site (%d) is out of range (max %d)\n",
149+
force_site, max_site);
150+
break;
151+
}
146152
if (force_site == it->second->pb_graph_node->flat_site_index) {
147153
cost = try_place_molecule(molecule, it->second->pb_graph_node, primitives_list);
148154
if (cost < HUGE_POSITIVE_FLOAT) {

vpr/src/place/initial_noc_placement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts) {
220220
// Generate and evaluate router moves
221221
for (int i_move = 0; i_move < N_MOVES; i_move++) {
222222
e_create_move create_move_outcome = e_create_move::ABORT;
223-
clear_move_blocks(blocks_affected);
223+
blocks_affected.clear_move_blocks();
224224
// Shrink the range limit over time
225225
float r_lim_decayed = 1.0f + (N_MOVES - i_move) * (max_r_lim / N_MOVES);
226226
create_move_outcome = propose_router_swap(blocks_affected, r_lim_decayed);

vpr/src/place/initial_placement.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,8 @@ void initial_placement(const t_placer_opts& placer_opts,
11921192
propagate_place_constraints();
11931193

11941194
/*Mark the blocks that have already been locked to one spot via floorplan constraints
1195-
* as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement*/
1195+
* as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement
1196+
*/
11961197
mark_fixed_blocks();
11971198

11981199
// Compute and store compressed floorplanning constraints
@@ -1204,17 +1205,22 @@ void initial_placement(const t_placer_opts& placer_opts,
12041205
read_constraints(constraints_file);
12051206
}
12061207

1207-
if (noc_opts.noc) {
1208-
// NoC routers are placed before other blocks
1209-
initial_noc_placement(noc_opts, placer_opts);
1210-
propagate_place_constraints();
1211-
}
1208+
if(!placer_opts.read_initial_place_file.empty()) {
1209+
const auto& grid = g_vpr_ctx.device().grid;
1210+
read_place(nullptr, placer_opts.read_initial_place_file.c_str(), false, grid);
1211+
} else {
1212+
if (noc_opts.noc) {
1213+
// NoC routers are placed before other blocks
1214+
initial_noc_placement(noc_opts, placer_opts);
1215+
propagate_place_constraints();
1216+
}
12121217

1213-
//Assign scores to blocks and placement macros according to how difficult they are to place
1214-
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
1218+
//Assign scores to blocks and placement macros according to how difficult they are to place
1219+
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
12151220

1216-
//Place all blocks
1217-
place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file);
1221+
//Place all blocks
1222+
place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file);
1223+
}
12181224

12191225
alloc_and_load_movable_blocks();
12201226

vpr/src/place/move_transactions.cpp

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
#include "move_transactions.h"
12
#include "move_utils.h"
23

34
#include "globals.h"
45
#include "place_util.h"
6+
#include "vtr_assert.h"
7+
8+
t_pl_blocks_to_be_moved::t_pl_blocks_to_be_moved(size_t max_blocks){
9+
moved_blocks.reserve(max_blocks);
10+
}
11+
12+
size_t t_pl_blocks_to_be_moved::get_size_and_increment() {
13+
VTR_ASSERT_SAFE(moved_blocks.size() < moved_blocks.capacity());
14+
moved_blocks.resize(moved_blocks.size() + 1);
15+
return moved_blocks.size() - 1;
16+
}
517

618
//Records that block 'blk' should be moved to the specified 'to' location
7-
e_block_move_result record_block_move(t_pl_blocks_to_be_moved& blocks_affected, ClusterBlockId blk, t_pl_loc to) {
8-
auto res = blocks_affected.moved_to.emplace(to);
9-
if (!res.second) {
19+
e_block_move_result t_pl_blocks_to_be_moved::record_block_move(ClusterBlockId blk, t_pl_loc to) {
20+
auto [to_it, to_success] = moved_to.emplace(to);
21+
if (!to_success) {
1022
log_move_abort("duplicate block move to location");
1123
return e_block_move_result::ABORT;
1224
}
@@ -15,36 +27,57 @@ e_block_move_result record_block_move(t_pl_blocks_to_be_moved& blocks_affected,
1527

1628
t_pl_loc from = place_ctx.block_locs[blk].loc;
1729

18-
auto res2 = blocks_affected.moved_from.emplace(from);
19-
if (!res2.second) {
30+
auto [_, from_success] = moved_from.emplace(from);
31+
if (!from_success) {
32+
moved_to.erase(to_it);
2033
log_move_abort("duplicate block move from location");
2134
return e_block_move_result::ABORT;
2235
}
2336

2437
VTR_ASSERT_SAFE(to.sub_tile < int(place_ctx.grid_blocks.num_blocks_at_location({to.x, to.y, to.layer})));
2538

2639
// Sets up the blocks moved
27-
int imoved_blk = blocks_affected.num_moved_blocks;
28-
blocks_affected.moved_blocks[imoved_blk].block_num = blk;
29-
blocks_affected.moved_blocks[imoved_blk].old_loc = from;
30-
blocks_affected.moved_blocks[imoved_blk].new_loc = to;
31-
blocks_affected.num_moved_blocks++;
40+
size_t imoved_blk = get_size_and_increment();
41+
moved_blocks[imoved_blk].block_num = blk;
42+
moved_blocks[imoved_blk].old_loc = from;
43+
moved_blocks[imoved_blk].new_loc = to;
3244

3345
return e_block_move_result::VALID;
3446
}
3547

48+
//Examines the currently proposed move and determine any empty locations
49+
std::set<t_pl_loc> t_pl_blocks_to_be_moved::t_pl_blocks_to_be_moved::determine_locations_emptied_by_move() {
50+
std::set<t_pl_loc> moved_from_set;
51+
std::set<t_pl_loc> moved_to_set;
52+
53+
for (const t_pl_moved_block& moved_block : moved_blocks) {
54+
//When a block is moved its old location becomes free
55+
moved_from_set.emplace(moved_block.old_loc);
56+
57+
//But any block later moved to a position fills it
58+
moved_to_set.emplace(moved_block.new_loc);
59+
}
60+
61+
std::set<t_pl_loc> empty_locs;
62+
std::set_difference(moved_from_set.begin(), moved_from_set.end(),
63+
moved_to_set.begin(), moved_to_set.end(),
64+
std::inserter(empty_locs, empty_locs.begin()));
65+
66+
return empty_locs;
67+
}
68+
3669
//Moves the blocks in blocks_affected to their new locations
3770
void apply_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
3871
auto& place_ctx = g_vpr_ctx.mutable_placement();
3972
auto& device_ctx = g_vpr_ctx.device();
4073

4174
//Swap the blocks, but don't swap the nets or update place_ctx.grid_blocks
4275
//yet since we don't know whether the swap will be accepted
43-
for (int iblk = 0; iblk < blocks_affected.num_moved_blocks; ++iblk) {
44-
ClusterBlockId blk = blocks_affected.moved_blocks[iblk].block_num;
76+
for (const t_pl_moved_block& moved_block : blocks_affected.moved_blocks) {
77+
ClusterBlockId blk = moved_block.block_num;
4578

46-
const t_pl_loc& old_loc = blocks_affected.moved_blocks[iblk].old_loc;
47-
const t_pl_loc& new_loc = blocks_affected.moved_blocks[iblk].new_loc;
79+
const t_pl_loc& old_loc = moved_block.old_loc;
80+
const t_pl_loc& new_loc = moved_block.new_loc;
4881

4982
// move the block to its new location
5083
place_ctx.block_locs[blk].loc = new_loc;
@@ -67,11 +100,11 @@ void commit_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
67100
auto& place_ctx = g_vpr_ctx.mutable_placement();
68101

69102
/* Swap physical location */
70-
for (int iblk = 0; iblk < blocks_affected.num_moved_blocks; ++iblk) {
71-
ClusterBlockId blk = blocks_affected.moved_blocks[iblk].block_num;
103+
for (const t_pl_moved_block& moved_block : blocks_affected.moved_blocks) {
104+
ClusterBlockId blk = moved_block.block_num;
72105

73-
const t_pl_loc& to = blocks_affected.moved_blocks[iblk].new_loc;
74-
const t_pl_loc& from = blocks_affected.moved_blocks[iblk].old_loc;
106+
const t_pl_loc& to = moved_block.new_loc;
107+
const t_pl_loc& from = moved_block.old_loc;
75108

76109
//Remove from old location only if it hasn't already been updated by a previous block update
77110
if (place_ctx.grid_blocks.block_at_location(from) == blk) {
@@ -97,11 +130,11 @@ void revert_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
97130
auto& device_ctx = g_vpr_ctx.device();
98131

99132
// Swap the blocks back, nets not yet swapped they don't need to be changed
100-
for (int iblk = 0; iblk < blocks_affected.num_moved_blocks; ++iblk) {
101-
ClusterBlockId blk = blocks_affected.moved_blocks[iblk].block_num;
133+
for (const t_pl_moved_block& moved_block : blocks_affected.moved_blocks) {
134+
ClusterBlockId blk = moved_block.block_num;
102135

103-
const t_pl_loc& old_loc = blocks_affected.moved_blocks[iblk].old_loc;
104-
const t_pl_loc& new_loc = blocks_affected.moved_blocks[iblk].new_loc;
136+
const t_pl_loc& old_loc = moved_block.old_loc;
137+
const t_pl_loc& new_loc = moved_block.new_loc;
105138

106139
// return the block to where it was before the swap
107140
place_ctx.block_locs[blk].loc = old_loc;
@@ -121,15 +154,15 @@ void revert_move_blocks(const t_pl_blocks_to_be_moved& blocks_affected) {
121154
}
122155

123156
//Clears the current move so a new move can be proposed
124-
void clear_move_blocks(t_pl_blocks_to_be_moved& blocks_affected) {
157+
void t_pl_blocks_to_be_moved::clear_move_blocks() {
125158
//Reset moved flags
126-
blocks_affected.moved_to.clear();
127-
blocks_affected.moved_from.clear();
159+
moved_to.clear();
160+
moved_from.clear();
128161

129-
//For run-time, we just reset num_moved_blocks to zero, but do not free the blocks_affected
162+
//For run-time, we just reset size of blocks_affected.moved_blocks to zero, but do not free the blocks_affected
130163
//array to avoid memory allocation
131164

132-
blocks_affected.num_moved_blocks = 0;
165+
moved_blocks.resize(0);
133166

134-
blocks_affected.affected_pins.clear();
167+
affected_pins.clear();
135168
}

0 commit comments

Comments
 (0)