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>
@@ -28,7 +29,9 @@ static void load_rr_indexed_data_base_costs(const RRGraphView& rr_graph,
2829
2930static float get_delay_normalization_fac (const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data, const bool echo_enabled, const char * echo_file_name);
3031
31- static void load_rr_indexed_data_T_values (const RRGraphView& rr_graph, vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data);
32+ static void load_rr_indexed_data_T_values (const RRGraphView& rr_graph,
33+ const RRSwitchId wire_to_ipin_switch,
34+ vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data);
3235
3336/* *
3437 * @brief Computes average R, Tdel, and Cinternal of fan-in switches for a given node.
@@ -49,7 +52,7 @@ static void calculate_average_switch(const RRGraphView& rr_graph,
4952 int & num_switches,
5053 int & num_shorts,
5154 short & buffered,
52- vtr::vector<RRNodeId, std::vector<RREdgeId>>& fan_in_list);
55+ const vtr::vector<RRNodeId, std::vector<RREdgeId>>& fan_in_list);
5356
5457static void fixup_rr_indexed_data_T_values (vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data, size_t num_segment);
5558
@@ -84,7 +87,7 @@ void alloc_and_load_rr_indexed_data(const RRGraphView& rr_graph,
8487 const std::vector<t_segment_inf>& segment_inf_y,
8588 const std::vector<t_segment_inf>& segment_inf_z,
8689 vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data,
87- RRSwitchId wire_to_ipin_switch,
90+ const RRSwitchId wire_to_ipin_switch,
8891 e_base_cost_type base_cost_type,
8992 const bool echo_enabled,
9093 const char * echo_file_name) {
@@ -108,9 +111,6 @@ void alloc_and_load_rr_indexed_data(const RRGraphView& rr_graph,
108111 rr_indexed_data[RRIndexedDataId (i)].C_load = 0 .;
109112 }
110113
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-
114114 std::vector<int > ortho_costs = find_ortho_cost_index (rr_graph, segment_inf_x, segment_inf_y, e_parallel_axis::X_AXIS);
115115
116116 /* AA: The code below should replace find_ortho_cost_index call once we deprecate the CLASSIC lookahead as it is the only lookahead
@@ -158,7 +158,9 @@ void alloc_and_load_rr_indexed_data(const RRGraphView& rr_graph,
158158 rr_indexed_data[index].seg_index = seg_ptr->seg_index ;
159159 }
160160
161- load_rr_indexed_data_T_values (rr_graph, rr_indexed_data);
161+ load_rr_indexed_data_T_values (rr_graph,
162+ wire_to_ipin_switch,
163+ rr_indexed_data);
162164
163165 fixup_rr_indexed_data_T_values (rr_indexed_data, total_num_segment);
164166
@@ -513,6 +515,7 @@ static float get_delay_normalization_fac(const vtr::vector<RRIndexedDataId, t_rr
513515 * - Placement Delay Matrix computation
514516 */
515517static void load_rr_indexed_data_T_values (const RRGraphView& rr_graph,
518+ const RRSwitchId wire_to_ipin_switch,
516519 vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data) {
517520 vtr::vector<RRNodeId, std::vector<RREdgeId>> fan_in_list = get_fan_in_list (rr_graph);
518521
@@ -531,12 +534,24 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
531534 vtr::vector<RRIndexedDataId, std::vector<float >> switch_Cinternal_total (rr_indexed_data.size ());
532535 vtr::vector<RRIndexedDataId, short > switches_buffered (rr_indexed_data.size (), LIBRRGRAPH_UNDEFINED_VAL);
533536
537+ size_t ipin_switch_count = 0 ;
538+ float ipin_switch_T_total = 0 .;
539+
534540 // Walk through the RR graph and collect all R and C values of all the nodes,
535541 // as well as their fan-in switches R, T_del, and Cinternal values.
536542 // The median of R and C values for each cost index is assigned to the indexed data.
537543 for (const RRNodeId rr_id : rr_graph.nodes ()) {
538544 e_rr_type rr_type = rr_graph.node_type (rr_id);
539545
546+ if (rr_type == e_rr_type::IPIN) {
547+ for (const RREdgeId edge : fan_in_list[rr_id]) {
548+ RRSwitchId rr_switch_id = RRSwitchId (rr_graph.edge_switch (edge));
549+ float switch_T_del = rr_graph.rr_switch_inf (rr_switch_id).Tdel ;
550+ ipin_switch_T_total += switch_T_del;
551+ ipin_switch_count++;
552+ }
553+ }
554+
540555 if (!is_chanxy (rr_type) && !is_chanz (rr_type)) {
541556 continue ;
542557 }
@@ -550,7 +565,15 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
550565 int num_switches = 0 ;
551566 int num_shorts = 0 ;
552567 short buffered = LIBRRGRAPH_UNDEFINED_VAL;
553- calculate_average_switch (rr_graph, rr_id, avg_switch_R, avg_switch_T, avg_switch_Cinternal, num_switches, num_shorts, buffered, fan_in_list);
568+ calculate_average_switch (rr_graph,
569+ rr_id,
570+ avg_switch_R,
571+ avg_switch_T,
572+ avg_switch_Cinternal,
573+ num_switches,
574+ num_shorts,
575+ buffered,
576+ fan_in_list);
554577
555578 if (num_switches == 0 ) {
556579 if (num_shorts == 0 ) {
@@ -590,6 +613,18 @@ static void load_rr_indexed_data_T_values(const RRGraphView& rr_graph,
590613 }
591614 }
592615
616+ // Set the T_linear value for the IPIN cost index
617+ {
618+ if (ipin_switch_count == 0 ) {
619+ VTR_LOG_WARN (" No IPIN switches found. Setting T_linear to 0\n " );
620+ float default_ipin_switch_T_del = rr_graph.rr_switch_inf (RRSwitchId (wire_to_ipin_switch)).Tdel ;
621+ rr_indexed_data[RRIndexedDataId (IPIN_COST_INDEX)].T_linear = default_ipin_switch_T_del;
622+ } else {
623+ float average_ipin_switch_T_del = ipin_switch_T_total / ipin_switch_count;
624+ rr_indexed_data[RRIndexedDataId (IPIN_COST_INDEX)].T_linear = average_ipin_switch_T_del;
625+ }
626+ }
627+
593628 unsigned num_occurences_of_no_instances_with_cost_index = 0 ;
594629 for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < rr_indexed_data.size (); cost_index++) {
595630 if (num_nodes_of_index[RRIndexedDataId (cost_index)] == 0 ) { // Segments don't exist.
@@ -650,7 +685,7 @@ static void calculate_average_switch(const RRGraphView& rr_graph,
650685 int & num_switches,
651686 int & num_shorts,
652687 short & buffered,
653- vtr::vector<RRNodeId, std::vector<RREdgeId>>& fan_in_list) {
688+ const vtr::vector<RRNodeId, std::vector<RREdgeId>>& fan_in_list) {
654689
655690 avg_switch_R = 0 ;
656691 avg_switch_T = 0 ;
0 commit comments