@@ -534,7 +534,8 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
534534 vtr::vector<RRIndexedDataId, std::vector<float >> switch_Cinternal_total (rr_indexed_data.size ());
535535 vtr::vector<RRIndexedDataId, short > switches_buffered (rr_indexed_data.size (), LIBRRGRAPH_UNDEFINED_VAL);
536536
537- std::map<short , size_t > ipin_switch_count;
537+ size_t ipin_switch_count = 0 ;
538+ float ipin_switch_T_total = 0 .;
538539
539540 // Walk through the RR graph and collect all R and C values of all the nodes,
540541 // as well as their fan-in switches R, T_del, and Cinternal values.
@@ -544,12 +545,9 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
544545
545546 if (rr_type == e_rr_type::IPIN) {
546547 for (const RREdgeId edge : fan_in_list[rr_id]) {
547- short switch_index = rr_graph.rr_nodes ().edge_switch (edge);
548- if (ipin_switch_count.find (switch_index) == ipin_switch_count.end ()) {
549- ipin_switch_count[switch_index] = 1 ;
550- } else {
551- ipin_switch_count[switch_index]++;
552- }
548+ RRSwitchId rr_switch_id = RRSwitchId (rr_graph.edge_switch (edge));
549+ ipin_switch_T_total += rr_graph.rr_switch_inf (rr_switch_id).Tdel ;
550+ ipin_switch_count++;
553551 }
554552 }
555553
@@ -614,22 +612,16 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
614612 }
615613 }
616614
617- short most_frequent_ipin_switch = -1 ;
618- size_t most_frequent_ipin_switch_count = 0 ;
619- for (const auto & [switch_index, count] : ipin_switch_count) {
620- if (count > most_frequent_ipin_switch_count) {
621- most_frequent_ipin_switch = switch_index;
622- most_frequent_ipin_switch_count = count;
615+ // Set the T_linear value for the IPIN cost index
616+ {
617+ if (ipin_switch_count == 0 ) {
618+ VTR_LOG_WARN (" No IPIN switches found. Setting T_linear to 0\n " );
619+ float default_ipin_switch_T_del = rr_graph.rr_switch_inf (RRSwitchId (wire_to_ipin_switch)).Tdel ;
620+ rr_indexed_data[RRIndexedDataId (IPIN_COST_INDEX)].T_linear = default_ipin_switch_T_del;
621+ } else {
622+ rr_indexed_data[RRIndexedDataId (IPIN_COST_INDEX)].T_linear = ipin_switch_T_total / ipin_switch_count;
623623 }
624624 }
625- VTR_ASSERT (most_frequent_ipin_switch != -1 );
626- rr_indexed_data[RRIndexedDataId (IPIN_COST_INDEX)].T_linear = rr_graph.rr_switch_inf (RRSwitchId (most_frequent_ipin_switch)).Tdel ;
627- short wire_to_ipin_switch_index = static_cast <short >(size_t (wire_to_ipin_switch));
628- if (most_frequent_ipin_switch != wire_to_ipin_switch_index) {
629- VTR_LOG_WARN (" Most frequent ipin switch %d is not the same as the wire_to_ipin_switch %d\n " ,
630- most_frequent_ipin_switch,
631- wire_to_ipin_switch_index);
632- }
633625
634626 unsigned num_occurences_of_no_instances_with_cost_index = 0 ;
635627 for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < rr_indexed_data.size (); cost_index++) {
0 commit comments