Skip to content

Commit efe43e9

Browse files
add print_post_placement_stats() to PlacementLogPrinter
1 parent f2fab38 commit efe43e9

File tree

6 files changed

+77
-72
lines changed

6 files changed

+77
-72
lines changed

vpr/src/place/place_log_util.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "placer.h"
1111
#include "draw.h"
1212
#include "read_place.h"
13+
#include "tatum/echo_writer.hpp"
1314

1415
PlacementLogPrinter::PlacementLogPrinter(const Placer& placer)
1516
: placer_(placer)
@@ -199,6 +200,61 @@ void PlacementLogPrinter::print_initial_placement_stats() const {
199200
}
200201
}
201202

203+
void PlacementLogPrinter::print_post_placement_stats() const {
204+
const auto& timing_ctx = g_vpr_ctx.timing();
205+
const PlacementAnnealer& annealer = placer_.annealer();
206+
const auto& [swap_stats, move_type_stats, placer_stats] = annealer.get_stats();
207+
208+
VTR_LOG("\n");
209+
VTR_LOG("Swaps called: %d\n", swap_stats.num_ts_called);
210+
// blocks_affected.move_abortion_logger.report_aborted_moves();
211+
212+
if (placer_.placer_opts_.place_algorithm.is_timing_driven()) {
213+
//Final timing estimate
214+
VTR_ASSERT(placer_.timing_info_);
215+
216+
if (isEchoFileEnabled(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH)) {
217+
tatum::write_echo(getEchoFileName(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH),
218+
*timing_ctx.graph, *timing_ctx.constraints,
219+
*placer_.placement_delay_calc_, placer_.timing_info_->analyzer());
220+
221+
tatum::NodeId debug_tnode = id_or_pin_name_to_tnode(placer_.analysis_opts_.echo_dot_timing_graph_node);
222+
write_setup_timing_graph_dot(getEchoFileName(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH) + std::string(".dot"),
223+
*placer_.timing_info_, debug_tnode);
224+
}
225+
226+
generate_post_place_timing_reports(placer_.placer_opts_, placer_.analysis_opts_, *placer_.timing_info_,
227+
*placer_.placement_delay_calc_, /*is_flat=*/false, placer_.placer_state_.blk_loc_registry());
228+
229+
// Print critical path delay metrics
230+
VTR_LOG("\n");
231+
print_setup_timing_summary(*timing_ctx.constraints,
232+
*placer_.timing_info_->setup_analyzer(), "Placement estimated ", "");
233+
}
234+
235+
char msg[vtr::bufsize];
236+
sprintf(msg,
237+
"Placement. Cost: %g bb_cost: %g td_cost: %g Channel Factor: %d",
238+
placer_.costs_.cost, placer_.costs_.bb_cost, placer_.costs_.timing_cost, placer_.placer_opts_.place_chan_width);
239+
VTR_LOG("Placement cost: %g, bb_cost: %g, td_cost: %g, \n", placer_.costs_.cost,
240+
placer_.costs_.bb_cost, placer_.costs_.timing_cost);
241+
update_screen(ScreenUpdatePriority::MAJOR, msg, PLACEMENT, placer_.timing_info_);
242+
243+
// print the noc costs info
244+
if (placer_.noc_opts_.noc) {
245+
VTR_ASSERT(placer_.noc_cost_handler_.has_value());
246+
placer_.noc_cost_handler_->print_noc_costs("\nNoC Placement Costs", placer_.costs_, placer_.noc_opts_);
247+
248+
// TODO: move this to an appropriate file
249+
#ifdef ENABLE_NOC_SAT_ROUTING
250+
if (costs.noc_cost_terms.congestion > 0.0) {
251+
VTR_LOG("NoC routing configuration is congested. Invoking the SAT NoC router.\n");
252+
invoke_sat_router(costs, noc_opts, placer_opts.seed);
253+
}
254+
#endif //ENABLE_NOC_SAT_ROUTING
255+
}
256+
}
257+
202258
void generate_post_place_timing_reports(const t_placer_opts& placer_opts,
203259
const t_analysis_opts& analysis_opts,
204260
const SetupTimingInfo& timing_info,

vpr/src/place/place_log_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class PlacementLogPrinter {
2626
void print_placement_swaps_stats() const;
2727
void print_place_status(float elapsed_sec) const;
2828
void print_initial_placement_stats() const;
29+
void print_post_placement_stats() const;
2930

3031
private:
3132
const Placer& placer_;

vpr/src/place/placer.cpp

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#include "analytic_placer.h"
1010
#include "initial_placement.h"
1111
#include "concrete_timing_info.h"
12-
#include "tatum/echo_writer.hpp"
1312
#include "verify_placement.h"
1413
#include "place_timing_update.h"
1514
#include "annealer.h"
1615
#include "RL_agent_util.h"
1716
#include "place_checkpoint.h"
17+
#include "tatum/echo_writer.hpp"
1818

1919
Placer::Placer(const Netlist<>& net_list,
2020
const t_placer_opts& placer_opts,
@@ -179,17 +179,14 @@ void Placer::alloc_and_init_timing_objects_(const Netlist<>& net_list,
179179

180180
// Write out the initial timing echo file
181181
if (isEchoFileEnabled(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH)) {
182-
tatum::write_echo(
183-
getEchoFileName(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH),
184-
*timing_ctx.graph, *timing_ctx.constraints,
185-
*placement_delay_calc_, timing_info_->analyzer());
182+
tatum::write_echo(getEchoFileName(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH),
183+
*timing_ctx.graph, *timing_ctx.constraints,
184+
*placement_delay_calc_, timing_info_->analyzer());
186185

187186
tatum::NodeId debug_tnode = id_or_pin_name_to_tnode(analysis_opts.echo_dot_timing_graph_node);
188187

189-
write_setup_timing_graph_dot(
190-
getEchoFileName(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH)
191-
+ std::string(".dot"),
192-
*timing_info_, debug_tnode);
188+
write_setup_timing_graph_dot(getEchoFileName(E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH) + std::string(".dot"),
189+
*timing_info_, debug_tnode);
193190
}
194191

195192
costs_.timing_cost_norm = 1 / costs_.timing_cost;
@@ -337,8 +334,11 @@ void Placer::place() {
337334
perform_full_timing_update(crit_params, place_delay_model_.get(), placer_criticalities_.get(),
338335
placer_setup_slacks_.get(), pin_timing_invalidator_.get(),
339336
timing_info_.get(), &costs_, placer_state_);
337+
338+
critical_path_ = timing_info_->least_slack_critical_path();
339+
340340
VTR_LOG("post-quench CPD = %g (ns) \n",
341-
1e9 * timing_info_->least_slack_critical_path().delay());
341+
1e9 * critical_path_.delay());
342342
}
343343

344344
// See if our latest checkpoint is better than the current placement solution
@@ -369,7 +369,7 @@ void Placer::place() {
369369

370370
check_place_();
371371

372-
print_post_placement_stats_();
372+
log_printer_.print_post_placement_stats();
373373

374374
// Print out swap statistics and resource utilization
375375
log_printer_.print_resources_utilization();
@@ -391,61 +391,6 @@ void Placer::place() {
391391
p_runtime_ctx.f_update_td_costs_total_elapsed_sec);
392392
}
393393

394-
void Placer::print_post_placement_stats_() {
395-
const auto& timing_ctx = g_vpr_ctx.timing();
396-
const auto& [swap_stats, move_type_stats, placer_stats] = annealer_->get_stats();
397-
398-
VTR_LOG("\n");
399-
VTR_LOG("Swaps called: %d\n", swap_stats.num_ts_called);
400-
// blocks_affected.move_abortion_logger.report_aborted_moves();
401-
402-
if (placer_opts_.place_algorithm.is_timing_driven()) {
403-
//Final timing estimate
404-
VTR_ASSERT(timing_info_);
405-
406-
critical_path_ = timing_info_->least_slack_critical_path();
407-
408-
if (isEchoFileEnabled(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH)) {
409-
tatum::write_echo(getEchoFileName(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH),
410-
*timing_ctx.graph, *timing_ctx.constraints,
411-
*placement_delay_calc_, timing_info_->analyzer());
412-
413-
tatum::NodeId debug_tnode = id_or_pin_name_to_tnode(analysis_opts_.echo_dot_timing_graph_node);
414-
write_setup_timing_graph_dot(getEchoFileName(E_ECHO_FINAL_PLACEMENT_TIMING_GRAPH) + std::string(".dot"),
415-
*timing_info_, debug_tnode);
416-
}
417-
418-
generate_post_place_timing_reports(placer_opts_, analysis_opts_, *timing_info_,
419-
*placement_delay_calc_, /*is_flat=*/false, placer_state_.blk_loc_registry());
420-
421-
// Print critical path delay metrics
422-
VTR_LOG("\n");
423-
print_setup_timing_summary(*timing_ctx.constraints,
424-
*timing_info_->setup_analyzer(), "Placement estimated ", "");
425-
}
426-
427-
char msg[vtr::bufsize];
428-
sprintf(msg,
429-
"Placement. Cost: %g bb_cost: %g td_cost: %g Channel Factor: %d",
430-
costs_.cost, costs_.bb_cost, costs_.timing_cost, placer_opts_.place_chan_width);
431-
VTR_LOG("Placement cost: %g, bb_cost: %g, td_cost: %g, \n", costs_.cost,
432-
costs_.bb_cost, costs_.timing_cost);
433-
update_screen(ScreenUpdatePriority::MAJOR, msg, PLACEMENT, timing_info_);
434-
435-
// print the noc costs info
436-
if (noc_opts_.noc) {
437-
VTR_ASSERT(noc_cost_handler_.has_value());
438-
noc_cost_handler_->print_noc_costs("\nNoC Placement Costs", costs_, noc_opts_);
439-
440-
#ifdef ENABLE_NOC_SAT_ROUTING
441-
if (costs.noc_cost_terms.congestion > 0.0) {
442-
VTR_LOG("NoC routing configuration is congested. Invoking the SAT NoC router.\n");
443-
invoke_sat_router(costs, noc_opts, placer_opts.seed);
444-
}
445-
#endif //ENABLE_NOC_SAT_ROUTING
446-
}
447-
}
448-
449394
void Placer::copy_locs_to_global_state() {
450395
auto& place_ctx = g_vpr_ctx.mutable_placement();
451396

@@ -481,12 +426,15 @@ const t_placer_costs& Placer::costs() const {
481426
const tatum::TimingPathInfo& Placer::critical_path() const {
482427
return critical_path_;
483428
}
429+
484430
std::shared_ptr<const SetupTimingInfo> Placer::timing_info() const {
485431
return timing_info_;
486432
}
433+
487434
const PlacerState& Placer::placer_state() const {
488435
return placer_state_;
489436
}
437+
490438
const std::optional<NocCostHandler>& Placer::noc_cost_handler() const {
491439
return noc_cost_handler_;
492440
}

vpr/src/place/placer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class Placer {
8484

8585
std::unique_ptr<PlacementAnnealer> annealer_;
8686

87-
PlacementLogPrinter log_printer_;
87+
const PlacementLogPrinter log_printer_;
88+
89+
friend void PlacementLogPrinter::print_post_placement_stats() const;
8890

8991
private:
9092
void alloc_and_init_timing_objects_(const Netlist<>& net_list,
@@ -100,8 +102,6 @@ class Placer {
100102
void check_place_();
101103

102104
int check_placement_costs_();
103-
104-
void print_post_placement_stats_();
105105
};
106106

107107
#endif //VTR_PLACER_H

vpr/src/timing/timing_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tatum::TimingPathInfo find_least_slack_critical_path_delay(const tatum::TimingCo
4747

4848
auto cpds = tatum::find_critical_paths(*timing_ctx.graph, constraints, setup_analyzer);
4949

50-
//Record the maximum critical path accross all domain pairs
50+
//Record the maximum critical path across all domain pairs
5151
for (const auto& path_info : cpds) {
5252
if (path_info.slack() < crit_path_info.slack() || std::isnan(crit_path_info.slack())) {
5353
crit_path_info = path_info;
@@ -855,7 +855,7 @@ tatum::NodeId pin_name_to_tnode(std::string pin_name) {
855855
return tnode;
856856
}
857857

858-
void write_setup_timing_graph_dot(std::string filename, SetupTimingInfo& timing_info, tatum::NodeId debug_node) {
858+
void write_setup_timing_graph_dot(std::string filename, const SetupTimingInfo& timing_info, tatum::NodeId debug_node) {
859859
auto& timing_graph = *timing_info.timing_graph();
860860

861861
auto dot_writer = tatum::make_graphviz_dot_writer(timing_graph, *timing_info.delay_calculator());

vpr/src/timing/timing_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void print_tatum_cpds(std::vector<tatum::TimingPathInfo> cpds);
119119
tatum::NodeId id_or_pin_name_to_tnode(std::string name_or_id);
120120
tatum::NodeId pin_name_to_tnode(std::string name);
121121

122-
void write_setup_timing_graph_dot(std::string filename, SetupTimingInfo& timing_info, tatum::NodeId debug_node = tatum::NodeId::INVALID());
122+
void write_setup_timing_graph_dot(std::string filename, const SetupTimingInfo& timing_info, tatum::NodeId debug_node = tatum::NodeId::INVALID());
123123
void write_hold_timing_graph_dot(std::string filename, HoldTimingInfo& timing_info, tatum::NodeId debug_node = tatum::NodeId::INVALID());
124124

125125
struct TimingStats {

0 commit comments

Comments
 (0)