Skip to content

Commit d4c83e6

Browse files
committed
rr_graph_indexed: enhance printing of indexed data
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 01c8019 commit d4c83e6

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

vpr/src/base/echo_files.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void alloc_and_load_echo_file_info() {
115115
setEchoFileName(E_ECHO_SBLOCK_PATTERN, "sblock_pattern.txt");
116116
setEchoFileName(E_ECHO_ENDPOINT_TIMING, "endpoint_timing.echo.json");
117117
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
118+
setEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA, "rr_indexed_data.echo");
118119
}
119120

120121
void free_echo_file_info() {

vpr/src/base/echo_files.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum e_echo_files {
4747
E_ECHO_SBLOCK_PATTERN,
4848
E_ECHO_ENDPOINT_TIMING,
4949
E_ECHO_LOOKAHEAD_MAP,
50+
E_ECHO_RR_GRAPH_INDEXED_DATA,
5051

5152
//Timing Graphs
5253
E_ECHO_PRE_PACKING_TIMING_GRAPH,

vpr/src/route/rr_graph_indexed_data.cpp

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include <cmath> /* Needed only for sqrt call (remove if sqrt removed) */
2+
#include <fstream>
3+
#include <iomanip>
24

35
#include "vtr_assert.h"
46
#include "vtr_log.h"
@@ -14,6 +16,8 @@
1416
#include "rr_graph_indexed_data.h"
1517
#include "read_xml_arch_file.h"
1618

19+
#include "echo_files.h"
20+
1721
/******************* Subroutines local to this module ************************/
1822

1923
static void load_rr_indexed_data_base_costs(enum e_base_cost_type base_cost_type);
@@ -28,7 +32,7 @@ static void fixup_rr_indexed_data_T_values(size_t num_segment);
2832

2933
static std::vector<size_t> count_rr_segment_types();
3034

31-
static void print_rr_index_info(const std::vector<t_segment_inf>& segment_inf);
35+
static void print_rr_index_info(const char* fname, const std::vector<t_segment_inf>& segment_inf);
3236

3337
/******************** Subroutine definitions *********************************/
3438

@@ -115,7 +119,10 @@ void alloc_and_load_rr_indexed_data(const std::vector<t_segment_inf>& segment_in
115119

116120
load_rr_indexed_data_base_costs(base_cost_type);
117121

118-
if (false) print_rr_index_info(segment_inf);
122+
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA)) {
123+
print_rr_index_info(getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA),
124+
segment_inf);
125+
}
119126
}
120127

121128
void load_rr_index_segments(const int num_segment) {
@@ -269,7 +276,18 @@ static float get_delay_normalization_fac() {
269276
Tdel_num += 1;
270277
}
271278

272-
return Tdel_sum / Tdel_num;
279+
float delay_norm_fac = Tdel_sum / Tdel_num;
280+
281+
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA)) {
282+
std::ofstream out_file;
283+
284+
out_file.open(getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA));
285+
out_file << "Delay normalization factor: " << delay_norm_fac << std::endl;
286+
287+
out_file.close();
288+
}
289+
290+
return delay_norm_fac;
273291
}
274292

275293
static void load_rr_indexed_data_T_values() {
@@ -471,32 +489,50 @@ static void fixup_rr_indexed_data_T_values(size_t num_segment) {
471489
}
472490
}
473491

474-
static void print_rr_index_info(const std::vector<t_segment_inf>& segment_inf) {
492+
static void print_rr_index_info(const char* fname, const std::vector<t_segment_inf>& segment_inf) {
475493
auto& device_ctx = g_vpr_ctx.device();
476494

495+
std::ofstream out_file;
496+
497+
out_file.open(fname, std::ios_base::app);
498+
out_file << std::left << std::setw(30) << "Cost Index";
499+
out_file << std::left << std::setw(20) << "Base Cost";
500+
out_file << std::left << std::setw(20) << "Ortho Cost Index";
501+
out_file << std::left << std::setw(20) << "Seg Index";
502+
out_file << std::left << std::setw(20) << "Inv. Length";
503+
out_file << std::left << std::setw(20) << "T. Linear";
504+
out_file << std::left << std::setw(20) << "T. Quadratic";
505+
out_file << std::left << std::setw(20) << "C. Load" << std::endl;
477506
for (size_t cost_index = 0; cost_index < device_ctx.rr_indexed_data.size(); ++cost_index) {
478507
auto& index_data = device_ctx.rr_indexed_data[cost_index];
479508

509+
std::ostringstream string_stream;
510+
480511
if (cost_index == SOURCE_COST_INDEX) {
481-
VTR_LOG("Cost Index %zu SOURCE\n", cost_index);
512+
string_stream << cost_index << " SOURCE";
482513
} else if (cost_index == SINK_COST_INDEX) {
483-
VTR_LOG("Cost Index %zu SINK\n", cost_index);
514+
string_stream << cost_index << " SINK";
484515
} else if (cost_index == OPIN_COST_INDEX) {
485-
VTR_LOG("Cost Index %zu OPIN\n", cost_index);
516+
string_stream << cost_index << " OPIN";
486517
} else if (cost_index == IPIN_COST_INDEX) {
487-
VTR_LOG("Cost Index %zu IPIN\n", cost_index);
518+
string_stream << cost_index << " IPIN";
488519
} else if (cost_index <= IPIN_COST_INDEX + segment_inf.size()) {
489-
VTR_LOG("Cost Index %zu CHANX %s\n", cost_index, segment_inf[index_data.seg_index].name.c_str());
520+
string_stream << cost_index << " CHANX " << segment_inf[index_data.seg_index].name.c_str();
490521
} else {
491-
VTR_LOG("Cost Index %zu CHANY %s\n", cost_index, segment_inf[index_data.seg_index].name.c_str());
522+
string_stream << cost_index << " CHANY " << segment_inf[index_data.seg_index].name.c_str();
492523
}
493524

494-
VTR_LOG("\tbase_cost=%g\n", index_data.base_cost);
495-
VTR_LOG("\tortho_cost_index=%d\n", index_data.ortho_cost_index);
496-
VTR_LOG("\tseg_index=%d\n", index_data.seg_index);
497-
VTR_LOG("\tinv_length=%g\n", index_data.inv_length);
498-
VTR_LOG("\tT_linear=%g\n", index_data.T_linear);
499-
VTR_LOG("\tT_quadratic=%g\n", index_data.T_quadratic);
500-
VTR_LOG("\tC_load=%g\n", index_data.C_load);
525+
std::string cost_index_str = string_stream.str();
526+
527+
out_file << std::left << std::setw(30) << cost_index_str;
528+
out_file << std::left << std::setw(20) << index_data.base_cost;
529+
out_file << std::left << std::setw(20) << index_data.ortho_cost_index;
530+
out_file << std::left << std::setw(20) << index_data.seg_index;
531+
out_file << std::left << std::setw(20) << index_data.inv_length;
532+
out_file << std::left << std::setw(20) << index_data.T_linear;
533+
out_file << std::left << std::setw(20) << index_data.T_quadratic;
534+
out_file << std::left << std::setw(20) << index_data.C_load << std::endl;
501535
}
536+
537+
out_file.close();
502538
}

0 commit comments

Comments
 (0)