Skip to content

Commit bf028ef

Browse files
committed
Revert "Changed the random number generator in packer to deterministic vtr::irand"
This reverts commit 53cd616.
1 parent 53cd616 commit bf028ef

File tree

4 files changed

+19
-29
lines changed

4 files changed

+19
-29
lines changed

vpr/src/pack/greedy_candidate_selector.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "vpr_context.h"
1818
#include "vpr_types.h"
1919
#include "vtr_assert.h"
20-
#include "vtr_random.h"
2120

2221
/*
2322
* @brief Get gain of packing molecule into current cluster.
@@ -519,8 +518,7 @@ t_pack_molecule* GreedyCandidateSelector::get_next_candidate_for_cluster(
519518
LegalizationClusterId cluster_id,
520519
const ClusterLegalizer& cluster_legalizer,
521520
const Prepacker& prepacker,
522-
AttractionInfo& attraction_groups,
523-
vtr::RngContainer& rng) {
521+
AttractionInfo& attraction_groups) {
524522
/* Finds the block with the greatest gain that satisfies the
525523
* input, clock and capacity constraints of a cluster that are
526524
* passed in. If no suitable block is found it returns nullptr.
@@ -599,8 +597,7 @@ t_pack_molecule* GreedyCandidateSelector::get_next_candidate_for_cluster(
599597
cluster_id,
600598
prepacker,
601599
cluster_legalizer,
602-
attraction_groups,
603-
rng);
600+
attraction_groups);
604601
}
605602
/* Grab highest gain molecule */
606603
// If this was a vector, this would just be a pop_back.
@@ -729,8 +726,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_grou
729726
LegalizationClusterId legalization_cluster_id,
730727
const Prepacker& prepacker,
731728
const ClusterLegalizer& cluster_legalizer,
732-
AttractionInfo& attraction_groups,
733-
vtr::RngContainer& rng) {
729+
AttractionInfo& attraction_groups) {
734730
auto cluster_type = cluster_legalizer.get_cluster_type(legalization_cluster_id);
735731

736732
/*
@@ -783,10 +779,17 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_grou
783779
return;
784780
}
785781

782+
int min = 0;
786783
int max = num_available_atoms - 1;
787784

788785
for (int j = 0; j < attraction_group_num_atoms_threshold_; j++) {
789-
int selected_atom = rng.irand(max);
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);
790793

791794
AtomBlockId blk_id = available_atoms[selected_atom];
792795

vpr/src/pack/greedy_candidate_selector.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "cluster_legalizer.h"
1717
#include "physical_types.h"
1818
#include "vtr_vector.h"
19-
#include "vtr_random.h"
2019

2120
// Forward declarations
2221
class AtomNetlist;
@@ -302,8 +301,7 @@ class GreedyCandidateSelector {
302301
LegalizationClusterId cluster_id,
303302
const ClusterLegalizer& cluster_legalizer,
304303
const Prepacker& prepacker,
305-
AttractionInfo& attraction_groups,
306-
vtr::RngContainer& rng);
304+
AttractionInfo& attraction_groups);
307305

308306
/**
309307
* @brief Finalize the creation of a cluster.
@@ -456,8 +454,7 @@ class GreedyCandidateSelector {
456454
LegalizationClusterId legalization_cluster_id,
457455
const Prepacker& prepacker,
458456
const ClusterLegalizer& cluster_legalizer,
459-
AttractionInfo& attraction_groups,
460-
vtr::RngContainer& rng);
457+
AttractionInfo& attraction_groups);
461458

462459
/**
463460
* @brief Finds a molecule to propose which is unrelated but may be good to

vpr/src/pack/greedy_clusterer.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include "vpr_context.h"
5656
#include "vtr_math.h"
5757
#include "vtr_vector.h"
58-
#include "vtr_random.h"
5958

6059
namespace {
6160

@@ -161,8 +160,6 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
161160

162161
print_pack_status_header();
163162

164-
vtr::RngContainer rng(0);
165-
166163
// Continue clustering as long as a valid seed is returned from the seed
167164
// selector.
168165
while (seed_mol != nullptr) {
@@ -186,8 +183,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
186183
balance_block_type_utilization,
187184
attraction_groups,
188185
num_used_type_instances,
189-
mutable_device_ctx,
190-
rng);
186+
mutable_device_ctx);
191187

192188
if (!new_cluster_id.is_valid()) {
193189
// If the previous strategy failed, try to grow the cluster again,
@@ -201,8 +197,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
201197
balance_block_type_utilization,
202198
attraction_groups,
203199
num_used_type_instances,
204-
mutable_device_ctx,
205-
rng);
200+
mutable_device_ctx);
206201
}
207202

208203
// Ensure that the seed was packed successfully.
@@ -244,8 +239,7 @@ LegalizationClusterId GreedyClusterer::try_grow_cluster(
244239
bool balance_block_type_utilization,
245240
AttractionInfo& attraction_groups,
246241
std::map<t_logical_block_type_ptr, size_t>& num_used_type_instances,
247-
DeviceContext& mutable_device_ctx,
248-
vtr::RngContainer& rng) {
242+
DeviceContext& mutable_device_ctx) {
249243

250244
// Check to ensure that this molecule is unclustered.
251245
VTR_ASSERT(!cluster_legalizer.is_mol_clustered(seed_mol));
@@ -273,8 +267,7 @@ LegalizationClusterId GreedyClusterer::try_grow_cluster(
273267
legalization_cluster_id,
274268
cluster_legalizer,
275269
prepacker,
276-
attraction_groups,
277-
rng);
270+
attraction_groups);
278271

279272
/*
280273
* When attraction groups are created, the purpose is to pack more densely by adding more molecules
@@ -323,8 +316,7 @@ LegalizationClusterId GreedyClusterer::try_grow_cluster(
323316
legalization_cluster_id,
324317
cluster_legalizer,
325318
prepacker,
326-
attraction_groups,
327-
rng);
319+
attraction_groups);
328320

329321
// If the next candidate molecule is the same as the previous
330322
// candidate molecule, increment the number of repeated

vpr/src/pack/greedy_clusterer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <vector>
1414
#include "cluster_legalizer.h"
1515
#include "physical_types.h"
16-
#include "vtr_random.h"
1716

1817
// Forward declarations
1918
class AtomNetId;
@@ -157,8 +156,7 @@ class GreedyClusterer {
157156
bool balance_block_type_utilization,
158157
AttractionInfo& attraction_groups,
159158
std::map<t_logical_block_type_ptr, size_t>& num_used_type_instances,
160-
DeviceContext& mutable_device_ctx,
161-
vtr::RngContainer& rng);
159+
DeviceContext& mutable_device_ctx);
162160

163161
/**
164162
* @brief Given a seed molecule, starts a new cluster by trying to find a

0 commit comments

Comments
 (0)