Skip to content

Commit 574b6fc

Browse files
committed
[vpr] fix the bugs after merge was mastered
1 parent 34d77d8 commit 574b6fc

File tree

3 files changed

+49
-50
lines changed

3 files changed

+49
-50
lines changed

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ struct t_pl_loc {
790790
}
791791

792792
friend bool operator==(const t_pl_loc& lhs, const t_pl_loc& rhs) {
793-
return std::tie(lhs.x, lhs.y, lhs.sub_tile, lhs.layer) == std::tie(rhs.x, rhs.y, rhs.sub_tile, rhs.layer);
793+
return std::tie(lhs.layer, lhs.x, lhs.y, lhs.sub_tile) == std::tie(rhs.layer, rhs.x, rhs.y, rhs.sub_tile);
794794
}
795795

796796
friend bool operator!=(const t_pl_loc& lhs, const t_pl_loc& rhs) {

vpr/src/place/net_cost_handler.cpp

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "move_utils.h"
55
#include "place_timing_update.h"
66
#include "noc_place_utils.h"
7+
#include "vtr_math.h"
78

89
using std::max;
910
using std::min;
@@ -2026,68 +2027,66 @@ void reset_move_nets(int num_nets_affected) {
20262027
}
20272028

20282029
void recompute_costs_from_scratch(const t_placer_opts& placer_opts,
2029-
const t_noc_opts& noc_opts,
2030-
const PlaceDelayModel* delay_model,
2031-
const PlacerCriticalities* criticalities,
2032-
t_placer_costs* costs) {
2030+
const t_noc_opts& noc_opts,
2031+
const PlaceDelayModel* delay_model,
2032+
const PlacerCriticalities* criticalities,
2033+
t_placer_costs* costs) {
2034+
auto check_and_print_cost = [](double new_cost,
2035+
double old_cost,
2036+
const std::string& cost_name) {
2037+
if (!vtr::isclose(new_cost, old_cost, ERROR_TOL, 0.)) {
2038+
std::string msg = vtr::string_fmt(
2039+
"in recompute_costs_from_scratch: new_%s = %g, old %s = %g, ERROR_TOL = %g\n",
2040+
cost_name.c_str(), new_cost, cost_name.c_str(), old_cost, ERROR_TOL);
2041+
VPR_ERROR(VPR_ERROR_PLACE, msg.c_str());
2042+
}
2043+
};
2044+
20332045
double new_bb_cost = recompute_bb_cost();
2034-
if (fabs(new_bb_cost - costs->bb_cost) > costs->bb_cost * ERROR_TOL) {
2035-
std::string msg = vtr::string_fmt(
2036-
"in recompute_costs_from_scratch: new_bb_cost = %g, old bb_cost = %g\n",
2037-
new_bb_cost, costs->bb_cost);
2038-
VPR_ERROR(VPR_ERROR_PLACE, msg.c_str());
2039-
}
2046+
check_and_print_cost(new_bb_cost, costs->bb_cost, "bb_cost");
20402047
costs->bb_cost = new_bb_cost;
20412048

20422049
if (placer_opts.place_algorithm.is_timing_driven()) {
20432050
double new_timing_cost = 0.;
20442051
comp_td_costs(delay_model, *criticalities, &new_timing_cost);
2045-
if (fabs(
2046-
new_timing_cost
2047-
- costs->timing_cost)
2048-
> costs->timing_cost * ERROR_TOL) {
2049-
std::string msg = vtr::string_fmt(
2050-
"in recompute_costs_from_scratch: new_timing_cost = %g, old timing_cost = %g, ERROR_TOL = %g\n",
2051-
new_timing_cost, costs->timing_cost, ERROR_TOL);
2052-
VPR_ERROR(VPR_ERROR_PLACE, msg.c_str());
2053-
}
2052+
check_and_print_cost(new_timing_cost, costs->timing_cost, "timing_cost");
20542053
costs->timing_cost = new_timing_cost;
20552054
} else {
20562055
VTR_ASSERT(placer_opts.place_algorithm == BOUNDING_BOX_PLACE);
2057-
20582056
costs->cost = new_bb_cost * costs->bb_cost_norm;
20592057
}
20602058

20612059
if (noc_opts.noc) {
2062-
double new_noc_aggregate_bandwidth_cost = 0.;
2063-
double new_noc_latency_cost = 0.;
2064-
recompute_noc_costs(new_noc_aggregate_bandwidth_cost, new_noc_latency_cost);
2065-
2066-
if (fabs(
2067-
new_noc_aggregate_bandwidth_cost
2068-
- costs->noc_aggregate_bandwidth_cost)
2069-
> costs->noc_aggregate_bandwidth_cost * ERROR_TOL) {
2070-
std::string msg = vtr::string_fmt(
2071-
"in recompute_costs_from_scratch: new_noc_aggregate_bandwidth_cost = %g, old noc_aggregate_bandwidth_cost = %g, ERROR_TOL = %g\n",
2072-
new_noc_aggregate_bandwidth_cost, costs->noc_aggregate_bandwidth_cost, ERROR_TOL);
2073-
VPR_ERROR(VPR_ERROR_PLACE, msg.c_str());
2074-
}
2075-
costs->noc_aggregate_bandwidth_cost = new_noc_aggregate_bandwidth_cost;
2060+
NocCostTerms new_noc_cost;
2061+
recompute_noc_costs(new_noc_cost);
2062+
2063+
check_and_print_cost(new_noc_cost.aggregate_bandwidth,
2064+
costs->noc_cost_terms.aggregate_bandwidth,
2065+
"noc_aggregate_bandwidth");
2066+
costs->noc_cost_terms.aggregate_bandwidth = new_noc_cost.aggregate_bandwidth;
20762067

20772068
// only check if the recomputed cost and the current noc latency cost are within the error tolerance if the cost is above 1 picosecond.
20782069
// Otherwise, there is no need to check (we expect the latency cost to be above the threshold of 1 picosecond)
2079-
if (new_noc_latency_cost > MIN_EXPECTED_NOC_LATENCY_COST) {
2080-
if (fabs(
2081-
new_noc_latency_cost
2082-
- costs->noc_latency_cost)
2083-
> costs->noc_latency_cost * ERROR_TOL) {
2084-
std::string msg = vtr::string_fmt(
2085-
"in recompute_costs_from_scratch: new_noc_latency_cost = %g, old noc_latency_cost = %g, ERROR_TOL = %g\n",
2086-
new_noc_latency_cost, costs->noc_latency_cost, ERROR_TOL);
2087-
VPR_ERROR(VPR_ERROR_PLACE, msg.c_str());
2088-
}
2070+
if (new_noc_cost.latency > MIN_EXPECTED_NOC_LATENCY_COST) {
2071+
check_and_print_cost(new_noc_cost.latency,
2072+
costs->noc_cost_terms.latency,
2073+
"noc_latency_cost");
2074+
}
2075+
costs->noc_cost_terms.latency = new_noc_cost.latency;
2076+
2077+
if (new_noc_cost.latency_overrun > MIN_EXPECTED_NOC_LATENCY_COST) {
2078+
check_and_print_cost(new_noc_cost.latency_overrun,
2079+
costs->noc_cost_terms.latency_overrun,
2080+
"noc_latency_overrun_cost");
2081+
}
2082+
costs->noc_cost_terms.latency_overrun = new_noc_cost.latency_overrun;
2083+
2084+
if (new_noc_cost.congestion > MIN_EXPECTED_NOC_CONGESTION_COST) {
2085+
check_and_print_cost(new_noc_cost.congestion,
2086+
costs->noc_cost_terms.congestion,
2087+
"noc_congestion_cost");
20892088
}
2090-
costs->noc_latency_cost = new_noc_latency_cost;
2089+
costs->noc_cost_terms.congestion = new_noc_cost.congestion;
20912090
}
20922091
}
20932092

vpr/src/place/net_cost_handler.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ void reset_move_nets(int num_nets_affected);
9999
* @param costs
100100
*/
101101
void recompute_costs_from_scratch(const t_placer_opts& placer_opts,
102-
const t_noc_opts& noc_opts,
103-
const PlaceDelayModel* delay_model,
104-
const PlacerCriticalities* criticalities,
105-
t_placer_costs* costs);
102+
const t_noc_opts& noc_opts,
103+
const PlaceDelayModel* delay_model,
104+
const PlacerCriticalities* criticalities,
105+
t_placer_costs* costs);
106106

107107
/**
108108
* @brief Allocates and loads the chanx_place_cost_fac and chany_place_cost_fac

0 commit comments

Comments
 (0)