Skip to content

Commit 0fe92d4

Browse files
litghostkmurray
authored andcommitted
Factor rr indexed data fixup into function.
Signed-off-by: Keith Rothman <[email protected]>
1 parent 53b178b commit 0fe92d4

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

vpr/src/route/rr_graph_indexed_data.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ static void load_rr_indexed_data_T_values(int index_start,
2929
int nodes_per_chan,
3030
const t_rr_node_indices& L_rr_node_indices);
3131

32+
static void fixup_rr_indexed_data_T_values(size_t num_segment);
33+
3234
static std::vector<size_t> count_rr_segment_types();
3335

3436
/******************** Subroutine definitions *********************************/
@@ -115,27 +117,7 @@ void alloc_and_load_rr_indexed_data(const std::vector<t_segment_inf>& segment_in
115117
load_rr_indexed_data_T_values((CHANX_COST_INDEX_START + num_segment),
116118
num_segment, CHANY, nodes_per_chan, L_rr_node_indices);
117119

118-
// Scan CHANX/CHANY indexed data and search for uninitialized costs.
119-
//
120-
// This would occur if a segment ends up only being used as CHANX or a
121-
// CHANY, but not both. If this occurs, then copying the orthogonal
122-
// pair's cost data is likely a better choice than leaving it as -1.
123-
//
124-
// The primary reason for this fixup is to avoid propagating negative
125-
// values in cost functions.
126-
for (int cost_index = CHANX_COST_INDEX_START;
127-
cost_index < CHANX_COST_INDEX_START + 2 * num_segment; cost_index++) {
128-
int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
129-
130-
// Check if this data is uninitialized, but the orthogonal data is
131-
// initialized.
132-
if (device_ctx.rr_indexed_data[cost_index].T_linear == OPEN && device_ctx.rr_indexed_data[ortho_cost_index].T_linear != OPEN) {
133-
// Copy orthogonal data over.
134-
device_ctx.rr_indexed_data[cost_index].T_linear = device_ctx.rr_indexed_data[ortho_cost_index].T_linear;
135-
device_ctx.rr_indexed_data[cost_index].T_quadratic = device_ctx.rr_indexed_data[ortho_cost_index].T_quadratic;
136-
device_ctx.rr_indexed_data[cost_index].C_load = device_ctx.rr_indexed_data[ortho_cost_index].C_load;
137-
}
138-
}
120+
fixup_rr_indexed_data_T_values(num_segment);
139121

140122
load_rr_indexed_data_base_costs(nodes_per_chan, L_rr_node_indices,
141123
base_cost_type);
@@ -448,3 +430,29 @@ static void load_rr_indexed_data_T_values(int index_start,
448430
free(switch_Cinternal_total);
449431
free(switches_buffered);
450432
}
433+
434+
static void fixup_rr_indexed_data_T_values(size_t num_segment) {
435+
auto& device_ctx = g_vpr_ctx.mutable_device();
436+
437+
// Scan CHANX/CHANY indexed data and search for uninitialized costs.
438+
//
439+
// This would occur if a segment ends up only being used as CHANX or a
440+
// CHANY, but not both. If this occurs, then copying the orthogonal
441+
// pair's cost data is likely a better choice than leaving it as -1.
442+
//
443+
// The primary reason for this fixup is to avoid propagating negative
444+
// values in cost functions.
445+
for (size_t cost_index = CHANX_COST_INDEX_START;
446+
cost_index < CHANX_COST_INDEX_START + 2 * num_segment; cost_index++) {
447+
int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
448+
449+
// Check if this data is uninitialized, but the orthogonal data is
450+
// initialized.
451+
if (device_ctx.rr_indexed_data[cost_index].T_linear == OPEN && device_ctx.rr_indexed_data[ortho_cost_index].T_linear != OPEN) {
452+
// Copy orthogonal data over.
453+
device_ctx.rr_indexed_data[cost_index].T_linear = device_ctx.rr_indexed_data[ortho_cost_index].T_linear;
454+
device_ctx.rr_indexed_data[cost_index].T_quadratic = device_ctx.rr_indexed_data[ortho_cost_index].T_quadratic;
455+
device_ctx.rr_indexed_data[cost_index].C_load = device_ctx.rr_indexed_data[ortho_cost_index].C_load;
456+
}
457+
}
458+
}

0 commit comments

Comments
 (0)