Skip to content

Commit a92ba80

Browse files
applied PR comments
1 parent 619d9e7 commit a92ba80

File tree

8 files changed

+78
-35
lines changed

8 files changed

+78
-35
lines changed

vpr/src/base/read_options.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,28 +2813,39 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
28132813
noc_grp.add_argument<double>(args.noc_placement_weighting, "--noc_placement_weighting")
28142814
.help(
28152815
"Controls the importance of the NoC placement parameters relative to timing and wirelength of the design."
2816-
"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.")
2816+
"This value can be >=0, where 0 would mean the placement is based solely on timing and wirelength."
2817+
"A value of 1 would mean noc placement is considered equal to timing and wirelength"
2818+
"A value greater than 1 would mean the placement is increasingly dominated by NoC parameters.")
28172819
.default_value("5.0")
28182820
.show_in(argparse::ShowIn::HELP_ONLY);
28192821

28202822
noc_grp.add_argument<double>(args.noc_latency_constraints_weighting, "--noc_latency_constraints_weighting")
28212823
.help(
2822-
"Controls the importance of meeting all the NoC traffic flow latency constraints."
2823-
"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.")
2824+
"Controls the importance of meeting all the NoC traffic flow latency constraints.\n"
2825+
"This value can be >=0, where 0 would mean the latency constraints have no relevance to placement.\n"
2826+
"Other positive numbers specify the importance of meeting latency constraints to other NoC-related cost terms.\n"
2827+
"Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and"
2828+
"only their relative ratios determine the importance of each cost term.")
28242829
.default_value("0.6")
28252830
.show_in(argparse::ShowIn::HELP_ONLY);
28262831

28272832
noc_grp.add_argument<double>(args.noc_latency_weighting, "--noc_latency_weighting")
28282833
.help(
2829-
"Controls the importance of reducing the latencies of the NoC traffic flows."
2830-
"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.")
2834+
"Controls the importance of reducing the latencies of the NoC traffic flows.\n"
2835+
"This value can be >=0, where 0 would mean the latencies have no relevance to placement.\n"
2836+
"Other positive numbers specify the importance of minimizing aggregate latency to other NoC-related cost terms.\n"
2837+
"Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and"
2838+
"only their relative ratios determine the importance of each cost term.")
28312839
.default_value("0.02")
28322840
.show_in(argparse::ShowIn::HELP_ONLY);
28332841

28342842
noc_grp.add_argument<double>(args.noc_congestion_weighting, "--noc_congestion_weighting")
28352843
.help(
2836-
"Controls the importance of reducing the congestion of the NoC links."
2837-
"This value can be >=0, where 0 would mean the congestion has no relevance to placement, a value of 1 would mean the congestion is 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 link congestions.")
2844+
"Controls the importance of reducing the congestion of the NoC links.\n"
2845+
"This value can be >=0, where 0 would mean the congestion has no relevance to placement.\n"
2846+
"Other positive numbers specify the importance of minimizing congestion to other NoC-related cost terms.\n"
2847+
"Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and"
2848+
"only their relative ratios determine the importance of each cost term.")
28382849
.default_value("0.00")
28392850
.show_in(argparse::ShowIn::HELP_ONLY);
28402851

vpr/src/base/vpr_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,11 +1498,11 @@ struct t_noc_opts {
14981498
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
14991499
std::string noc_routing_algorithm; ///<controls the routing algorithm used to route packets within the NoC
15001500
double noc_placement_weighting; ///<controls the significance of the NoC placement cost relative to the total placement cost range:[0-inf)
1501-
double noc_aggregate_bandwidth_weighting;
1502-
double noc_latency_constraints_weighting; ///<controls the significance of meeting the traffic flow contraints range:[0-inf)
1501+
double noc_aggregate_bandwidth_weighting; ///<controls the significance of aggregate used bandwidth relative to other NoC placement costs:[0:-inf)
1502+
double noc_latency_constraints_weighting; ///<controls the significance of meeting the traffic flow constraints range:[0-inf)
15031503
double noc_latency_weighting; ///<controls the significance of the traffic flow latencies relative to the other NoC placement costs range:[0-inf)
15041504
double noc_congestion_weighting; ///<controls the significance of the link congestions relative to the other NoC placement costs range:[0-inf)
1505-
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]
1505+
int noc_swap_percentage; ///<controls the number of NoC router block swap attempts relative to the total number of swaps attempted by the placer range:[0-100]
15061506
std::string noc_placement_file_name; ///<is the name of the output file that contains the NoC placement information
15071507
};
15081508

