Skip to content

Commit dc9c2e2

Browse files
Merge branch 'master' into temp_place_ref
2 parents ae9dc10 + 49de5fb commit dc9c2e2

17 files changed

+84
-30
lines changed

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
@@ -306,6 +306,14 @@ static std::string read_place_body(std::ifstream& placement_file,
306306
loc.layer = block_layer;
307307

308308
if (seen_blocks[blk_id] == 0) {
309+
if (is_place_file && block_locs[blk_id].is_fixed) {
310+
const t_pl_loc& constraint_loc = block_locs[blk_id].loc;
311+
if (loc != constraint_loc) {
312+
VPR_THROW(VPR_ERROR_PLACE,
313+
"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).",
314+
blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, constraint_loc.x, constraint_loc.y, constraint_loc.layer, constraint_loc.sub_tile);
315+
}
316+
}
309317
set_block_location(blk_id, loc, place_loc_vars);
310318
}
311319

vpr/src/base/vpr_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ struct t_placer_opts {
12651265
enum e_pad_loc_type pad_loc_type;
12661266
std::string constraints_file;
12671267
std::string write_initial_place_file;
1268+
std::string read_initial_place_file;
12681269
enum pfreq place_freq;
12691270
int recompute_crit_iter;
12701271
int inner_loop_recompute_divider;
@@ -1372,6 +1373,8 @@ struct t_placer_opts {
13721373
* an essentially breadth-first search, astar_fac = 1 is near *
13731374
* the usual astar algorithm and astar_fac > 1 are more *
13741375
* aggressive. *
1376+
* astar_offset: Offset that is subtracted from the lookahead (expected *
1377+
* future costs) in the timing-driven router. *
13751378
* max_criticality: The maximum criticality factor (from 0 to 1) any sink *
13761379
* will ever have (i.e. clip criticality to this number). *
13771380
* criticality_exp: Set criticality to (path_length(sink) / longest_path) ^ *
@@ -1460,6 +1463,7 @@ struct t_router_opts {
14601463
enum e_router_algorithm router_algorithm;
14611464
enum e_base_cost_type base_cost_type;
14621465
float astar_fac;
1466+
float astar_offset;
14631467
float router_profiler_astar_fac;
14641468
float max_criticality;
14651469
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_placement.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,17 +1260,24 @@ void initial_placement(const t_placer_opts& placer_opts,
12601260
read_constraints(constraints_file, place_loc_vars);
12611261
}
12621262

1263-
if (noc_opts.noc) {
1264-
// NoC routers are placed before other blocks
1265-
initial_noc_placement(noc_opts, placer_opts, place_loc_vars);
1266-
propagate_place_constraints();
1267-
}
12681263

1269-
//Assign scores to blocks and placement macros according to how difficult they are to place
1270-
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
12711264

1272-
//Place all blocks
1273-
place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file, place_loc_vars);
1265+
if(!placer_opts.read_initial_place_file.empty()) {
1266+
const auto& grid = g_vpr_ctx.device().grid;
1267+
read_place(nullptr, placer_opts.read_initial_place_file.c_str(), place_loc_vars, false, grid);
1268+
} else {
1269+
if (noc_opts.noc) {
1270+
// NoC routers are placed before other blocks
1271+
initial_noc_placement(noc_opts, placer_opts, place_loc_vars);
1272+
propagate_place_constraints();
1273+
}
1274+
1275+
//Assign scores to blocks and placement macros according to how difficult they are to place
1276+
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
1277+
1278+
//Place all blocks
1279+
place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file, place_loc_vars);
1280+
}
12741281

12751282
alloc_and_load_movable_blocks(block_locs);
12761283

vpr/src/place/place.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ void try_place(const Netlist<>& net_list,
459459
auto [move_generator, move_generator2] = create_move_generators(placer_ctx, placer_opts, move_lim, noc_opts.noc_centroid_weight);
460460

461461
if (!placer_opts.write_initial_place_file.empty()) {
462-
print_place(nullptr, nullptr, (placer_opts.write_initial_place_file + ".init.place").c_str(),
463-
placer_ctx.block_locs());
462+
print_place(nullptr, nullptr, placer_opts.write_initial_place_file.c_str(), placer_ctx.block_locs());
464463
}
465464

466465
#ifdef ENABLE_ANALYTIC_PLACE

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,8 @@ void OverrideDelayModel::compute_override_delay_model(
11891189
RouterDelayProfiler& route_profiler,
11901190
const t_router_opts& router_opts) {
11911191
t_router_opts router_opts2 = router_opts;
1192-
router_opts2.astar_fac = 0.;
1192+
router_opts2.astar_fac = 0.f;
1193+
router_opts2.astar_offset = 0.f;
11931194

11941195
//Look at all the direct connections that exist, and add overrides to delay model
11951196
auto& device_ctx = g_vpr_ctx.device();

vpr/src/route/connection_router.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "connection_router.h"
2-
#include "rr_graph.h"
32

3+
#include <algorithm>
4+
#include "rr_graph.h"
45
#include "binary_heap.h"
56
#include "four_ary_heap.h"
67
#include "bucket.h"
@@ -660,8 +661,8 @@ float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_para
660661
float expected_total_delay_cost;
661662
float expected_total_cong_cost;
662663

663-
float expected_total_cong = cost_params.astar_fac * expected_cong + backwards_cong;
664-
float expected_total_delay = cost_params.astar_fac * expected_delay + backwards_delay;
664+
float expected_total_cong = expected_cong + backwards_cong;
665+
float expected_total_delay = expected_delay + backwards_delay;
665666

666667
//If budgets specified calculate cost as described by RCV paper:
667668
// R. Fung, V. Betz and W. Chow, "Slack Allocation and Routing to Improve FPGA Timing While
@@ -813,7 +814,7 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
813814
rr_node_arch_name(target_node, is_flat_).c_str(),
814815
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, target_node, is_flat_).c_str(),
815816
expected_cost, to->R_upstream);
816-
total_cost += to->backward_path_cost + cost_params.astar_fac * expected_cost;
817+
total_cost += to->backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
817818
}
818819
to->cost = total_cost;
819820
}
@@ -905,12 +906,8 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
905906

