Skip to content

Commit

Permalink
Remove system seeding from the core
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Feb 13, 2020
1 parent 98f4c68 commit 0abe004
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 227 deletions.
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(EspressoCore_SRC
polymer.cpp
polynom.cpp
pressure.cpp
random.cpp
rattle.cpp
reaction_ensemble.cpp
rotate_system.cpp
Expand Down
5 changes: 0 additions & 5 deletions src/core/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ void on_program_start() {
cuda_init();
#endif

/*
call the initialization of the modules here
*/
Random::init_random();

init_node_grid();

/* initially go for domain decomposition */
Expand Down
1 change: 1 addition & 0 deletions src/core/forces_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "bonded_interactions/subt_lj.hpp"
#include "bonded_interactions/thermalized_bond.hpp"
#include "bonded_interactions/umbrella.hpp"
#include "errorhandling.hpp"
#include "forces.hpp"
#include "immersed_boundary/ibm_tribend.hpp"
#include "immersed_boundary/ibm_triel.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/core/grid_based_algorithms/lb_particle_coupling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cells.hpp"
#include "communication.hpp"
#include "config.hpp"
#include "errorhandling.hpp"
#include "global.hpp"
#include "grid.hpp"
#include "grid_based_algorithms/lattice.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/core/integrators/velocity_verlet_npt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ParticleRange.hpp"
#include "cells.hpp"
#include "communication.hpp"
#include "errorhandling.hpp"
#include "grid.hpp"
#include "integrate.hpp"
#include "nonbonded_interactions/nonbonded_interaction_data.hpp"
Expand Down
149 changes: 0 additions & 149 deletions src/core/random.cpp

This file was deleted.

72 changes: 0 additions & 72 deletions src/core/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@
* Random number generation using Philox.
*/

#include "errorhandling.hpp"

#include <Random123/philox.h>
#include <utils/Vector.hpp>
#include <utils/constants.hpp>
#include <utils/u32_to_u64.hpp>
#include <utils/uniform.hpp>

#include <random>
#include <stdexcept>
#include <string>
#include <vector>

/*
Expand Down Expand Up @@ -181,73 +176,6 @@ auto noise_gaussian(uint64_t counter, int key1, int key2 = 0) {
return noise;
}

extern std::mt19937 generator;
extern std::uniform_real_distribution<double> uniform_real_distribution;
extern bool user_has_seeded;
inline void unseeded_error() {
runtimeErrorMsg() << "Please seed the random number generator.\nESPResSo "
"can choose one for you with set_random_state_PRNG().";
}

/**
* @brief checks the seeded state and throws error if unseeded
*/
inline void check_user_has_seeded() {
static bool unseeded_error_thrown = false;
if (!user_has_seeded && !unseeded_error_thrown) {
unseeded_error_thrown = true;
unseeded_error();
}
}

/**
* @brief Set seed of random number generators on each node.
*
* @param cnt Unused.
* @param seeds A vector of seeds, must be at least n_nodes long.
*/
void mpi_random_seed(int cnt, std::vector<int> &seeds);

/**
* @brief Gets a string representation of the state of all the nodes.
*/
std::string mpi_random_get_stat();

/**
* @brief Set the seeds on all the node to the state represented
* by the string.
* The string representation must be one that was returned by
* @ref mpi_random_get_stat.
*/
void mpi_random_set_stat(const std::vector<std::string> &stat);

/**
* @brief Get the state size of the random number generator
*/
int get_state_size_of_generator();

/**
* @brief Initialize PRNG with MPI rank as seed.
*/
void init_random();

/**
* @brief Initialize PRNG with user-provided seed.
*
* @param seed seed
*/
void init_random_seed(int seed);

} // namespace Random

/**
* @brief Draws a random real number from the uniform distribution in the
* range [0,1) using the Mersenne twister.
*/
inline double d_random() {
using namespace Random;
check_user_has_seeded();
return uniform_real_distribution(generator);
}

#endif

0 comments on commit 0abe004

Please sign in to comment.