Skip to content

Commit ce0fb18

Browse files
add print_initial_placement_stats() to PlacementLogPrinter
1 parent 34deb5c commit ce0fb18

File tree

6 files changed

+59
-51
lines changed

6 files changed

+59
-51
lines changed

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(
367367
}
368368
#endif //NO_GRAPHICS
369369

370-
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<SetupTimingInfo> setup_timing_info) {
370+
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<const SetupTimingInfo> setup_timing_info) {
371371
#ifndef NO_GRAPHICS
372372

373373
/* Updates the screen if the user has requested graphics. The priority *

vpr/src/draw/draw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern ezgl::application application;
4242

4343
#endif /* NO_GRAPHICS */
4444

45-
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<SetupTimingInfo> timing_info);
45+
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<const SetupTimingInfo> timing_info);
4646

4747
//FIXME: Currently broken if no rr-graph is loaded
4848
/**

vpr/src/place/place_log_util.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "VprTimingGraphResolver.h"
99
#include "timing_info.h"
1010
#include "placer.h"
11+
#include "draw.h"
12+
#include "read_place.h"
1113

1214
PlacementLogPrinter::PlacementLogPrinter(const Placer& placer)
1315
: placer_(placer) {}
@@ -136,6 +138,59 @@ void PlacementLogPrinter::print_placement_swaps_stats() const {
136138
VTR_LOG("\tSwaps aborted: %*d (%4.1f %%)\n", num_swap_print_digits,
137139
swap_stats.num_swap_aborted, 100 * abort_rate);
138140
}
141+
void PlacementLogPrinter::print_initial_placement_stats() const {
142+
const t_placer_costs& costs = placer_.costs();
143+
const t_noc_opts& noc_opts = placer_.noc_opts();
144+
const t_placer_opts& placer_opts = placer_.placer_opts();
145+
const tatum::TimingPathInfo& critical_path = placer_.critical_path();
146+
const std::optional<NocCostHandler>& noc_cost_handler = placer_.noc_cost_handler();
147+
std::shared_ptr<const SetupTimingInfo> timing_info = placer_.timing_info();
148+
const PlacerState& placer_state = placer_.placer_state();
149+
150+
VTR_LOG("Initial placement cost: %g bb_cost: %g td_cost: %g\n",
151+
costs.cost, costs.bb_cost, costs.timing_cost);
152+
153+
if (noc_opts.noc) {
154+
VTR_ASSERT(noc_cost_handler.has_value());
155+
noc_cost_handler->print_noc_costs("Initial NoC Placement Costs", costs, noc_opts);
156+
}
157+
158+
if (placer_opts.place_algorithm.is_timing_driven()) {
159+
VTR_LOG("Initial placement estimated Critical Path Delay (CPD): %g ns\n",
160+
1e9 * critical_path.delay());
161+
VTR_LOG("Initial placement estimated setup Total Negative Slack (sTNS): %g ns\n",
162+
1e9 * timing_info->setup_total_negative_slack());
163+
VTR_LOG("Initial placement estimated setup Worst Negative Slack (sWNS): %g ns\n",
164+
1e9 * timing_info->setup_worst_negative_slack());
165+
VTR_LOG("\n");
166+
VTR_LOG("Initial placement estimated setup slack histogram:\n");
167+
print_histogram(create_setup_slack_histogram(*timing_info->setup_analyzer()));
168+
}
169+
170+
const BlkLocRegistry& blk_loc_registry = placer_state.blk_loc_registry();
171+
size_t num_macro_members = 0;
172+
for (const t_pl_macro& macro : blk_loc_registry.place_macros().macros()) {
173+
num_macro_members += macro.members.size();
174+
}
175+
VTR_LOG("Placement contains %zu placement macros involving %zu blocks (average macro size %f)\n",
176+
blk_loc_registry.place_macros().macros().size(), num_macro_members,
177+
float(num_macro_members) / blk_loc_registry.place_macros().macros().size());
178+
VTR_LOG("\n");
179+
180+
char msg[vtr::bufsize];
181+
sprintf(msg,
182+
"Initial Placement. Cost: %g BB Cost: %g TD Cost %g \t Channel Factor: %d",
183+
costs.cost, costs.bb_cost, costs.timing_cost, placer_opts.place_chan_width);
184+
185+
// Draw the initial placement
186+
update_screen(ScreenUpdatePriority::MAJOR, msg, PLACEMENT, timing_info);
187+
188+
if (placer_opts.placement_saves_per_temperature >= 1) {
189+
std::string filename = vtr::string_fmt("placement_%03d_%03d.place", 0, 0);
190+
VTR_LOG("Saving initial placement to file: %s\n", filename.c_str());
191+
print_place(nullptr, nullptr, filename.c_str(), blk_loc_registry.block_locs());
192+
}
193+
}
139194

140195
void generate_post_place_timing_reports(const t_placer_opts& placer_opts,
141196
const t_analysis_opts& analysis_opts,

vpr/src/place/place_log_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PlacementLogPrinter {
2424
void print_resources_utilization() const;
2525
void print_placement_swaps_stats() const;
2626
void print_place_status(float elapsed_sec) const;
27+
void print_initial_placement_stats() const;
2728

2829
private:
2930
const Placer& placer_;

vpr/src/place/placer.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Placer::Placer(const Netlist<>& net_list,
126126
// Sanity check that initial placement is legal
127127
check_place_();
128128

129-
print_initial_placement_stats_();
129+
log_printer_.print_initial_placement_stats();
130130

131131
annealer_ = std::make_unique<PlacementAnnealer>(placer_opts_, placer_state_, costs_, net_cost_handler_, noc_cost_handler_,
132132
noc_opts_, rng_, std::move(move_generator), std::move(move_generator2), place_delay_model_.get(),
@@ -255,52 +255,6 @@ int Placer::check_placement_costs_() {
255255
return error;
256256
}
257257

258-
void Placer::print_initial_placement_stats_() {
259-
VTR_LOG("Initial placement cost: %g bb_cost: %g td_cost: %g\n",
260-
costs_.cost, costs_.bb_cost, costs_.timing_cost);
261-
262-
if (noc_opts_.noc) {
263-
VTR_ASSERT(noc_cost_handler_.has_value());
264-
noc_cost_handler_->print_noc_costs("Initial NoC Placement Costs", costs_, noc_opts_);
265-
}
266-
267-
if (placer_opts_.place_algorithm.is_timing_driven()) {
268-
VTR_LOG("Initial placement estimated Critical Path Delay (CPD): %g ns\n",
269-
1e9 * critical_path_.delay());
270-
VTR_LOG("Initial placement estimated setup Total Negative Slack (sTNS): %g ns\n",
271-
1e9 * timing_info_->setup_total_negative_slack());
272-
VTR_LOG("Initial placement estimated setup Worst Negative Slack (sWNS): %g ns\n",
273-
1e9 * timing_info_->setup_worst_negative_slack());
274-
VTR_LOG("\n");
275-
VTR_LOG("Initial placement estimated setup slack histogram:\n");
276-
print_histogram(create_setup_slack_histogram(*timing_info_->setup_analyzer()));
277-
}
278-
279-
const BlkLocRegistry& blk_loc_registry = placer_state_.blk_loc_registry();
280-
size_t num_macro_members = 0;
281-
for (const t_pl_macro& macro : blk_loc_registry.place_macros().macros()) {
282-
num_macro_members += macro.members.size();
283-
}
284-
VTR_LOG("Placement contains %zu placement macros involving %zu blocks (average macro size %f)\n",
285-
blk_loc_registry.place_macros().macros().size(), num_macro_members,
286-
float(num_macro_members) / blk_loc_registry.place_macros().macros().size());
287-
VTR_LOG("\n");
288-
289-
char msg[vtr::bufsize];
290-
sprintf(msg,
291-
"Initial Placement. Cost: %g BB Cost: %g TD Cost %g \t Channel Factor: %d",
292-
costs_.cost, costs_.bb_cost, costs_.timing_cost, placer_opts_.place_chan_width);
293-
294-
// Draw the initial placement
295-
update_screen(ScreenUpdatePriority::MAJOR, msg, PLACEMENT, timing_info_);
296-
297-
if (placer_opts_.placement_saves_per_temperature >= 1) {
298-
std::string filename = vtr::string_fmt("placement_%03d_%03d.place", 0, 0);
299-
VTR_LOG("Saving initial placement to file: %s\n", filename.c_str());
300-
print_place(nullptr, nullptr, filename.c_str(), blk_loc_registry.block_locs());
301-
}
302-
}
303-
304258
void Placer::place() {
305259
const auto& timing_ctx = g_vpr_ctx.timing();
306260
const auto& cluster_ctx = g_vpr_ctx.clustering();

vpr/src/place/placer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ class Placer {
101101

102102
int check_placement_costs_();
103103

104-
void print_initial_placement_stats_();
105-
106104
void print_post_placement_stats_();
107105
};
108106

0 commit comments

Comments
 (0)