Skip to content

Commit 0e29f62

Browse files
Re-compute NoC costs when a placement checkpoint is restored.
If the current router placement is different from the one in the checkpoint, NoC-related costs and internal data structures need to be re-computed and re-initialized to match the placement in the checkpoint. This is done by calling reinitialize_noc_routing() in restore_best_placement().
1 parent d62ad56 commit 0e29f62

File tree

8 files changed

+57
-6
lines changed

8 files changed

+57
-6
lines changed

vpr/src/noc/noc_storage.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const vtr::vector<NocLinkId, NocLink>& NocStorage::get_noc_links(void) const {
2323
return link_storage;
2424
}
2525

26+
vtr::vector<NocLinkId, NocLink>& NocStorage::get_mutable_noc_links(void) {
27+
return link_storage;
28+
}
29+
2630
int NocStorage::get_number_of_noc_links(void) const {
2731
return link_storage.size();
2832
}

vpr/src/noc/noc_storage.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ class NocStorage {
184184
*/
185185
const vtr::vector<NocLinkId, NocLink>& get_noc_links(void) const;
186186

187+
/**
188+
* @brief Get all the links in the NoC. The links themselves can
189+
* be modified. This function should be used when information on
190+
* every link needs to be modified.
191+
*
192+
* @return A vector of links.
193+
*/
194+
vtr::vector<NocLinkId, NocLink>& get_mutable_noc_links(void);
195+
187196
/**
188197
* @return An integer representing the total number of links within the
189198
* NoC.

vpr/src/place/initial_placement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ void initial_placement(enum e_pad_loc_type pad_loc_type, const char* constraints
11051105

11061106
// route all the traffic flows in the NoC now that all the router cluster block have been placed (this is done only if the noc optimization is enabled by the user)
11071107
if (noc_enabled) {
1108-
initial_noc_placement();
1108+
initial_noc_routing();
11091109
}
11101110

11111111
//#ifdef VERBOSE

vpr/src/place/noc_place_utils.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static vtr::vector<NocTrafficFlowId, TrafficFlowPlaceCost> traffic_flow_costs, p
99
static std::vector<NocTrafficFlowId> affected_traffic_flows;
1010
/*********************************************************** *****************************/
1111

12-
void initial_noc_placement(void) {
12+
void initial_noc_routing(void) {
1313
// need to get placement information about where the router cluster blocks are placed on the device
1414
const auto& place_ctx = g_vpr_ctx.placement();
1515

@@ -37,6 +37,22 @@ void initial_noc_placement(void) {
3737
return;
3838
}
3939

40+
void reinitialize_noc_routing(const t_noc_opts& noc_opts, t_placer_costs& costs) {
41+
auto& noc_ctx = g_vpr_ctx.mutable_noc();
42+
43+
// Zero out bandwidth usage for all links
44+
for (auto& noc_link : noc_ctx.noc_model.get_mutable_noc_links()) {
45+
noc_link.set_bandwidth_usage(0.0);
46+
}
47+
48+
// Route traffic flows and update link bandwidth usage
49+
initial_noc_routing();
50+
51+
// Initialize traffic_flow_costs
52+
costs.noc_aggregate_bandwidth_cost = comp_noc_aggregate_bandwidth_cost();
53+
costs.noc_latency_cost = comp_noc_latency_cost(noc_opts);
54+
}
55+
4056
void find_affected_noc_routers_and_update_noc_costs(const t_pl_blocks_to_be_moved& blocks_affected, double& noc_aggregate_bandwidth_delta_c, double& noc_latency_delta_c, const t_noc_opts& noc_opts) {
4157
// provides the positions where the affected blocks have moved to
4258
auto& place_ctx = g_vpr_ctx.placement();

vpr/src/place/noc_place_utils.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,23 @@ struct TrafficFlowPlaceCost {
4949
* routed. This is why this function should only be used once.
5050
*
5151
*/
52-
void initial_noc_placement(void);
52+
void initial_noc_routing(void);
53+
54+
/**
55+
* @brief Zeros out all link bandwidth usage an re-routes traffic flows.
56+
* Initializes static variables in noc_place_utils.cpp that are used to
57+
* keep track of NoC-related costs.
58+
*
59+
* This function should be called when a placement checkpoint is restored.
60+
* If the router placement in the checkpoint is different from the last
61+
* router placement before the checkpoint is restored, link bandwidth usage,
62+
* traffic flow routes, and static variable in noc_place_utils.cpp are no
63+
* longer valid and need to be re-initialized.
64+
*
65+
* @param noc_opts NoC-related options used to calculated NoC costs
66+
* @param costs Used to get aggregate bandwidth and latency costs.
67+
*/
68+
void reinitialize_noc_routing(const t_noc_opts& noc_opts, t_placer_costs& costs);
5369

5470
/**
5571
* @brief Goes through all the cluster blocks that were moved

vpr/src/place/place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ void try_place(const Netlist<>& net_list,
953953
if (placer_opts.place_checkpointing)
954954
restore_best_placement(placement_checkpoint, timing_info, costs,
955955
placer_criticalities, placer_setup_slacks, place_delay_model,
956-
pin_timing_invalidator, crit_params);
956+
pin_timing_invalidator, crit_params, noc_opts);
957957

958958
if (placer_opts.placement_saves_per_temperature >= 1) {
959959
std::string filename = vtr::string_fmt("placement_%03d_%03d.place",

vpr/src/place/place_checkpoint.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "place_checkpoint.h"
2+
#include "noc_place_utils.h"
23

34
float t_placement_checkpoint::get_cp_cpd() { return cpd; }
45
double t_placement_checkpoint::get_cp_bb_cost() { return costs.bb_cost; }
@@ -26,7 +27,7 @@ void save_placement_checkpoint_if_needed(t_placement_checkpoint& placement_check
2627
}
2728
}
2829

29-
void restore_best_placement(t_placement_checkpoint& placement_checkpoint, std::shared_ptr<SetupTimingInfo>& timing_info, t_placer_costs& costs, std::unique_ptr<PlacerCriticalities>& placer_criticalities, std::unique_ptr<PlacerSetupSlacks>& placer_setup_slacks, std::unique_ptr<PlaceDelayModel>& place_delay_model, std::unique_ptr<NetPinTimingInvalidator>& pin_timing_invalidator, PlaceCritParams crit_params) {
30+
void restore_best_placement(t_placement_checkpoint& placement_checkpoint, std::shared_ptr<SetupTimingInfo>& timing_info, t_placer_costs& costs, std::unique_ptr<PlacerCriticalities>& placer_criticalities, std::unique_ptr<PlacerSetupSlacks>& placer_setup_slacks, std::unique_ptr<PlaceDelayModel>& place_delay_model, std::unique_ptr<NetPinTimingInvalidator>& pin_timing_invalidator, PlaceCritParams crit_params, const t_noc_opts& noc_opts) {
3031
if (placement_checkpoint.cp_is_valid() && timing_info->least_slack_critical_path().delay() > placement_checkpoint.get_cp_cpd() && costs.bb_cost < 1.05 * placement_checkpoint.get_cp_bb_cost()) {
3132
//restore the latest placement checkpoint
3233
costs = placement_checkpoint.restore_placement();
@@ -43,6 +44,11 @@ void restore_best_placement(t_placement_checkpoint& placement_checkpoint, std::s
4344
timing_info.get(),
4445
&costs);
4546

47+
// If NoC is enabled, re-compute NoC costs and re-initialize NoC internal data structures
48+
if (noc_opts.noc) {
49+
reinitialize_noc_routing(noc_opts, costs);
50+
}
51+
4652
VTR_LOG("\nCheckpoint restored\n");
4753
}
4854
}

vpr/src/place/place_checkpoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ class t_placement_checkpoint {
5050
void save_placement_checkpoint_if_needed(t_placement_checkpoint& placement_checkpoint, std::shared_ptr<SetupTimingInfo> timing_info, t_placer_costs& costs, float cpd);
5151

5252
//restore the checkpoint if it's better than the latest placement solution
53-
void restore_best_placement(t_placement_checkpoint& placement_checkpoint, std::shared_ptr<SetupTimingInfo>& timing_info, t_placer_costs& costs, std::unique_ptr<PlacerCriticalities>& placer_criticalities, std::unique_ptr<PlacerSetupSlacks>& placer_setup_slacks, std::unique_ptr<PlaceDelayModel>& place_delay_model, std::unique_ptr<NetPinTimingInvalidator>& pin_timing_invalidator, PlaceCritParams crit_params);
53+
void restore_best_placement(t_placement_checkpoint& placement_checkpoint, std::shared_ptr<SetupTimingInfo>& timing_info, t_placer_costs& costs, std::unique_ptr<PlacerCriticalities>& placer_criticalities, std::unique_ptr<PlacerSetupSlacks>& placer_setup_slacks, std::unique_ptr<PlaceDelayModel>& place_delay_model, std::unique_ptr<NetPinTimingInvalidator>& pin_timing_invalidator, PlaceCritParams crit_params, const t_noc_opts& noc_opts);
5454
#endif

0 commit comments

Comments
 (0)