906907
if (!rcv_path_manager.is_enabled()) {
907908
// tot_cost = backward_path_cost + cost_params.astar_fac * expected_cost;
908-
float tot_cost = backward_path_cost
909-
+ cost_params.astar_fac
910-
* router_lookahead_.get_expected_cost(inode,
911-
target_node,
912-
cost_params,
913-
R_upstream);
909+
float expected_cost = router_lookahead_.get_expected_cost(inode, target_node, cost_params, R_upstream);
910+
float tot_cost = backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
914911
VTR_LOGV_DEBUG(router_debug_, " Adding node %8d to heap from init route tree with cost %g (%s)\n",
915912
inode,
916913
tot_cost,

vpr/src/route/connection_router_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct t_conn_delay_budget {
2323
struct t_conn_cost_params {
2424
float criticality = 1.;
2525
float astar_fac = 1.2;
26+
float astar_offset = 0.f;
2627
float bend_cost = 1.;
2728
float pres_fac = 1.;
2829
const t_conn_delay_budget* delay_budget = nullptr;

vpr/src/route/route_net.tpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ inline NetResultFlags route_net(ConnectionRouter& router,
139139
t_conn_delay_budget conn_delay_budget;
140140
t_conn_cost_params cost_params;
141141
cost_params.astar_fac = router_opts.astar_fac;
142+
cost_params.astar_offset = router_opts.astar_offset;
142143
cost_params.bend_cost = router_opts.bend_cost;
143144
cost_params.pres_fac = pres_fac;
144145
cost_params.delay_budget = ((budgeting_inf.if_set()) ? &conn_delay_budget : nullptr);

vpr/src/route/router_delay_profiling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
9595
t_conn_cost_params cost_params;
9696
cost_params.criticality = 1.;
9797
cost_params.astar_fac = router_opts.router_profiler_astar_fac;
98+
cost_params.astar_offset = router_opts.astar_offset;
9899
cost_params.bend_cost = router_opts.bend_cost;
99100

100101
route_budgets budgeting_inf(net_list_, is_flat_);
@@ -164,6 +165,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
164165
t_conn_cost_params cost_params;
165166
cost_params.criticality = 1.;
166167
cost_params.astar_fac = router_opts.astar_fac;
168+
cost_params.astar_offset = router_opts.astar_offset;
167169
cost_params.bend_cost = router_opts.bend_cost;
168170
/* This function is called during placement. Thus, the flat routing option should be disabled. */
169171
//TODO: Placement is run with is_flat=false. However, since is_flat is passed, det_routing_arch should

vpr/test/test_connection_router.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static float do_one_route(RRNodeId source_node,
4141
t_conn_cost_params cost_params;
4242
cost_params.criticality = router_opts.max_criticality;
4343
cost_params.astar_fac = router_opts.astar_fac;
44+
cost_params.astar_offset = router_opts.astar_offset;
4445
cost_params.bend_cost = router_opts.bend_cost;
4546

4647
const Netlist<>& net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().nlist : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;

vtr_flow/arch/ispd/ultrascale_ispd.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,11 @@
504504
</pb_type>
505505
<interconnect>
506506
<!-- Fracturable LUT connectivity: Based on Fig 3-1 of 'UltraScale Architecture CLB User Guide' UG574 (v1.5) -->
507-
<!-- UPDATED based on known legal external ISPD placements -->
508-
<complete name="I0" input="LUT6_2.I0" output="LUTX[0].I0 LUTX[1].I0 LUTX[0].I1 LUTX[1].I1 LUTX[0].I2 LUTX[1].I2 LUTX[0].I3 LUTX[1].I3 LUTX[0].I4 LUTX[1].I4"/>
509-
<complete name="I1" input="LUT6_2.I1" output="LUTX[0].I0 LUTX[1].I0 LUTX[0].I1 LUTX[1].I1 LUTX[0].I2 LUTX[1].I2 LUTX[0].I3 LUTX[1].I3 LUTX[0].I4 LUTX[1].I4"/>
510-
<complete name="I2" input="LUT6_2.I2" output="LUTX[0].I0 LUTX[1].I0 LUTX[0].I1 LUTX[1].I1 LUTX[0].I2 LUTX[1].I2 LUTX[0].I3 LUTX[1].I3 LUTX[0].I4 LUTX[1].I4"/>
511-
<complete name="I3" input="LUT6_2.I3" output="LUTX[0].I0 LUTX[1].I0 LUTX[0].I1 LUTX[1].I1 LUTX[0].I2 LUTX[1].I2 LUTX[0].I3 LUTX[1].I3 LUTX[0].I4 LUTX[1].I4"/>
512-
<complete name="I4" input="LUT6_2.I4" output="LUTX[0].I0 LUTX[1].I0 LUTX[0].I1 LUTX[1].I1 LUTX[0].I2 LUTX[1].I2 LUTX[0].I3 LUTX[1].I3 LUTX[0].I4 LUTX[1].I4"/>
507+
<direct name="I0" input="LUT6_2.I0" output="LUTX[0].I0 LUTX[1].I0"/>
508+
<direct name="I1" input="LUT6_2.I1" output="LUTX[0].I1 LUTX[1].I1"/>
509+
<direct name="I2" input="LUT6_2.I2" output="LUTX[0].I2 LUTX[1].I2"/>
510+
<direct name="I3" input="LUT6_2.I3" output="LUTX[0].I3 LUTX[1].I3"/>
511+
<direct name="I4" input="LUT6_2.I4" output="LUTX[0].I4 LUTX[1].I4"/>
513512
<direct name="O6" input="LUTX[0].O" output="LUT6_2.O6"/>
514513
<direct name="O5" input="LUTX[1].O" output="LUT6_2.O5"/>
515514
</interconnect>

0 commit comments

Comments
 (0)