Skip to content

Commit 89f89d0

Browse files
committed
rmp: use the correct type for the seed
Improves on the fix in #8543 and also fixes the weird .i using float issue. Signed-off-by: Matt Liberty <[email protected]>
1 parent b23fa6a commit 89f89d0

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/rmp/include/rmp/Restructure.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <fstream>
88
#include <functional>
99
#include <optional>
10+
#include <random>
1011
#include <set>
1112
#include <string>
1213
#include <vector>
@@ -76,7 +77,10 @@ class Restructure
7677
char* workdir_name,
7778
char* abc_logfile);
7879

79-
void setAnnealingSeed(uint64_t seed) { annealing_seed_ = seed; }
80+
void setAnnealingSeed(std::mt19937::result_type seed)
81+
{
82+
annealing_seed_ = seed;
83+
}
8084
void setAnnealingTemp(float temp) { annealing_temp_ = temp; }
8185
void setAnnealingIters(unsigned iters) { annealing_iters_ = iters; }
8286
void setAnnealingRevertAfter(unsigned revert_after)
@@ -120,7 +124,7 @@ class Restructure
120124
odb::dbBlock* block_ = nullptr;
121125

122126
// Annealing
123-
std::optional<uint64_t> annealing_seed_;
127+
std::optional<std::mt19937::result_type> annealing_seed_;
124128
std::optional<float> annealing_temp_;
125129
unsigned annealing_iters_ = 100;
126130
std::optional<unsigned> annealing_revert_after_;

src/rmp/src/annealing_strategy.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AnnealingStrategy : public ResynthesisStrategy
2525
public:
2626
explicit AnnealingStrategy(sta::Corner* corner,
2727
sta::Slack slack_threshold,
28-
std::optional<uint64_t> seed,
28+
std::optional<std::mt19937::result_type> seed,
2929
std::optional<float> temperature,
3030
unsigned iterations,
3131
std::optional<unsigned> revert_after,
@@ -38,8 +38,7 @@ class AnnealingStrategy : public ResynthesisStrategy
3838
initial_ops_(initial_ops)
3939
{
4040
if (seed) {
41-
const uint32_t seed_32 = *seed;
42-
random_ = decltype(random_){seed_32};
41+
random_.seed(*seed);
4342
}
4443
}
4544
void OptimizeDesign(sta::dbSta* sta,

src/rmp/src/rmp.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ set_slack_threshold(float slack_threshold)
4949
}
5050

5151
void
52-
set_annealing_seed(float annealing_seed)
52+
set_annealing_seed(std::mt19937::result_type annealing_seed)
5353
{
5454
getRestructure()->setAnnealingSeed(annealing_seed);
5555
}

0 commit comments

Comments
 (0)