11#include < fstream>
22#include < sstream>
3+ #include < utility>
34
45#include " vtr_log.h"
56#include " vtr_assert.h"
@@ -30,7 +31,7 @@ tatum::TimingPathInfo find_longest_critical_path_delay(const tatum::TimingConstr
3031
3132 auto cpds = tatum::find_critical_paths (*timing_ctx.graph , constraints, setup_analyzer);
3233
33- // Record the maximum critical path accross all domain pairs
34+ // Record the maximum critical path across all domain pairs
3435 for (const auto & path_info : cpds) {
3536 if (crit_path_info.delay () < path_info.delay () || std::isnan (crit_path_info.delay ())) {
3637 crit_path_info = path_info;
@@ -234,7 +235,7 @@ TimingStats::TimingStats(std::string pref, double cpd, double f_max, double swns
234235 fmax = f_max;
235236 setup_worst_neg_slack = swns;
236237 setup_total_neg_slack = stns;
237- prefix = pref;
238+ prefix = std::move ( pref) ;
238239}
239240
240241void TimingStats::write (OutputFormat fmt, std::ostream& output) const {
@@ -255,32 +256,32 @@ void TimingStats::write(OutputFormat fmt, std::ostream& output) const {
255256 }
256257}
257258
258- void write_setup_timing_summary (std::string timing_summary_filename, const TimingStats& stats) {
259- if (timing_summary_filename.size () > 0 ) {
259+ void write_setup_timing_summary (std::string_view timing_summary_filename, const TimingStats& stats) {
260+ if (! timing_summary_filename.empty () ) {
260261 TimingStats::OutputFormat fmt;
261262
262- if (vtr::check_file_name_extension (timing_summary_filename.c_str (), " .json" )) {
263+ if (vtr::check_file_name_extension (timing_summary_filename.data (), " .json" )) {
263264 fmt = TimingStats::OutputFormat::JSON;
264- } else if (vtr::check_file_name_extension (timing_summary_filename.c_str (), " .xml" )) {
265+ } else if (vtr::check_file_name_extension (timing_summary_filename.data (), " .xml" )) {
265266 fmt = TimingStats::OutputFormat::XML;
266- } else if (vtr::check_file_name_extension (timing_summary_filename.c_str (), " .txt" )) {
267+ } else if (vtr::check_file_name_extension (timing_summary_filename.data (), " .txt" )) {
267268 fmt = TimingStats::OutputFormat::HumanReadable;
268269 } else {
269- VPR_FATAL_ERROR (VPR_ERROR_PACK, " Unknown extension on output %s" , timing_summary_filename.c_str ());
270+ VPR_FATAL_ERROR (VPR_ERROR_PACK, " Unknown extension on output %s" , timing_summary_filename.data ());
270271 }
271272
272273 std::fstream fp;
273274
274- fp.open (timing_summary_filename, std::fstream::out | std::fstream::trunc);
275+ fp.open (timing_summary_filename. data () , std::fstream::out | std::fstream::trunc);
275276 stats.write (fmt, fp);
276277 fp.close ();
277278 }
278279}
279280
280281void print_setup_timing_summary (const tatum::TimingConstraints& constraints,
281282 const tatum::SetupTimingAnalyzer& setup_analyzer,
282- std::string prefix,
283- std::string timing_summary_filename) {
283+ std::string_view prefix,
284+ std::string_view timing_summary_filename) {
284285 auto & timing_ctx = g_vpr_ctx.timing ();
285286
286287 auto crit_paths = tatum::find_critical_paths (*timing_ctx.graph , constraints, setup_analyzer);
@@ -292,32 +293,32 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
292293 double setup_worst_neg_slack = sec_to_nanosec (find_setup_worst_negative_slack (setup_analyzer));
293294 double setup_total_neg_slack = sec_to_nanosec (find_setup_total_negative_slack (setup_analyzer));
294295
295- const auto stats = TimingStats (prefix, least_slack_cpd_delay, fmax,
296+ const auto stats = TimingStats (prefix. data () , least_slack_cpd_delay, fmax,
296297 setup_worst_neg_slack, setup_total_neg_slack);
297298 if (!timing_summary_filename.empty ())
298299 write_setup_timing_summary (timing_summary_filename, stats);
299300
300- VTR_LOG (" %scritical path delay (least slack): %g ns" , prefix.c_str (), least_slack_cpd_delay);
301+ VTR_LOG (" %scritical path delay (least slack): %g ns" , prefix.data (), least_slack_cpd_delay);
301302
302303 if (crit_paths.size () == 1 ) {
303304 // Fmax is only meaningful for a single-clock circuit
304305 VTR_LOG (" , Fmax: %g MHz" , fmax);
305306 }
306307 VTR_LOG (" \n " );
307308
308- VTR_LOG (" %ssetup Worst Negative Slack (sWNS): %g ns\n " , prefix.c_str (), setup_worst_neg_slack);
309- VTR_LOG (" %ssetup Total Negative Slack (sTNS): %g ns\n " , prefix.c_str (), setup_total_neg_slack);
309+ VTR_LOG (" %ssetup Worst Negative Slack (sWNS): %g ns\n " , prefix.data (), setup_worst_neg_slack);
310+ VTR_LOG (" %ssetup Total Negative Slack (sTNS): %g ns\n " , prefix.data (), setup_total_neg_slack);
310311 VTR_LOG (" \n " );
311312
312- VTR_LOG (" %ssetup slack histogram:\n " , prefix.c_str ());
313+ VTR_LOG (" %ssetup slack histogram:\n " , prefix.data ());
313314 print_histogram (create_setup_slack_histogram (setup_analyzer));
314315
315316 if (crit_paths.size () > 1 ) {
316317 // Multi-clock
317318 VTR_LOG (" \n " );
318319
319320 // Periods per constraint
320- VTR_LOG (" %sintra-domain critical path delays (CPDs):\n " , prefix.c_str ());
321+ VTR_LOG (" %sintra-domain critical path delays (CPDs):\n " , prefix.data ());
321322 for (const auto & path : crit_paths) {
322323 if (path.launch_domain () == path.capture_domain ()) {
323324 VTR_LOG (" %s to %s CPD: %g ns (%g MHz)\n " ,
@@ -329,7 +330,7 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
329330 }
330331 VTR_LOG (" \n " );
331332
332- VTR_LOG (" %sinter-domain critical path delays (CPDs):\n " , prefix.c_str ());
333+ VTR_LOG (" %sinter-domain critical path delays (CPDs):\n " , prefix.data ());
333334 for (const auto & path : crit_paths) {
334335 if (path.launch_domain () != path.capture_domain ()) {
335336 VTR_LOG (" %s to %s CPD: %g ns (%g MHz)\n " ,
@@ -342,7 +343,7 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
342343 VTR_LOG (" \n " );
343344
344345 // Slack per constraint
345- VTR_LOG (" %sintra-domain worst setup slacks per constraint:\n " , prefix.c_str ());
346+ VTR_LOG (" %sintra-domain worst setup slacks per constraint:\n " , prefix.data ());
346347 for (const auto & path : crit_paths) {
347348 if (path.launch_domain () == path.capture_domain ()) {
348349 VTR_LOG (" %s to %s worst setup slack: %g ns\n " ,
@@ -353,7 +354,7 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
353354 }
354355 VTR_LOG (" \n " );
355356
356- VTR_LOG (" %sinter-domain worst setup slacks per constraint:\n " , prefix.c_str ());
357+ VTR_LOG (" %sinter-domain worst setup slacks per constraint:\n " , prefix.data ());
357358 for (const auto & path : crit_paths) {
358359 if (path.launch_domain () != path.capture_domain ()) {
359360 VTR_LOG (" %s to %s worst setup slack: %g ns\n " ,
@@ -374,7 +375,7 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
374375 if (path.launch_domain () == path.capture_domain () && !constraints.is_virtual_clock (path.launch_domain ())) {
375376 if (path.delay () == 0 .) {
376377 VTR_LOG_WARN (" %s%s to %s CPD is %g, skipping in geomean and fanout-weighted CPDs\n " ,
377- prefix.c_str (),
378+ prefix.data (),
378379 constraints.clock_domain_name (path.launch_domain ()).c_str (),
379380 constraints.clock_domain_name (path.capture_domain ()).c_str (),
380381 sec_to_nanosec (path.delay ()));
@@ -394,11 +395,11 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
394395
395396 // Print multi-clock geomeans
396397 double geomean_intra_domain_cpd = std::numeric_limits<double >::quiet_NaN ();
397- if (intra_domain_cpds.size () > 0 ) {
398+ if (! intra_domain_cpds.empty () ) {
398399 geomean_intra_domain_cpd = vtr::geomean (intra_domain_cpds.begin (), intra_domain_cpds.end ());
399400 }
400401 VTR_LOG (" %sgeomean non-virtual intra-domain period: %g ns (%g MHz)\n " ,
401- prefix.c_str (),
402+ prefix.data (),
402403 sec_to_nanosec (geomean_intra_domain_cpd),
403404 sec_to_mhz (geomean_intra_domain_cpd));
404405
@@ -408,13 +409,13 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
408409 }
409410
410411 double fanout_weighted_geomean_intra_domain_cpd = std::numeric_limits<double >::quiet_NaN ();
411- if (fanout_weighted_intra_domain_cpds.size () > 0 ) {
412+ if (! fanout_weighted_intra_domain_cpds.empty () ) {
412413 fanout_weighted_geomean_intra_domain_cpd = vtr::geomean (fanout_weighted_intra_domain_cpds.begin (),
413414 fanout_weighted_intra_domain_cpds.end ());
414415 }
415416
416417 VTR_LOG (" %sfanout-weighted geomean non-virtual intra-domain period: %g ns (%g MHz)\n " ,
417- prefix.c_str (),
418+ prefix.data (),
418419 sec_to_nanosec (fanout_weighted_geomean_intra_domain_cpd),
419420 sec_to_mhz (fanout_weighted_geomean_intra_domain_cpd));
420421
@@ -605,28 +606,30 @@ std::vector<HistogramBucket> create_hold_slack_histogram(const tatum::HoldTiming
605606 return histogram;
606607}
607608
608- void print_hold_timing_summary (const tatum::TimingConstraints& constraints, const tatum::HoldTimingAnalyzer& hold_analyzer, std::string prefix) {
609+ void print_hold_timing_summary (const tatum::TimingConstraints& constraints,
610+ const tatum::HoldTimingAnalyzer& hold_analyzer,
611+ std::string_view prefix) {
609612 auto & timing_ctx = g_vpr_ctx.timing ();
610613
611614 auto hold_worst_neg_slack = sec_to_nanosec (find_hold_worst_negative_slack (hold_analyzer));
612615 auto hold_total_neg_slack = sec_to_nanosec (find_hold_total_negative_slack (hold_analyzer));
613616
614- VTR_LOG (" %shold Worst Negative Slack (hWNS): %g ns\n " , prefix.c_str (), hold_worst_neg_slack);
615- VTR_LOG (" %shold Total Negative Slack (hTNS): %g ns\n " , prefix.c_str (), hold_total_neg_slack);
617+ VTR_LOG (" %shold Worst Negative Slack (hWNS): %g ns\n " , prefix.data (), hold_worst_neg_slack);
618+ VTR_LOG (" %shold Total Negative Slack (hTNS): %g ns\n " , prefix.data (), hold_total_neg_slack);
616619
617620 /* For testing*/
618621 // VTR_LOG("Hold Total Negative Slack within clbs: %g ns\n", sec_to_nanosec(find_total_negative_slack_within_clb_blocks(hold_analyzer)));
619622 VTR_LOG (" \n " );
620623
621- VTR_LOG (" %shold slack histogram:\n " , prefix.c_str ());
624+ VTR_LOG (" %shold slack histogram:\n " , prefix.data ());
622625 print_histogram (create_hold_slack_histogram (hold_analyzer));
623626
624627 if (constraints.clock_domains ().size () > 1 ) {
625628 // Multi-clock
626629 VTR_LOG (" \n " );
627630
628631 // Slack per constraint
629- VTR_LOG (" %sintra-domain worst hold slacks per constraint:\n " , prefix.c_str ());
632+ VTR_LOG (" %sintra-domain worst hold slacks per constraint:\n " , prefix.data ());
630633 for (const auto & domain : constraints.clock_domains ()) {
631634 float worst_slack = find_hold_worst_slack (hold_analyzer, domain, domain);
632635
@@ -639,7 +642,7 @@ void print_hold_timing_summary(const tatum::TimingConstraints& constraints, cons
639642 }
640643 VTR_LOG (" \n " );
641644
642- VTR_LOG (" %sinter-domain worst hold slacks per constraint:\n " , prefix.c_str ());
645+ VTR_LOG (" %sinter-domain worst hold slacks per constraint:\n " , prefix.data ());
643646 for (const auto & launch_domain : constraints.clock_domains ()) {
644647 for (const auto & capture_domain : constraints.clock_domains ()) {
645648 if (launch_domain != capture_domain) {
@@ -816,13 +819,13 @@ float calc_relaxed_criticality(const std::map<DomainPair, float>& domains_max_re
816819 return max_crit;
817820}
818821
819- void print_tatum_cpds (std::vector<tatum::TimingPathInfo> cpds) {
822+ void print_tatum_cpds (const std::vector<tatum::TimingPathInfo>& cpds) {
820823 for (auto path : cpds) {
821824 VTR_LOG (" Tatum %zu -> %zu: least_slack=%g cpd=%g\n " , size_t (path.launch_domain ()), size_t (path.capture_domain ()), float (path.slack ()), float (path.delay ()));
822825 }
823826}
824827
825- tatum::NodeId id_or_pin_name_to_tnode (std::string pin_name_or_tnode) {
828+ tatum::NodeId id_or_pin_name_to_tnode (const std::string& pin_name_or_tnode) {
826829 std::istringstream ss (pin_name_or_tnode);
827830 int id;
828831 if (ss >> id) { // Successfully converted
@@ -837,7 +840,7 @@ tatum::NodeId id_or_pin_name_to_tnode(std::string pin_name_or_tnode) {
837840 return pin_name_to_tnode (pin_name_or_tnode);
838841}
839842
840- tatum::NodeId pin_name_to_tnode (std::string pin_name) {
843+ tatum::NodeId pin_name_to_tnode (const std::string& pin_name) {
841844 auto & atom_ctx = g_vpr_ctx.atom ();
842845
843846 AtomPinId pin = atom_ctx.nlist .find_pin (pin_name);
@@ -855,7 +858,7 @@ tatum::NodeId pin_name_to_tnode(std::string pin_name) {
855858 return tnode;
856859}
857860
858- void write_setup_timing_graph_dot (std::string filename, const SetupTimingInfo& timing_info, tatum::NodeId debug_node) {
861+ void write_setup_timing_graph_dot (const std::string& filename, const SetupTimingInfo& timing_info, tatum::NodeId debug_node) {
859862 auto & timing_graph = *timing_info.timing_graph ();
860863
861864 auto dot_writer = tatum::make_graphviz_dot_writer (timing_graph, *timing_info.delay_calculator ());
@@ -874,7 +877,7 @@ void write_setup_timing_graph_dot(std::string filename, const SetupTimingInfo& t
874877 dot_writer.write_dot_file (filename, *timing_info.setup_analyzer ());
875878}
876879
877- void write_hold_timing_graph_dot (std::string filename, HoldTimingInfo& timing_info, tatum::NodeId debug_node) {
880+ void write_hold_timing_graph_dot (const std::string& filename, HoldTimingInfo& timing_info, tatum::NodeId debug_node) {
878881 auto & timing_graph = *timing_info.timing_graph ();
879882
880883 auto dot_writer = tatum::make_graphviz_dot_writer (timing_graph, *timing_info.delay_calculator ());
0 commit comments