File tree 2 files changed +10
-11
lines changed
2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ GreedyCandidateSelector::GreedyCandidateSelector(
77
77
is_clock_(is_clock),
78
78
is_global_(is_global),
79
79
net_output_feeds_driving_block_input_(net_output_feeds_driving_block_input),
80
- timing_info_(timing_info) {
80
+ timing_info_(timing_info),
81
+ rng_(0 ) {
81
82
// Initialize the list of molecules to pack, the clustering data, and the
82
83
// net info.
83
84
@@ -779,17 +780,9 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_grou
779
780
return ;
780
781
}
781
782
782
- int min = 0 ;
783
- int max = num_available_atoms - 1 ;
784
-
785
783
for (int j = 0 ; j < attraction_group_num_atoms_threshold_; j++) {
786
- // FIXME: This is a non-deterministic random number generator and it is
787
- // overkill to what this needs to be. Should use vtr::irand which
788
- // would be faster.
789
- std::random_device rd;
790
- std::mt19937 gen (rd ());
791
- std::uniform_int_distribution<> distr (min, max);
792
- int selected_atom = distr (gen);
784
+ // Get a random atom between 0 and the number of available atoms - 1
785
+ int selected_atom = rng_.irand (num_available_atoms - 1 );
793
786
794
787
AtomBlockId blk_id = available_atoms[selected_atom];
795
788
Original file line number Diff line number Diff line change 16
16
#include " cluster_legalizer.h"
17
17
#include " physical_types.h"
18
18
#include " vtr_vector.h"
19
+ #include " vtr_random.h"
19
20
20
21
// Forward declarations
21
22
class AtomNetlist ;
@@ -516,5 +517,10 @@ class GreedyCandidateSelector {
516
517
// / @brief A count on the number of unrelated clustering attempts which
517
518
// / have been performed.
518
519
int num_unrelated_clustering_attempts_ = 0 ;
520
+
521
+ // / @brief Random number generator used by the clusterer. Currently this
522
+ // / is used only when selecting atoms from attraction groups, but
523
+ // / could be used for other purposes in the future.
524
+ vtr::RngContainer rng_;
519
525
};
520
526
You can’t perform that action at this time.
0 commit comments