vpr/src/noc/noc_storage.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* in the NoC. They can be thought of as edges in a graph. Links
3131
* have a source router where they exit from and sink router where
3232
* they enter. It is important to note that the links are not
33-
* bi-directional, the legal way to traverse a link is from the
33+
* bi-directional; the legal way to traverse a link is from the
3434
* source router of the link to the sink router.
3535
*
3636
*/
@@ -271,8 +271,10 @@ class NocStorage {
271271

272272
/**
273273
* @brief Given source and sink router identifiers, this function
274-
* finds a link connecting these routers and returns it identifier.
274+
* finds a link connecting these routers and returns its identifier.
275275
* If such a link does not exist, an invalid id is returned.
276+
* The function is not optimized for performance as it has a complexity
277+
* of O(N_links).
276278
*
277279
* @param src_router The unique router identifier for the source router.
278280
* @param dst_router The unique router identifier for the destination router.

vpr/src/place/noc_place_utils.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ void reinitialize_noc_routing(t_placer_costs& costs) {
8686

8787
void find_affected_noc_routers_and_update_noc_costs(const t_pl_blocks_to_be_moved& blocks_affected,
8888
NocCostTerms& delta_c) {
89+
/* For speed, delta_c is passed by reference instead of being returned.
90+
* We expect delta cost terms to be zero to ensure correctness.
91+
*/
8992
VTR_ASSERT_SAFE(delta_c.aggregate_bandwidth == 0.);
9093
VTR_ASSERT_SAFE(delta_c.latency == 0.);
91-
VTR_ASSERT(delta_c.latency_overrun == 0.);
94+
VTR_ASSERT_SAFE(delta_c.latency_overrun == 0.);
9295
VTR_ASSERT_SAFE(delta_c.congestion == 0.);
9396
auto& noc_ctx = g_vpr_ctx.mutable_noc();
9497

@@ -230,7 +233,7 @@ void re_route_associated_traffic_flows(ClusterBlockId moved_block_router_id,
230233
// first check to see whether we have already re-routed the current traffic flow and only re-route it if we haven't already.
231234
if (updated_traffic_flows.find(traffic_flow_id) == updated_traffic_flows.end()) {
232235
// get all links for this flow route before it is rerouted
233-
// The returned const std::vector<NocLinkId>& is copied so that we can modify (sort) it
236+
// The returned const std::vector<NocLinkId>& is copied so that we can modify (sort) it in find_affected_links_by_flow_reroute()
234237
std::vector<NocLinkId> prev_traffic_flow_links = noc_traffic_flows_storage.get_traffic_flow_route(traffic_flow_id);
235238

236239
// now update the current traffic flow by re-routing it based on the new locations of its src and destination routers
@@ -603,9 +606,16 @@ double calculate_noc_cost(const NocCostTerms& cost_terms,
603606
double cost = 0.0;
604607

605608
/* NoC's contribution to the placement cost is a weighted sum over:
606-
* 1) Traffic flow latency costs
607-
* 2) Traffic flow aggregate bandwidth costs
608-
* 3) Link congestion costs
609+
* 1) Traffic flow aggregate bandwidth cost
610+
* 2) Traffic flow latency cost
611+
* 3) Traffic flow latency overrun cost
612+
* 4) Link congestion cost
613+
*
614+
* Since NoC-related cost terms have different scales, they are
615+
* rescaled by multiplying each cost term with its corresponding
616+
* normalization factor. Then, a weighted sum over normalized cost terms
617+
* is computed. Weighting factors determine the contribution of each
618+
* normalized term to the sum.
609619
*/
610620
cost = noc_opts.noc_placement_weighting * (
611621
cost_terms.aggregate_bandwidth * norm_factors.aggregate_bandwidth * noc_opts.noc_aggregate_bandwidth_weighting +

vpr/src/place/noc_place_utils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ constexpr double INVALID_NOC_COST_TERM = -1.0;
3535
* @brief Each traffic flow cost consists of two components:
3636
* 1) traffic flow aggregate bandwidth (sum over all used links of the traffic flow bandwidth)
3737
* 2) traffic flow latency (currently unloaded/best-case latency of the flow)
38+
* 3) traffic flow latency overrun (how much the latency is higher than the
39+
* latency constraint for a traffic flow.
3840
* NoC placement code will keep an array-of-struct to easily access each
3941
* traffic flow cost.
4042
*/
@@ -378,6 +380,9 @@ double calculate_traffic_flow_aggregate_bandwidth_cost(const std::vector<NocLink
378380
* latencies.
379381
* @param traffic_flow_info Contains the traffic flow priority.
380382
* @return The computed latency cost terms for the given traffic flow.
383+
* The first element is the total latency experience by the traffic flow.
384+
* The second one specifies how much the experienced latency exceeds the
385+
* latency constraint set for this traffic flow.
381386
*/
382387
std::pair<double, double> calculate_traffic_flow_latency_cost(const std::vector<NocLinkId>& traffic_flow_route,
383388
const NocStorage& noc_model,
@@ -394,6 +399,15 @@ std::pair<double, double> calculate_traffic_flow_latency_cost(const std::vector<
394399
*/
395400
double calculate_link_congestion_cost(const NocLink& link);
396401

402+
/**
403+
* @brief The user passes weighting factors for aggregate latency
404+
* and latency overrun terms. The weighting factor for aggregate
405+
* bandwidth is computed by subtracting two user-provided weighting
406+
* factor from 1. The computed aggregate bandwidth weighting factor
407+
* is stored in noc_opts argument.
408+
*
409+
* @param noc_opts Contains weighting factors.
410+
*/
397411
void normalize_noc_cost_weighting_factor(t_noc_opts& noc_opts);
398412

399413
/**
@@ -424,6 +438,8 @@ int get_number_of_traffic_flows_with_latency_cons_met(void);
424438

425439
/**
426440
* @brief Goes through all NoC links and counts the congested ones.
441+
* A congested NoC link is a link whose used bandwidth exceeds its
442+
* bandwidth capacity.
427443
*
428444
* @return The total number of congested NoC links.
429445
*/

vpr/src/place/place_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void alloc_and_load_legal_placement_locations(std::vector<std::vector<std::vecto
431431
continue;
432432
}
433433
// If this is the anchor position of a block, add it to the legal_pos.
434-
// Otherwise don't, so large blocks aren't added multiple times.
434+
// Otherwise, don't, so large blocks aren't added multiple times.
435435
if (device_ctx.grid.get_width_offset({i, j, layer_num}) == 0 && device_ctx.grid.get_height_offset({i, j, layer_num}) == 0) {
436436
int itype = tile->index;
437437
int isub_tile = sub_tile.index;

vpr/src/place/place_util.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ class t_placer_costs;
1818

1919
/**
2020
* @brief Data structure that stores different cost terms for NoC placement.
21+
* This data structure can also be used to store normalization and weighting
22+
* factors for NoC-related cost terms.
2123
*
22-
* @param aggregate_bandwidth The total used bandwidth used in the NoC.
23-
* @param latency A weighted average between aggregate latency and
24-
* latency overruns.
25-
* @param congestion The sum of congestion divided by available bandwidth
26-
* over all NoC links.
24+
* @param aggregate_bandwidth The aggregate NoC bandwidth cost. This is
25+
* computed by summing all used link bandwidths.
26+
* @param latency The NoC latency cost, calculated as the sum of latencies
27+
* experienced by each traffic flow.
28+
* @param latency_overrun Sum of latency overrun for traffic flows that have
29+
* a latency constraint.
30+
* @param congestion The NoC congestion cost, i.e. how over-utilized
31+
* NoC links are. This is computed by dividing over-utilized bandwidth
32+
* by link bandwidth, and summing all computed ratios.
2733
*/
2834
struct NocCostTerms {
2935
public:
@@ -61,22 +67,14 @@ struct NocCostTerms {
6167
* @param timing_cost_norm The normalization factor for the timing cost, which
6268
* is upper-bounded by the value of MAX_INV_TIMING_COST.
6369
*
64-
* @param noc_aggregate_bandwidth_cost The aggregate NoC bandwidth cost
65-
* @param noc_aggregate_bandwidth_cost_norm The normalization factor for
66-
* the aggregate bandwidth cost
67-
* @param noc_latency_cost The NoC latency cost,
68-
* calculated as the sum of latencies experienced by each traffic flow
69-
* @param noc_latency_cost_norm The normalization factor for the latency cost
70-
* @param noc_congestion_cost The NoC congestion cost, i.e. how over-utilized
71-
* NoC links are
72-
* @param noc_congestion_cost_norm The normalization factor for the NoC
73-
* congestion cost
70+
* @param noc_cost_terms NoC-related cost terms
71+
* @param noc_cost_norm_factors Normalization factors for NoC-related cost terms.
7472
*
7573
* @param MAX_INV_TIMING_COST Stops inverse timing cost from going to infinity
7674
* with very lax timing constraints, which avoids multiplying by a
7775
* gigantic timing_cost_norm when auto-normalizing. The exact value
7876
* of this cost has relatively little impact, but should be large
79-
* enough to not affect the timing costs computatation for normal
77+
* enough to not affect the timing costs computation for normal
8078
* constraints.
8179
*
8280
* @param place_algorithm Determines how the member values are updated upon
@@ -94,7 +92,7 @@ class t_placer_costs {
9492
NocCostTerms noc_cost_norm_factors;
9593

9694
public: //Constructor
97-
t_placer_costs(t_place_algorithm algo)
95+
explicit t_placer_costs(t_place_algorithm algo)
9896
: place_algorithm(algo) {}
9997
t_placer_costs() = default;
10098

vtr_flow/scripts/python_libs/vtr/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ def run_system_command(
146146
try:
147147
# Call the command
148148
stderr = None if self._valgrind else subprocess.STDOUT
149+
'''
150+
capnproto accesses PWD environment variable to learn about the current working directory.
151+
However, subprocess.Popen() changes the working directory without updating this variable.
152+
This can cause issues when a VTR task passes router lookahead or RR graph files to VPR.
153+
PWD environment variable is updated manually to prevent capnproto from throwing exceptions.
154+
'''
149155
modified_environ = os.environ.copy()
150156
modified_environ['PWD'] = str(temp_dir)
151157
proc = subprocess.Popen(

0 commit comments

Comments
 (0)