Skip to content

Commit 99d71d9

Browse files
authored
Merge pull request #2236 from verilog-to-routing/noc_placement_integration
Noc placement integration within VPRs placer
2 parents 7a440a9 + 5a727f6 commit 99d71d9

39 files changed

+4101
-599
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,9 +4577,6 @@ static void ProcessNoc(pugi::xml_node noc_tag, t_arch* arch, const pugiutil::loc
45774577
pugi::xml_node noc_topology;
45784578
pugi::xml_node noc_mesh_topology;
45794579

4580-
// identifier that lets us know when we could not properly convert an attribute value to a integer
4581-
int attribute_conversion_failure = -1;
4582-
45834580
// identifier that lets us know when we could not properly convert a string conversion value
45844581
std::string attribute_conversion_failure_string = "";
45854582

@@ -4593,16 +4590,26 @@ static void ProcessNoc(pugi::xml_node noc_tag, t_arch* arch, const pugiutil::loc
45934590
pugiutil::expect_only_attributes(noc_tag, expected_noc_attributes, loc_data);
45944591

45954592
// now go through and parse the required attributes for noc tag
4596-
noc_ref->link_bandwidth = pugiutil::get_attribute(noc_tag, "link_bandwidth", loc_data, pugiutil::REQUIRED).as_double(attribute_conversion_failure);
45974593

4598-
noc_ref->link_latency = pugiutil::get_attribute(noc_tag, "link_latency", loc_data, pugiutil::REQUIRED).as_double(attribute_conversion_failure);
4594+
// variables below temporarily store the attribute values as string
4595+
// this is so that scientific notation can be used for these attributes
4596+
std::string link_bandwidth_intermediate_val;
4597+
std::string router_latency_intermediate_val;
4598+
std::string link_latency_intermediate_val;
4599+
4600+
link_bandwidth_intermediate_val = pugiutil::get_attribute(noc_tag, "link_bandwidth", loc_data, pugiutil::REQUIRED).as_string();
4601+
noc_ref->link_bandwidth = std::atof(link_bandwidth_intermediate_val.c_str());
4602+
4603+
link_latency_intermediate_val = pugiutil::get_attribute(noc_tag, "link_latency", loc_data, pugiutil::REQUIRED).as_string();
4604+
noc_ref->link_latency = std::atof(link_latency_intermediate_val.c_str());
45994605

4600-
noc_ref->router_latency = pugiutil::get_attribute(noc_tag, "router_latency", loc_data, pugiutil::REQUIRED).as_double(attribute_conversion_failure);
4606+
router_latency_intermediate_val = pugiutil::get_attribute(noc_tag, "router_latency", loc_data, pugiutil::REQUIRED).as_string();
4607+
noc_ref->router_latency = std::atof(router_latency_intermediate_val.c_str());
46014608

46024609
noc_ref->noc_router_tile_name = pugiutil::get_attribute(noc_tag, "noc_router_tile_name", loc_data, pugiutil::REQUIRED).as_string();
46034610

46044611
// the noc parameters can only be non-zero positive values
4605-
if ((noc_ref->link_bandwidth < 0) || (noc_ref->link_latency < 0) || (noc_ref->router_latency < 0)) {
4612+
if ((noc_ref->link_bandwidth <= 0.) || (noc_ref->link_latency <= 0.) || (noc_ref->router_latency <= 0.)) {
46064613
archfpga_throw(loc_data.filename_c_str(), loc_data.line(noc_tag),
46074614
"The link bandwidth, link latency and router latency for the NoC must be a positive non-zero value.");
46084615
}

vpr/src/base/SetupVPR.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,11 @@ static void SetupNocOpts(const t_options& Options, t_noc_opts* NocOpts) {
715715
NocOpts->noc = Options.noc;
716716
NocOpts->noc_flows_file = Options.noc_flows_file;
717717
NocOpts->noc_routing_algorithm = Options.noc_routing_algorithm;
718+
NocOpts->noc_placement_weighting = Options.noc_placement_weighting;
719+
NocOpts->noc_latency_constraints_weighting = Options.noc_latency_constraints_weighting;
720+
NocOpts->noc_latency_weighting = Options.noc_latency_weighting;
721+
NocOpts->noc_swap_percentage = Options.noc_swap_percentage;
722+
NocOpts->noc_placement_file_name = Options.noc_placement_file_name;
718723

719724
return;
720725
}

vpr/src/base/ShowSetup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,5 +785,10 @@ static void ShowPackerOpts(const t_packer_opts& PackerOpts) {
785785
static void ShowNocOpts(const t_noc_opts& NocOpts) {
786786
VTR_LOG("NocOpts.noc_flows_file: %s\n", NocOpts.noc_flows_file.c_str());
787787
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_routing_algorithm.c_str());
788+
VTR_LOG("NocOpts.noc_placement_weighting: %f\n", NocOpts.noc_placement_weighting);
789+
VTR_LOG("NocOpts.noc_latency_constraints_weighting: %f\n", NocOpts.noc_latency_constraints_weighting);
790+
VTR_LOG("NocOpts.noc_latency_weighting: %f\n", NocOpts.noc_latency_weighting);
791+
VTR_LOG("NocOpts.noc_swap_percentage: %d%%\n", NocOpts.noc_swap_percentage);
792+
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_placement_file_name.c_str());
788793
VTR_LOG("\n");
789794
}

vpr/src/base/place_and_route.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
5555
const t_annealing_sched& annealing_sched,
5656
const t_router_opts& router_opts,
5757
const t_analysis_opts& analysis_opts,
58+
const t_noc_opts& noc_opts,
5859
const t_file_name_opts& filename_opts,
5960
const t_arch* arch,
6061
bool verify_binary_search,
@@ -185,6 +186,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
185186
annealing_sched,
186187
router_opts,
187188
analysis_opts,
189+
noc_opts,
188190
arch->Chans,
189191
det_routing_arch,
190192
segment_inf,
@@ -327,7 +329,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
327329
break;
328330
if (placer_opts.place_freq == PLACE_ALWAYS) {
329331
placer_opts.place_chan_width = current;
330-
try_place(placement_net_list, placer_opts, annealing_sched, router_opts, analysis_opts,
332+
try_place(placement_net_list, placer_opts, annealing_sched, router_opts, analysis_opts, noc_opts,
331333
arch->Chans, det_routing_arch, segment_inf,
332334
arch->Directs, arch->num_directs,
333335
false);

vpr/src/base/place_and_route.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
2828
const t_annealing_sched& annealing_sched,
2929
const t_router_opts& router_opts,
3030
const t_analysis_opts& analysis_opts,
31+
const t_noc_opts& noc_opts,
3132
const t_file_name_opts& filename_opts,
3233
const t_arch* arch,
3334
bool verify_binary_search,

vpr/src/base/read_options.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,42 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
26792679
"* bfs_routing: Uses the breadth first search algorithm. The objective is to find a route that uses a minimum number of links.\n"
26802680
"This can be used with any NoC topology\n")
26812681
.default_value("bfs_routing")
2682+
.choices({"xy_routing", "bfs_routing"})
2683+
.show_in(argparse::ShowIn::HELP_ONLY);
2684+
2685+
noc_grp.add_argument<double>(args.noc_placement_weighting, "--noc_placement_weighting")
2686+
.help(
2687+
"Controls the importance of the NoC placement parameters relative to timing and wirelength of the design."
2688+
"This value can be >=0, where 0 would mean the placement is based solely on timing and wirelength, a value of 1 would mean noc placement is considered equal to timing and wirelength and a value greater than 1 would mean the placement is increasingly dominated by NoC parameters.")
2689+
.default_value("0.6")
2690+
.show_in(argparse::ShowIn::HELP_ONLY);
2691+
2692+
noc_grp.add_argument<double>(args.noc_latency_constraints_weighting, "--noc_latency_constraints_weighting")
2693+
.help(
2694+
"Controls the importance of meeting all the NoC traffic flow latency constraints."
2695+
"This value can be >=0, where 0 would mean the latency constraints have no relevance to placement, a value of 1 would mean the latency constraints are weighted equally to the sum of other placement cost components and a value greater than 1 would mean the placement is increasingly dominated by meeting the latency constraints of the traffic flows.")
2696+
.default_value("1")
2697+
.show_in(argparse::ShowIn::HELP_ONLY);
2698+
2699+
noc_grp.add_argument<double>(args.noc_latency_weighting, "--noc_latency_weighting")
2700+
.help(
2701+
"Controls the importance of reducing the latencies of the NoC traffic flows."
2702+
"This value can be >=0, where 0 would mean the latencies have no relevance to placement, a value of 1 would mean the latencies are weighted equally to the sum of other placement cost components and a value greater than 1 would mean the placement is increasingly dominated by reducing the latencies of the traffic flows.")
2703+
.default_value("0.05")
2704+
.show_in(argparse::ShowIn::HELP_ONLY);
2705+
2706+
noc_grp.add_argument<double>(args.noc_swap_percentage, "--noc_swap_percentage")
2707+
.help(
2708+
"Sets the minimum fraction of swaps attempted by the placer that are NoC blocks."
2709+
"This value is an integer ranging from 0-100. 0 means NoC blocks will be moved at the same rate as other blocks. 100 means all swaps attempted by the placer are NoC router blocks.")
2710+
.default_value("40")
2711+
.show_in(argparse::ShowIn::HELP_ONLY);
2712+
2713+
noc_grp.add_argument<std::string>(args.noc_placement_file_name, "--noc_placement_file_name")
2714+
.help(
2715+
"Name of the output file that contains the NoC placement information."
2716+
"The default name is 'vpr_noc_placement_output.txt'")
2717+
.default_value("vpr_noc_placement_output.txt")
26822718
.show_in(argparse::ShowIn::HELP_ONLY);
26832719

26842720
return parser;

vpr/src/base/read_options.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ struct t_options {
146146
argparse::ArgValue<bool> noc;
147147
argparse::ArgValue<std::string> noc_flows_file;
148148
argparse::ArgValue<std::string> noc_routing_algorithm;
149+
argparse::ArgValue<double> noc_placement_weighting;
150+
argparse::ArgValue<double> noc_latency_constraints_weighting;
151+
argparse::ArgValue<double> noc_latency_weighting;
152+
argparse::ArgValue<double> noc_swap_percentage;
153+
argparse::ArgValue<std::string> noc_placement_file_name;
149154

150155
/* Timing-driven placement options only */
151156
argparse::ArgValue<float> PlaceTimingTradeoff;

vpr/src/base/setup_noc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ void setup_noc(const t_arch& arch) {
3838
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "No physical NoC routers were found on the FPGA device. Either the provided name for the physical router tile was incorrect or the FPGA device has no routers.");
3939
}
4040

41+
// store the reference to device grid with
42+
// need to set this first before adding routers to the model
43+
noc_ctx.noc_model.set_device_grid_width((int)device_ctx.grid.width());
44+
4145
// generate noc model
4246
generate_noc(arch, noc_ctx, noc_router_tiles);
4347

vpr/src/base/vpr_api.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch&
730730
vpr_setup.AnnealSched,
731731
vpr_setup.RouterOpts,
732732
vpr_setup.AnalysisOpts,
733+
vpr_setup.NocOpts,
733734
arch.Chans,
734735
&vpr_setup.RoutingArch,
735736
vpr_setup.Segments,
@@ -944,6 +945,7 @@ RouteStatus vpr_route_min_W(const Netlist<>& net_list,
944945
vpr_setup.AnnealSched,
945946
router_opts,
946947
vpr_setup.AnalysisOpts,
948+
vpr_setup.NocOpts,
947949
vpr_setup.FileNameOpts,
948950
&arch,
949951
router_opts.verify_binary_search,

vpr/src/base/vpr_types.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,9 +1337,14 @@ struct t_analysis_opts {
13371337

13381338
// used to store NoC specific options, when supplied as an input by the user
13391339
struct t_noc_opts {
1340-
bool noc; ///<options to turn on hard NoC modeling & optimization
1341-
std::string noc_flows_file; ///<name of the file that contains all the traffic flow information in the NoC
1342-
std::string noc_routing_algorithm; ///<controls the routing algorithm used to route packets within the NoC
1340+
bool noc; ///<options to turn on hard NoC modeling & optimization
1341+
std::string noc_flows_file; ///<name of the file that contains all the traffic flow information to be sent over the NoC in this design
1342+
std::string noc_routing_algorithm; ///<controls the routing algorithm used to route packets within the NoC
1343+
double noc_placement_weighting; ///<controls the significance of the NoC placement cost relative to the total placement cost range:[0-inf)
1344+
double noc_latency_constraints_weighting; ///<controls the significance of meeting the traffic flow contraints range:[0-inf)
1345+
double noc_latency_weighting; ///<controls the significance of the traffic flow latencies relative to the other NoC placement costs range:[0-inf)
1346+
int noc_swap_percentage; ///<controls the number of NoC router block swap attemps relative to the total number of swaps attempted by the placer range:[0-100]
1347+
std::string noc_placement_file_name; ///<is the name of the output file that contains the NoC placement information
13431348
};
13441349

13451350
/**

0 commit comments

Comments
 (0)