@@ -105,14 +105,27 @@ static float get_lemieux_cost_func(const int exponent, const bool both_sides, co
105
105
106
106
/* this annealer is used to adjust a desired wire or pin metric while keeping the other type of metric
107
107
* relatively constant */
108
- static bool annealer (const e_metric metric, const int nodes_per_chan, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const float target_metric, const float target_metric_tolerance, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics);
108
+ static bool annealer (const e_metric metric, const int nodes_per_chan, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const float target_metric, const float target_metric_tolerance, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics, vtr::RngContainer& rng );
109
109
/* updates temperature based on current temperature and the annealer's outer loop iteration */
110
110
static double update_temp (const double temp);
111
111
/* determines whether to accept or reject a proposed move based on the resulting delta of the cost and current temperature */
112
- static bool accept_move (const double del_cost, const double temp);
112
+ static bool accept_move (const double del_cost, const double temp, vtr::RngContainer& rng );
113
113
/* this function simply moves a switch from one track to another track (with an empty slot). The switch stays on the
114
114
* same pin as before. */
115
- static double try_move (const e_metric metric, const int nodes_per_chan, const float initial_orthogonal_metric, const float orthogonal_metric_tolerance, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const double cost, const double temp, const float target_metric, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics);
115
+ static double try_move (const e_metric metric,
116
+ const int nodes_per_chan,
117
+ const float initial_orthogonal_metric,
118
+ const float orthogonal_metric_tolerance,
119
+ const t_physical_tile_type_ptr block_type,
120
+ const e_pin_type pin_type,
121
+ const int Fc,
122
+ const int num_pin_type_pins,
123
+ const double cost,
124
+ const double temp,
125
+ const float target_metric,
126
+ int ***** pin_to_track_connections,
127
+ Conn_Block_Metrics* cb_metrics,
128
+ vtr::RngContainer& rng);
116
129
117
130
static void print_switch_histogram (const int nodes_per_chan, const Conn_Block_Metrics* cb_metrics);
118
131
@@ -157,9 +170,11 @@ void adjust_cb_metric(const e_metric metric, const float target, const float tar
157
170
get_conn_block_metrics (block_type, pin_to_track_connections, num_segments, segment_inf, pin_type,
158
171
Fc_array, chan_width_inf, &cb_metrics);
159
172
173
+
174
+ vtr::RngContainer rng (0 );
160
175
/* now run the annealer to adjust the desired metric towards the target value */
161
176
bool success = annealer (metric, nodes_per_chan, block_type, pin_type, Fc, num_pin_type_pins, target,
162
- target_tolerance, pin_to_track_connections, &cb_metrics);
177
+ target_tolerance, pin_to_track_connections, &cb_metrics, rng );
163
178
if (!success) {
164
179
VTR_LOG (" Failed to adjust specified connection block metric\n " );
165
180
}
@@ -658,15 +673,28 @@ static void find_tracks_unconnected_to_pin(const std::set<int>* pin_tracks, cons
658
673
659
674
/* this function simply moves a switch from one track to another track (with an empty slot). The switch stays on the
660
675
* same pin as before. */
661
- static double try_move (const e_metric metric, const int nodes_per_chan, const float initial_orthogonal_metric, const float orthogonal_metric_tolerance, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const double cost, const double temp, const float target_metric, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics) {
676
+ static double try_move (const e_metric metric,
677
+ const int nodes_per_chan,
678
+ const float initial_orthogonal_metric,
679
+ const float orthogonal_metric_tolerance,
680
+ const t_physical_tile_type_ptr block_type,
681
+ const e_pin_type pin_type,
682
+ const int Fc,
683
+ const int num_pin_type_pins,
684
+ const double cost,
685
+ const double temp,
686
+ const float target_metric,
687
+ int ***** pin_to_track_connections,
688
+ Conn_Block_Metrics* cb_metrics,
689
+ vtr::RngContainer& rng) {
662
690
double new_cost = 0 ;
663
691
float new_orthogonal_metric = 0 ;
664
692
float new_metric = 0 ;
665
693
666
694
/* will determine whether we should revert the attempted move at the end of this function */
667
695
bool revert = false ;
668
696
/* indicates whether or not we allow a track to be fully disconnected from all the pins of the connection block
669
- * in the processs of trying a move (to allow this, preserve_tracks is set to false) */
697
+ * in the process of trying a move (to allow this, preserve_tracks is set to false) */
670
698
const bool preserve_tracks = true ;
671
699
672
700
t_vec_vec_set* pin_to_tracks = &cb_metrics->pin_to_tracks ;
@@ -694,8 +722,8 @@ static double try_move(const e_metric metric, const int nodes_per_chan, const fl
694
722
set_of_tracks.clear ();
695
723
696
724
/* choose a random side, random pin, and a random switch */
697
- int rand_side = vtr:: irand (3 );
698
- int rand_pin_index = vtr:: irand (cb_metrics->pin_locations .at (rand_side).size () - 1 );
725
+ int rand_side = rng. irand (3 );
726
+ int rand_pin_index = rng. irand (cb_metrics->pin_locations .at (rand_side).size () - 1 );
699
727
int rand_pin = cb_metrics->pin_locations .at (rand_side).at (rand_pin_index);
700
728
std::set<int >* tracks_connected_to_pin = &pin_to_tracks->at (rand_side).at (rand_pin_index);
701
729
@@ -724,12 +752,12 @@ static double try_move(const e_metric metric, const int nodes_per_chan, const fl
724
752
new_cost = cost;
725
753
} else {
726
754
/* now choose a random track from the returned set of qualifying tracks */
727
- int old_track = vtr:: irand (set_of_tracks.size () - 1 );
755
+ int old_track = rng. irand (set_of_tracks.size () - 1 );
728
756
old_track = set_of_tracks.at (old_track);
729
757
730
758
/* next, get a new track connection i.e. one that is not already connected to our randomly chosen pin */
731
759
find_tracks_unconnected_to_pin (tracks_connected_to_pin, &track_to_pins->at (rand_side), &set_of_tracks);
732
- int new_track = vtr:: irand (set_of_tracks.size () - 1 );
760
+ int new_track = rng. irand (set_of_tracks.size () - 1 );
733
761
new_track = set_of_tracks.at (new_track);
734
762
735
763
/* move the rand_pin's connection from the old track to the new track and see what the new cost is */
@@ -781,7 +809,7 @@ static double try_move(const e_metric metric, const int nodes_per_chan, const fl
781
809
}
782
810
new_cost = fabs (target_metric - new_metric);
783
811
delta_cost = new_cost - cost;
784
- if (!accept_move (delta_cost, temp)) {
812
+ if (!accept_move (delta_cost, temp, rng )) {
785
813
revert = true ;
786
814
}
787
815
} else {
@@ -843,7 +871,7 @@ static double try_move(const e_metric metric, const int nodes_per_chan, const fl
843
871
844
872
/* this annealer is used to adjust a desired wire or pin metric while keeping the other type of metric
845
873
* relatively constant */
846
- static bool annealer (const e_metric metric, const int nodes_per_chan, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const float target_metric, const float target_metric_tolerance, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics) {
874
+ static bool annealer (const e_metric metric, const int nodes_per_chan, const t_physical_tile_type_ptr block_type, const e_pin_type pin_type, const int Fc, const int num_pin_type_pins, const float target_metric, const float target_metric_tolerance, int ***** pin_to_track_connections, Conn_Block_Metrics* cb_metrics, vtr::RngContainer& rng ) {
847
875
bool success = false ;
848
876
double temp = INITIAL_TEMP;
849
877
@@ -890,7 +918,8 @@ static bool annealer(const e_metric metric, const int nodes_per_chan, const t_ph
890
918
for (int i_inner = 0 ; i_inner < MAX_INNER_ITERATIONS; i_inner++) {
891
919
double new_cost = 0 ;
892
920
new_cost = try_move (metric, nodes_per_chan, initial_orthogonal_metric, orthogonal_metric_tolerance,
893
- block_type, pin_type, Fc, num_pin_type_pins, cost, temp, target_metric, pin_to_track_connections, cb_metrics);
921
+ block_type, pin_type, Fc, num_pin_type_pins, cost, temp, target_metric,
922
+ pin_to_track_connections, cb_metrics, rng);
894
923
895
924
/* update the cost after trying the move */
896
925
if (new_cost != cost) {
@@ -937,7 +966,7 @@ static double update_temp(const double temp) {
937
966
}
938
967
939
968
/* determines whether to accept or reject a proposed move based on the resulting delta of the cost and current temperature */
940
- static bool accept_move (const double del_cost, const double temp) {
969
+ static bool accept_move (const double del_cost, const double temp, vtr::RngContainer& rng ) {
941
970
bool accept = false ;
942
971
943
972
if (del_cost < 0 ) {
@@ -946,7 +975,7 @@ static bool accept_move(const double del_cost, const double temp) {
946
975
} else {
947
976
/* determine probabilistically whether or not to accept */
948
977
double probability = pow (2.718 , -(del_cost / temp));
949
- double rand_value = (double )vtr:: frand ();
978
+ double rand_value = (double )rng. frand ();
950
979
if (rand_value < probability) {
951
980
accept = true ;
952
981
} else {
0 commit comments