88#include " vtr_error.h"
99#include " vtr_log.h"
1010
11- void LookaheadProfiler::enable (bool should_enable) {
12- enabled_ = should_enable;
11+ void LookaheadProfiler::set_file_name (const std::string& file_name) {
12+ enabled_ = !file_name.empty ();
13+ if (!enabled_)
14+ return ;
15+
16+ lookahead_verifier_csv_.open (file_name, std::ios::out);
17+
18+ if (!lookahead_verifier_csv_.is_open ()) {
19+ std::string message = " Could not open " + file_name;
20+ VTR_LOG_ERROR (message.c_str ());
21+ throw vtr::VtrError (message, " lookahead_profiler.cpp" , 21 );
22+ }
23+
24+ lookahead_verifier_csv_
25+ << " iteration no."
26+ << " ,source node"
27+ << " ,sink node"
28+ << " ,sink block name"
29+ << " ,sink atom block model"
30+ << " ,sink cluster block type"
31+ << " ,sink cluster tile height"
32+ << " ,sink cluster tile width"
33+ << " ,current node"
34+ << " ,node type"
35+ << " ,node length"
36+ << " ,num. nodes from sink"
37+ << " ,delta x"
38+ << " ,delta y"
39+ << " ,actual cost"
40+ << " ,actual delay"
41+ << " ,actual congestion"
42+ << " ,predicted cost"
43+ << " ,predicted delay"
44+ << " ,predicted congestion"
45+ << " ,criticality"
46+ << " \n " ;
1347}
1448
1549void LookaheadProfiler::record (int iteration,
@@ -26,49 +60,9 @@ void LookaheadProfiler::record(int iteration,
2660 if (!enabled_)
2761 return ;
2862
29- // If csv file hasn't been opened, open it and write out column headers
30- if (is_empty_) {
31- lookahead_verifier_csv_.open (" lookahead_verifier_info.csv" , std::ios::out);
32-
33- if (!lookahead_verifier_csv_.is_open ()) {
34- VTR_LOG_ERROR (" Could not open lookahead_verifier_info.csv" );
35- throw vtr::VtrError (" Could not open lookahead_verifier_info.csv" ,
36- " lookahead_profiler.cpp" ,
37- 28 );
38- }
39-
40- lookahead_verifier_csv_
41- << " iteration no."
42- << " ,source node"
43- << " ,sink node"
44- << " ,sink block name"
45- << " ,sink atom block model"
46- << " ,sink cluster block type"
47- << " ,sink cluster tile height"
48- << " ,sink cluster tile width"
49- << " ,current node"
50- << " ,node type"
51- << " ,node length"
52- << " ,num. nodes from sink"
53- << " ,delta x"
54- << " ,delta y"
55- << " ,actual cost"
56- << " ,actual delay"
57- << " ,actual congestion"
58- << " ,predicted cost"
59- << " ,predicted delay"
60- << " ,predicted congestion"
61- << " ,criticality"
62- << " \n " ;
63-
64- is_empty_ = false ;
65- }
66-
6763 if (!lookahead_verifier_csv_.is_open ()) {
68- VTR_LOG_ERROR (" lookahead_verifier_info.csv is not open." );
69- throw vtr::VtrError (" lookahead_verifier_info.csv is not open." ,
70- " lookahead_profiler.cpp" ,
71- 62 );
64+ VTR_LOG_ERROR (" Output file is not open." );
65+ throw vtr::VtrError (" Output file is not open." , " lookahead_profiler.cpp" , 65 );
7266 }
7367
7468 // The default value in RouteTree::update_from_heap() is -1; only calls which descend from route_net()
0 commit comments