Skip to content

Commit f6e809e

Browse files
committed
Code review update: enhance more documentations. Added function level description for three routines in place.cpp: find_affected_sink_pins(), commit_td_cost(), invalidate_affected_connection_delays().
1 parent 23e8782 commit f6e809e

File tree

7 files changed

+131
-60
lines changed

7 files changed

+131
-60
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ If any of init_t, exit_t or alpha_t is specified, the user schedule, with a fixe
715715
.. option:: --place_quench_algorithm {bounding_box | criticality_timing | slack_timing}
716716

717717
Controls the algorithm used by the placer during placement quench.
718-
The algorithm options have identical functionality as the ones used by the option ``--place_algorithm``.
718+
The algorithm options have identical functionality as the ones used by the option ``--place_algorithm``. If specified, it overrides the option ``--place_algorithm`` during placement quench.
719719

720720
**Default:** ``criticality_timing``
721721

vpr/src/base/read_options.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ struct ParsePlaceAlgorithm {
359359
} else {
360360
std::stringstream msg;
361361
msg << "Invalid conversion from '" << str << "' to e_place_algorithm (expected one of: " << argparse::join(default_choices(), ", ") << ")";
362+
363+
//Deprecated option: "path_timing_driven" -> PATH_DRIVEN_TIMING_PLACE
364+
//New option: "criticality_timing" -> CRITICALITY_TIMING_PLACE
365+
if (str == "path_timing_driven") {
366+
msg << "\nDeprecated option: 'path_timing_driven'. It has been renamed to 'criticality_timing'";
367+
}
368+
362369
conv_value.set_error(msg.str());
363370
}
364371
return conv_value;
@@ -1694,7 +1701,9 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
16941701

16951702
place_grp.add_argument<e_place_algorithm, ParsePlaceAlgorithm>(args.PlaceQuenchAlgorithm, "--place_quench_algorithm")
16961703
.help(
1697-
"Controls which placement algorithm is used during placement quench. Valid options:\n"
1704+
"Controls which placement algorithm is used during placement quench.\n"
1705+
"If specified, it overrides the option --place_algorithm during placement quench.\n"
1706+
"Valid options:\n"
16981707
" * bounding_box: Focuses purely on minimizing the bounding box wirelength of the circuit. Turns off timing analysis if specified.\n"
16991708
" * criticality_timing: Focuses on minimizing both the wirelength and the connection timing costs (criticality * delay).\n"
17001709
" * slack_timing: Focuses on improving the circuit slack values to reduce critical path delay.\n")

