@@ -1982,75 +1982,71 @@ static void mark_and_update_partial_gain(const AtomNetId net_id, enum e_gain_upd
1982
1982
t_pb* cur_pb = atom_ctx.lookup .atom_pb (clustered_blk_id)->parent_pb ;
1983
1983
cur_pb = get_top_level_pb (cur_pb);
1984
1984
1985
- if (int (atom_ctx.nlist .net_sinks (net_id).size ()) > high_fanout_net_threshold) {
1986
- /* Optimization: It can be too runtime costly for marking all sinks for
1987
- * a high fanout-net that probably has no hope of ever getting packed,
1988
- * thus ignore those high fanout nets */
1989
- if (!is_global.count (net_id)) {
1990
- /* If no low/medium fanout nets, we may need to consider
1991
- * high fan-out nets for packing, so select one and store it */
1992
- while (cur_pb->parent_pb != nullptr ) {
1993
- cur_pb = cur_pb->parent_pb ;
1994
- }
1995
- AtomNetId stored_net = cur_pb->pb_stats ->tie_break_high_fanout_net ;
1996
- if (!stored_net || atom_ctx.nlist .net_sinks (net_id).size () < atom_ctx.nlist .net_sinks (stored_net).size ()) {
1997
- cur_pb->pb_stats ->tie_break_high_fanout_net = net_id;
1998
- }
1999
- }
2000
- return ;
2001
- }
1985
+ if (int (atom_ctx.nlist .net_sinks (net_id).size ()) > high_fanout_net_threshold) {
1986
+ /* Optimization: It can be too runtime costly for marking all sinks for
1987
+ * a high fanout-net that probably has no hope of ever getting packed,
1988
+ * thus ignore those high fanout nets */
1989
+ if (!is_global.count (net_id)) {
1990
+ /* If no low/medium fanout nets, we may need to consider
1991
+ * high fan-out nets for packing, so select one and store it */
1992
+ AtomNetId stored_net = cur_pb->pb_stats ->tie_break_high_fanout_net ;
1993
+ if (!stored_net || atom_ctx.nlist .net_sinks (net_id).size () < atom_ctx.nlist .net_sinks (stored_net).size ()) {
1994
+ cur_pb->pb_stats ->tie_break_high_fanout_net = net_id;
1995
+ }
1996
+ }
1997
+ return ;
1998
+ }
2002
1999
2003
2000
/* Mark atom net as being visited, if necessary. */
2004
2001
2005
- if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2006
- cur_pb->pb_stats ->marked_nets .push_back (net_id);
2007
- }
2008
-
2009
- /* Update gains of affected blocks. */
2010
-
2011
- if (gain_flag == GAIN) {
2012
- /* Check if this net is connected to it's driver block multiple times (i.e. as both an output and input)
2013
- * If so, avoid double counting by skipping the first (driving) pin. */
2014
-
2015
- auto pins = atom_ctx.nlist .net_pins (net_id);
2016
- if (net_output_feeds_driving_block_input[net_id] != 0 )
2017
- // We implicitly assume here that net_output_feeds_driver_block_input[net_id] is 2
2018
- // (i.e. the net loops back to the block only once)
2019
- pins = atom_ctx.nlist .net_sinks (net_id);
2020
-
2021
- if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2022
- for (auto pin_id : pins) {
2023
- auto blk_id = atom_ctx.nlist .pin_block (pin_id);
2024
- if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()) {
2025
- if (cur_pb->pb_stats ->sharinggain .count (blk_id) == 0 ) {
2026
- cur_pb->pb_stats ->marked_blocks .push_back (blk_id);
2027
- cur_pb->pb_stats ->sharinggain [blk_id] = 1 ;
2028
- cur_pb->pb_stats ->hillgain [blk_id] = 1 - num_ext_inputs_atom_block (blk_id);
2029
- } else {
2030
- cur_pb->pb_stats ->sharinggain [blk_id]++;
2031
- cur_pb->pb_stats ->hillgain [blk_id]++;
2032
- }
2033
- }
2034
- }
2035
- }
2036
-
2037
- if (connection_driven) {
2038
- update_connection_gain_values (net_id, clustered_blk_id, cur_pb,
2039
- net_relation_to_clustered_block);
2040
- }
2041
-
2042
- if (timing_driven) {
2043
- update_timing_gain_values (net_id, cur_pb,
2044
- net_relation_to_clustered_block,
2045
- timing_info,
2046
- is_global);
2047
- }
2048
- }
2049
- if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2050
- cur_pb->pb_stats ->num_pins_of_net_in_pb [net_id] = 0 ;
2051
- }
2052
- cur_pb->pb_stats ->num_pins_of_net_in_pb [net_id]++;
2002
+ if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2003
+ cur_pb->pb_stats ->marked_nets .push_back (net_id);
2004
+ }
2005
+
2006
+ /* Update gains of affected blocks. */
2007
+
2008
+ if (gain_flag == GAIN) {
2009
+ /* Check if this net is connected to it's driver block multiple times (i.e. as both an output and input)
2010
+ * If so, avoid double counting by skipping the first (driving) pin. */
2011
+
2012
+ auto pins = atom_ctx.nlist .net_pins (net_id);
2013
+ if (net_output_feeds_driving_block_input[net_id] != 0 )
2014
+ // We implicitly assume here that net_output_feeds_driver_block_input[net_id] is 2
2015
+ // (i.e. the net loops back to the block only once)
2016
+ pins = atom_ctx.nlist .net_sinks (net_id);
2017
+
2018
+ if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2019
+ for (auto pin_id : pins) {
2020
+ auto blk_id = atom_ctx.nlist .pin_block (pin_id);
2021
+ if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()) {
2022
+ if (cur_pb->pb_stats ->sharinggain .count (blk_id) == 0 ) {
2023
+ cur_pb->pb_stats ->marked_blocks .push_back (blk_id);
2024
+ cur_pb->pb_stats ->sharinggain [blk_id] = 1 ;
2025
+ cur_pb->pb_stats ->hillgain [blk_id] = 1 - num_ext_inputs_atom_block (blk_id);
2026
+ } else {
2027
+ cur_pb->pb_stats ->sharinggain [blk_id]++;
2028
+ cur_pb->pb_stats ->hillgain [blk_id]++;
2029
+ }
2030
+ }
2031
+ }
2032
+ }
2033
+
2034
+ if (connection_driven) {
2035
+ update_connection_gain_values (net_id, clustered_blk_id, cur_pb,
2036
+ net_relation_to_clustered_block);
2037
+ }
2053
2038
2039
+ if (timing_driven) {
2040
+ update_timing_gain_values (net_id, cur_pb,
2041
+ net_relation_to_clustered_block,
2042
+ timing_info,
2043
+ is_global);
2044
+ }
2045
+ }
2046
+ if (cur_pb->pb_stats ->num_pins_of_net_in_pb .count (net_id) == 0 ) {
2047
+ cur_pb->pb_stats ->num_pins_of_net_in_pb [net_id] = 0 ;
2048
+ }
2049
+ cur_pb->pb_stats ->num_pins_of_net_in_pb [net_id]++;
2054
2050
}
2055
2051
2056
2052
/* ****************************************/
@@ -2064,56 +2060,55 @@ static void update_total_gain(float alpha, float beta, bool timing_driven, bool
2064
2060
cur_pb = get_top_level_pb (cur_pb);
2065
2061
AttractGroupId cluster_att_grp_id;
2066
2062
2067
- cluster_att_grp_id = cur_pb->pb_stats ->attraction_grp_id ;
2068
-
2069
- for (AtomBlockId blk_id : cur_pb->pb_stats ->marked_blocks ) {
2070
- // Initialize connectiongain and sharinggain if
2071
- // they have not previously been updated for the block
2072
- if (cur_pb->pb_stats ->connectiongain .count (blk_id) == 0 ) {
2073
- cur_pb->pb_stats ->connectiongain [blk_id] = 0 ;
2074
- }
2075
- if (cur_pb->pb_stats ->sharinggain .count (blk_id) == 0 ) {
2076
- cur_pb->pb_stats ->sharinggain [blk_id] = 0 ;
2077
- }
2078
-
2079
- /* Todo: Right now we update the gain multiple times for each block.
2080
- * Eventually want to move this out of the while loop and only update it
2081
- * for the top-level block in each cluster.*/
2082
- AttractGroupId atom_grp_id = attraction_groups.get_atom_attraction_group (blk_id);
2083
- if (atom_grp_id != AttractGroupId::INVALID () && atom_grp_id == cluster_att_grp_id) {
2084
- // increase gain of atom based on attraction group gain
2085
- float att_grp_gain = attraction_groups.get_attraction_group_gain (atom_grp_id);
2086
- cur_pb->pb_stats ->gain [blk_id] += att_grp_gain;
2087
- }
2088
-
2089
- /* Todo: This was used to explore different normalization options, can
2090
- * be made more efficient once we decide on which one to use*/
2091
- int num_used_input_pins = atom_ctx.nlist .block_input_pins (blk_id).size ();
2092
- int num_used_output_pins = atom_ctx.nlist .block_output_pins (blk_id).size ();
2093
- /* end todo */
2094
-
2095
- /* Calculate area-only cost function */
2096
- int num_used_pins = num_used_input_pins + num_used_output_pins;
2097
- VTR_ASSERT (num_used_pins > 0 );
2098
- if (connection_driven) {
2099
- /* try to absorb as many connections as possible*/
2100
- cur_pb->pb_stats ->gain [blk_id] = ((1 - beta)
2101
- * (float )cur_pb->pb_stats ->sharinggain [blk_id]
2102
- + beta * (float )cur_pb->pb_stats ->connectiongain [blk_id])
2103
- / (num_used_pins);
2104
- } else {
2105
- cur_pb->pb_stats ->gain [blk_id] = ((float )cur_pb->pb_stats ->sharinggain [blk_id])
2106
- / (num_used_pins);
2107
- }
2108
-
2109
- /* Add in timing driven cost into cost function */
2110
- if (timing_driven) {
2111
- cur_pb->pb_stats ->gain [blk_id] = alpha
2112
- * cur_pb->pb_stats ->timinggain [blk_id]
2113
- + (1.0 - alpha) * (float )cur_pb->pb_stats ->gain [blk_id];
2114
- }
2115
- }
2063
+ cluster_att_grp_id = cur_pb->pb_stats ->attraction_grp_id ;
2064
+
2065
+ for (AtomBlockId blk_id : cur_pb->pb_stats ->marked_blocks ) {
2066
+ // Initialize connectiongain and sharinggain if
2067
+ // they have not previously been updated for the block
2068
+ if (cur_pb->pb_stats ->connectiongain .count (blk_id) == 0 ) {
2069
+ cur_pb->pb_stats ->connectiongain [blk_id] = 0 ;
2070
+ }
2071
+ if (cur_pb->pb_stats ->sharinggain .count (blk_id) == 0 ) {
2072
+ cur_pb->pb_stats ->sharinggain [blk_id] = 0 ;
2073
+ }
2116
2074
2075
+ /* Todo: Right now we update the gain multiple times for each block.
2076
+ * Eventually want to move this out of the while loop and only update it
2077
+ * for the top-level block in each cluster.*/
2078
+ AttractGroupId atom_grp_id = attraction_groups.get_atom_attraction_group (blk_id);
2079
+ if (atom_grp_id != AttractGroupId::INVALID () && atom_grp_id == cluster_att_grp_id) {
2080
+ // increase gain of atom based on attraction group gain
2081
+ float att_grp_gain = attraction_groups.get_attraction_group_gain (atom_grp_id);
2082
+ cur_pb->pb_stats ->gain [blk_id] += att_grp_gain;
2083
+ }
2084
+
2085
+ /* Todo: This was used to explore different normalization options, can
2086
+ * be made more efficient once we decide on which one to use*/
2087
+ int num_used_input_pins = atom_ctx.nlist .block_input_pins (blk_id).size ();
2088
+ int num_used_output_pins = atom_ctx.nlist .block_output_pins (blk_id).size ();
2089
+ /* end todo */
2090
+
2091
+ /* Calculate area-only cost function */
2092
+ int num_used_pins = num_used_input_pins + num_used_output_pins;
2093
+ VTR_ASSERT (num_used_pins > 0 );
2094
+ if (connection_driven) {
2095
+ /* try to absorb as many connections as possible*/
2096
+ cur_pb->pb_stats ->gain [blk_id] = ((1 - beta)
2097
+ * (float )cur_pb->pb_stats ->sharinggain [blk_id]
2098
+ + beta * (float )cur_pb->pb_stats ->connectiongain [blk_id])
2099
+ / (num_used_pins);
2100
+ } else {
2101
+ cur_pb->pb_stats ->gain [blk_id] = ((float )cur_pb->pb_stats ->sharinggain [blk_id])
2102
+ / (num_used_pins);
2103
+ }
2104
+
2105
+ /* Add in timing driven cost into cost function */
2106
+ if (timing_driven) {
2107
+ cur_pb->pb_stats ->gain [blk_id] = alpha
2108
+ * cur_pb->pb_stats ->timinggain [blk_id]
2109
+ + (1.0 - alpha) * (float )cur_pb->pb_stats ->gain [blk_id];
2110
+ }
2111
+ }
2117
2112
}
2118
2113
2119
2114
/* ****************************************/
0 commit comments