Skip to content

Commit 57837db

Browse files
committed
[libs][rr_graph] set T_linear for IPIN based on the most frequent switch connected to it
1 parent a632849 commit 57837db

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <algorithm>
44
#include <cmath> /* Needed only for sqrt call (remove if sqrt removed) */
5+
#include <cstddef>
56
#include <fstream>
67
#include <iomanip>
78
#include <numeric>
@@ -108,9 +109,6 @@ void alloc_and_load_rr_indexed_data(const RRGraphView& rr_graph,
108109
rr_indexed_data[RRIndexedDataId(i)].C_load = 0.;
109110
}
110111

111-
//TODO: SM: IPIN t_linear assumes wire_to_ipin_switch which corresponds to within die switch connection
112-
rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].T_linear = rr_graph.rr_switch_inf(wire_to_ipin_switch).Tdel;
113-
114112
std::vector<int> ortho_costs = find_ortho_cost_index(rr_graph, segment_inf_x, segment_inf_y, e_parallel_axis::X_AXIS);
115113

116114
/* AA: The code below should replace find_ortho_cost_index call once we deprecate the CLASSIC lookahead as it is the only lookahead
@@ -531,12 +529,25 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
531529
vtr::vector<RRIndexedDataId, std::vector<float>> switch_Cinternal_total(rr_indexed_data.size());
532530
vtr::vector<RRIndexedDataId, short> switches_buffered(rr_indexed_data.size(), LIBRRGRAPH_UNDEFINED_VAL);
533531

532+
std::map<short, int> ipin_switch_count;
533+
534534
// Walk through the RR graph and collect all R and C values of all the nodes,
535535
// as well as their fan-in switches R, T_del, and Cinternal values.
536536
// The median of R and C values for each cost index is assigned to the indexed data.
537537
for (const RRNodeId rr_id : rr_graph.nodes()) {
538538
e_rr_type rr_type = rr_graph.node_type(rr_id);
539539

540+
if (rr_type == e_rr_type::IPIN) {
541+
for (const RREdgeId edge : fan_in_list[rr_id]) {
542+
short switch_index = rr_graph.rr_nodes().edge_switch(edge);
543+
if (ipin_switch_count.find(switch_index) == ipin_switch_count.end()) {
544+
ipin_switch_count[switch_index] = 1;
545+
} else {
546+
ipin_switch_count[switch_index]++;
547+
}
548+
}
549+
}
550+
540551
if (!is_chanxy(rr_type) && !is_chanz(rr_type)) {
541552
continue;
542553
}
@@ -590,6 +601,16 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
590601
}
591602
}
592603

604+
int most_frequent_ipin_switch = -1;
605+
for (const auto& [switch_index, count] : ipin_switch_count) {
606+
if (count > most_frequent_ipin_switch_count) {
607+
most_frequent_ipin_switch = switch_index;
608+
}
609+
}
610+
VTR_ASSERT(most_frequent_ipin_switch != -1);
611+
rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].T_linear = rr_graph.rr_switch_inf(RRSwitchId(most_frequent_ipin_switch)).Tdel;
612+
613+
593614
unsigned num_occurences_of_no_instances_with_cost_index = 0;
594615
for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < rr_indexed_data.size(); cost_index++) {
595616
if (num_nodes_of_index[RRIndexedDataId(cost_index)] == 0) { // Segments don't exist.

0 commit comments

Comments
 (0)