Singleton class that generate a thread-safe random generator number for openMP
As singleton, it can be called from any class requiring RNGs.
More...
#include <sRandomNumberGenerator.hh>
|
int | Initialize (int a_nbThreads, int a_nbExtra) |
| Instantiate pseudo random number generators, one per thread by default, and additional extra ones if requested. More...
|
|
int | Initialize (int64_t a_seed, int a_nbThreads, int a_nbExtra) |
| Instantiate pseudo random number generators, one per thread by default, and additional extra ones if requested, starting from the user-provided seed. More...
|
|
HPFLTNB | GenerateRdmNber () |
| Generate a random number for the thread which index is recovered from the OpenMP function. More...
|
|
HPFLTNB | GenerateExtraRdmNber (int a_nb=0) |
| Generate a random number using the specified additional not thread safe random generator, for use in sequential parts of an otherwise multithreaded code. More...
|
|
Engine & | GetExtraGenerator (int a_nb=0) |
| Get the not thread safe additional random generator, for use various sequential parts of an otherwise multithreaded code. More...
|
|
void | SetVerbose (int a_verboseLevel) |
| Set verbosity level. More...
|
|
Singleton class that generate a thread-safe random generator number for openMP
As singleton, it can be called from any class requiring RNGs.
Definition at line 41 of file sRandomNumberGenerator.hh.
◆ Distribution
Distribution which produces random floating-point values i, uniformly distributed on the interval [a, b)
Definition at line 63 of file sRandomNumberGenerator.hh.
◆ Engine
◆ sRandomNumberGenerator() [1/2]
sRandomNumberGenerator::sRandomNumberGenerator |
( |
| ) |
|
|
private |
◆ ~sRandomNumberGenerator()
sRandomNumberGenerator::~sRandomNumberGenerator |
( |
| ) |
|
|
private |
◆ sRandomNumberGenerator() [2/2]
◆ GenerateExtraRdmNber()
HPFLTNB sRandomNumberGenerator::GenerateExtraRdmNber |
( |
int |
a_nb = 0 | ) |
|
Generate a random number using the specified additional not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.
- Parameters
-
a_nb | index of the extra non threaded rng |
- Returns
- HPFLTNB random number
Definition at line 252 of file sRandomNumberGenerator.cc.
◆ GenerateRdmNber()
HPFLTNB sRandomNumberGenerator::GenerateRdmNber |
( |
| ) |
|
Generate a random number for the thread which index is recovered from the OpenMP function.
- Returns
- a random generated number in [0. ; 1.)
Definition at line 232 of file sRandomNumberGenerator.cc.
◆ GetExtraGenerator()
Get the not thread safe additional random generator, for use various sequential parts of an otherwise multithreaded code.
- Parameters
-
a_nb | index of the extra non threaded rng |
- Returns
- HPFLTNB random number
Definition at line 267 of file sRandomNumberGenerator.cc.
◆ GetInstance()
◆ Initialize() [1/2]
int sRandomNumberGenerator::Initialize |
( |
int |
a_nbThreads, |
|
|
int |
a_nbExtra |
|
) |
| |
Instantiate pseudo random number generators, one per thread by default, and additional extra ones if requested.
- Parameters
-
a_nbThreads | : number of generators intended for usage in threads (one per thread) |
a_nbExtra | : number of additional generators intended for other usage (not thread safe) |
The generators for each thread and each MPI instance should be independent. The initial seed is generated by the true random generator and used to seed a temporary PRNG, which generates seeds for all final PRNGs. If MPI is used, an additional level of temporary generators is inserted, to ensure randomness.
- Returns
- 0 if success, positive value otherwise
Definition at line 72 of file sRandomNumberGenerator.cc.
◆ Initialize() [2/2]
int sRandomNumberGenerator::Initialize |
( |
int64_t |
a_seed, |
|
|
int |
a_nbThreads, |
|
|
int |
a_nbExtra |
|
) |
| |
Instantiate pseudo random number generators, one per thread by default, and additional extra ones if requested, starting from the user-provided seed.
- Parameters
-
a_seed | : initial seed |
a_nbThreads | : number of generators intended for usage in threads (one per thread) |
a_nbExtra | : number of additional generators intended for other usage (not thread safe) |
The generators for each thread and each MPI instance should be independent. The user-provided seed is fed to a temporary PRNG, which generates seeds for all final PRNGs. If MPI is used, an additional level of temporary generators is inserted, to ensure randomness.
- Returns
- 0 if success, positive value otherwise
Definition at line 151 of file sRandomNumberGenerator.cc.
◆ operator=()
◆ SetVerbose()
void sRandomNumberGenerator::SetVerbose |
( |
int |
a_verboseLevel | ) |
|
|
inline |
◆ m_seed
int64_t sRandomNumberGenerator::m_seed |
|
private |
Initial seed, that will start the initialization process for all the final pseudo random generators
Definition at line 148 of file sRandomNumberGenerator.hh.
◆ m_verbose
int sRandomNumberGenerator::m_verbose |
|
private |
◆ mp_Distribution
◆ mp_Engines
vector<Engine> sRandomNumberGenerator::mp_Engines |
|
private |
◆ mp_extraEngines
vector<Engine> sRandomNumberGenerator::mp_extraEngines |
|
private |
◆ mp_Instance
The documentation for this class was generated from the following files: