Skip to content

Commit

Permalink
Merge pull request #862 from DX-MON/master
Browse files Browse the repository at this point in the history
common: Improved the random seed initialisation for the context
  • Loading branch information
gatecat authored Nov 19, 2021
2 parents b7207b0 + b3edf81 commit f5cc959
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions common/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <boost/program_options.hpp>
#include <fstream>
#include <iostream>
#include <random>
#include "command.h"
#include "design_utils.h"
#include "json_frontend.h"
Expand Down Expand Up @@ -223,12 +224,9 @@ void CommandHandler::setupContext(Context *ctx)
}

if (vm.count("randomize-seed")) {
srand(time(NULL));
int r;
do {
r = rand();
} while (r == 0);
ctx->rngseed(r);
std::random_device randDev{};
std::uniform_int_distribution<int> distrib{1};
ctx->rngseed(distrib(randDev));
}

if (vm.count("slack_redist_iter")) {
Expand Down

0 comments on commit f5cc959

Please sign in to comment.