vpr/src/base/vpr_types.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ enum e_place_algorithm {
859859
/**
860860
* @brief Provides a wrapper around enum e_place_algorithm.
861861
*
862-
* Supports the method isTimingDriven(), which allows flexible updates
862+
* Supports the method is_timing_driven(), which allows flexible updates
863863
* to the placer algorithms if more timing driven placement strategies
864864
* are added in tht future. This method is used across various placement
865865
* setup files, and it can be useful for major placer routines as well.
@@ -879,8 +879,14 @@ class t_place_algorithm {
879879
~t_place_algorithm() = default;
880880

881881
//Assignment operators
882-
void operator=(const t_place_algorithm& rhs) { algo = rhs.algo; }
883-
void operator=(e_place_algorithm rhs) { algo = rhs; }
882+
t_place_algorithm& operator=(const t_place_algorithm& rhs) {
883+
algo = rhs.algo;
884+
return *this;
885+
}
886+
t_place_algorithm& operator=(e_place_algorithm rhs) {
887+
algo = rhs;
888+
return *this;
889+
}
884890

885891
//Equality operators
886892
bool operator==(const t_place_algorithm& rhs) const { return algo == rhs.algo; }
@@ -953,28 +959,31 @@ enum class e_place_delta_delay_algorithm {
953959
* @param place_chan_width
954960
* The channel width assumed if only one placement is performed.
955961
* @param pad_loc_type
956-
* Are pins FREE, fixed randomly, or fixed from a file.
957-
* @param block_loc_type
958-
* Are blocks fixed from a file.
962+
* Are pins FREE or fixed randomly.
959963
* @param constraints_file
960-
* File to read block locations from if block_loc_type is LOCKED.
964+
* File that specifies locations of locked down (constrained)
965+
* blocks for placement. Empty string means no constraints file.
961966
* @param pad_loc_file
962967
* File to read pad locations from if pad_loc_type is USER.
963968
* @param place_freq
964969
* Should the placement be skipped, done once, or done
965970
* for each channel width in the binary search.
966971
* @param recompute_crit_iter
967972
* How many temperature stages pass before we recompute
968-
* criticalities based on average point to point delay.
973+
* criticalities based on the current placement and its
974+
* estimated point-to-point delays.
969975
* @param inner_loop_crit_divider
970976
* (move_lim/inner_loop_crit_divider) determines how
971977
* many inner_loop iterations pass before a recompute
972978
* of criticalities is done.
973979
* @param td_place_exp_first
974980
* Exponent that is used in the CRITICALITY_TIMING_PLACE
975-
* mode. It is the value that the crit_exponent starts at.
981+
* mode to specify the initial value of `crit_exponent`.
982+
* After we map the slacks to criticalities, this value
983+
* is used to `sharpen` the criticalities, making connections
984+
* with worse slacks more critical.
976985
* @param td_place_exp_last
977-
* Value that the criticality exponent will be at the end.
986+
* Value that the crit_exponent will be at the end.
978987
* @param doPlacement
979988
* True if placement is supposed to be done in the CAD flow.
980989
* False if otherwise.

vpr/src/place/place.cpp

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,9 +1653,13 @@ static e_move_result try_swap(float t,
16531653
std::vector<ClusterPinId> sink_pins_affected;
16541654
find_affected_sink_pins(blocks_affected, sink_pins_affected);
16551655

1656+
//For setup slack analysis, we first do a timing analysis to get the newest slack values
1657+
//resulted from the proposed block moves. If the move turns out to be accepted, we keep
1658+
//the updated slack values and commit the block moves. If rejected, we reject the proposed
1659+
//block moves and revert this timing analysis.
16561660
if (place_algorithm == SLACK_TIMING_PLACE) {
1657-
//Invalidates timing of modified connections for incremental timing updates
1658-
//This routine relies on comparing proposed_connection_delay and connection_delay
1661+
//Gather all the connections with modified delays for incremental timing updates.
1662+
//This routine relies on comparing proposed_connection_delay and connection_delay.
16591663
invalidate_affected_connection_delays(sink_pins_affected,
16601664
pin_timing_invalidator,
16611665
timing_info);
@@ -1749,7 +1753,9 @@ static e_move_result try_swap(float t,
17491753
comp_td_connection_delays(delay_model);
17501754
comp_td_costs(delay_model, *criticalities, &costs->timing_cost);
17511755

1752-
//Re-invalidate the affected sink pins
1756+
//Re-invalidate the affected sink pins since the proposed move is
1757+
//rejected, and the same blocks are reverted to their original
1758+
//positions. The affected sink pins should stay the same.
17531759
invalidate_affected_connection_delays(sink_pins_affected,
17541760
pin_timing_invalidator,
17551761
timing_info);
@@ -1946,19 +1952,23 @@ static void update_td_delta_costs(const PlaceDelayModel* delay_model,
19461952
}
19471953
}
19481954

1955+
/**
1956+
* @brief Find all the sink pins with changed connection delays from the affected blocks.
1957+
*
1958+
* These sink pins will be passed into the pin_timing_invalidator for timing update.
1959+
* They will also be added to the pin invalidator when we wish to revert a timing update.
1960+
*
1961+
* It is possible that some connections may not have changed delay. For instance, if
1962+
* using a dx/dy delay model, this could occur if a sink moved to a new position with
1963+
* the same dx/dy from it's driver. To minimize work during the incremental STA update
1964+
* we do not invalidate such unchanged connections.
1965+
*/
19491966
static void find_affected_sink_pins(const t_pl_blocks_to_be_moved& blocks_affected,
19501967
std::vector<ClusterPinId>& sink_pins_affected) {
19511968
auto& cluster_ctx = g_vpr_ctx.clustering();
19521969
auto& clb_nlist = cluster_ctx.clb_nlist;
19531970

19541971
for (ClusterPinId clb_pin : blocks_affected.affected_pins) {
1955-
//It is possible that some connections may not have changed delay.(e.g.
1956-
//For instance, if using a dx/dy delay model, this could occur if a sink
1957-
//moved to a new position with the same dx/dy from it's driver.
1958-
//
1959-
//To minimize work during the incremental STA update we do not invalidate
1960-
//such unchanged connections.
1961-
19621972
ClusterNetId net = clb_nlist.pin_net(clb_pin);
19631973
int ipin = clb_nlist.pin_net_index(clb_pin);
19641974

@@ -2178,8 +2188,13 @@ static bool verify_connection_setup_slacks(const PlacerSetupSlacks* setup_slacks
21782188
return true;
21792189
}
21802190

2181-
/* Update the connection_timing_cost values from the temporary *
2182-
* values for all connections that have changed. */
2191+
/**
2192+
* @brief Update the connection_timing_cost values from the temporary
2193+
* values for all connections that have/haven't changed.
2194+
*
2195+
* All the connections have already been gathered by blocks_affected.affected_pins
2196+
* after running the routine find_affected_nets_and_update_costs() in try_swap().
2197+
*/
21832198
static void commit_td_cost(const t_pl_blocks_to_be_moved& blocks_affected) {
21842199
auto& cluster_ctx = g_vpr_ctx.clustering();
21852200
auto& clb_nlist = cluster_ctx.clb_nlist;
@@ -2217,10 +2232,15 @@ static void revert_td_cost(const t_pl_blocks_to_be_moved& blocks_affected) {
22172232
#endif
22182233
}
22192234

2220-
//Invalidates the delays of connections effected by the specified move
2221-
//
2222-
//Relies on proposed_connection_delay and connection_delay to detect
2223-
//which connections have actually had their delay changed.
2235+
/**
2236+
* @brief Invalidates the delays of connections effected by the specified move.
2237+
*
2238+
* Relies on find_affected_sink_pins() to find all the connections with different
2239+
* `proposed_connection_delay` and `connection_delay`.
2240+
*
2241+
* Invalidate all the timing graph edges associated with these sink pins via the
2242+
* ClusteredPinTimingInvalidator class.
2243+
*/
22242244
static void invalidate_affected_connection_delays(const std::vector<ClusterPinId>& sink_pins_affected,
22252245
ClusteredPinTimingInvalidator* pin_tedges_invalidator,
22262246
TimingInfo* timing_info) {
@@ -2229,12 +2249,6 @@ static void invalidate_affected_connection_delays(const std::vector<ClusterPinId
22292249

22302250
//Invalidate timing graph edges affected by the move
22312251
for (ClusterPinId clb_pin : sink_pins_affected) {
2232-
//It is possible that some connections may not have changed delay.
2233-
//For instance, if using a dx/dy delay model, this could occur if a sink
2234-
//moved to a new position with the same dx/dy from it's driver.
2235-
//
2236-
//To minimize work during the incremental STA update we do not invalidate
2237-
//such unchanged connections.
22382252
pin_tedges_invalidator->invalidate_connection(clb_pin, timing_info);
22392253
}
22402254
}

vpr/src/place/timing_place.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
#include "timing_info.h"
2121

22-
///@brief Use an incremental approach to updating criticalities and setup slacks?
23-
static constexpr bool INCR_UPDATE_CRITICALITIES = true, INCR_UPDATE_SETUP_SLACKS = true;
24-
2522
///@brief Allocates space for the timing_place_crit_ data structure.
2623
PlacerCriticalities::PlacerCriticalities(const ClusteredNetlist& clb_nlist, const ClusteredPinAtomPinsLookup& netlist_pin_lookup)
2724
: clb_nlist_(clb_nlist)
@@ -48,7 +45,7 @@ void PlacerCriticalities::update_criticalities(const SetupTimingInfo* timing_inf
4845
}
4946

5047
/* Determine what pins need updating */
51-
if (!recompute_required && crit_exponent == last_crit_exponent_ && INCR_UPDATE_CRITICALITIES) {
48+
if (!recompute_required && crit_exponent == last_crit_exponent_) {
5249
incr_update_criticalities(timing_info);
5350
} else {
5451
recompute_criticalities();
@@ -123,8 +120,11 @@ void PlacerCriticalities::recompute_criticalities() {
123120
}
124121

125122
///@brief Override the criticality of a particular connection.
126-
void PlacerCriticalities::set_criticality(ClusterNetId net_id, int ipin, float val) {
127-
timing_place_crit_[net_id][ipin] = val;
123+
void PlacerCriticalities::set_criticality(ClusterNetId net_id, int ipin, float crit_val) {
124+
VTR_ASSERT_SAFE_MSG(ipin > 0, "The pin should not be a driver pin (ipin = 0)");
125+
VTR_ASSERT_SAFE_MSG(ipin < clb_nlist_.net_pins(net_id).size(), "The pin index in net should be smaller than fanout");
126+
127+
timing_place_crit_[net_id][ipin] = crit_val;
128128
}
129129

130130
/**
@@ -163,7 +163,7 @@ void PlacerSetupSlacks::update_setup_slacks(const SetupTimingInfo* timing_info)
163163
}
164164

165165
/* Determine what pins need updating */
166-
if (!recompute_required && INCR_UPDATE_SETUP_SLACKS) {
166+
if (!recompute_required) {
167167
incr_update_setup_slacks(timing_info);
168168
} else {
169169
recompute_setup_slacks();
@@ -223,8 +223,11 @@ void PlacerSetupSlacks::recompute_setup_slacks() {
223223
}
224224

225225
///@brief Override the setup slack of a particular connection.
226-
void PlacerSetupSlacks::set_setup_slack(ClusterNetId net_id, int ipin, float val) {
227-
timing_place_setup_slacks_[net_id][ipin] = val;
226+
void PlacerSetupSlacks::set_setup_slack(ClusterNetId net_id, int ipin, float slack_val) {
227+
VTR_ASSERT_SAFE_MSG(ipin > 0, "The pin should not be a driver pin (ipin = 0)");
228+
VTR_ASSERT_SAFE_MSG(ipin < clb_nlist_.net_pins(net_id).size(), "The pin index in net should be smaller than fanout");
229+
230+
timing_place_setup_slacks_[net_id][ipin] = slack_val;
228231
}
229232

230233
/**

0 commit comments

Comments
 (0)