STORMM Source Documentation
Loading...
Searching...
No Matches
nml_random.h
1// -*-c++-*-
2#ifndef STORMM_NML_RANDOM_H
3#define STORMM_NML_RANDOM_H
4
5#include "copyright.h"
6#include "Parsing/textfile.h"
7#include "input.h"
8#include "namelist_emulator.h"
9
10namespace stormm {
11namespace namelist {
12
13using parse::WrapTextSearch;
14
17constexpr int default_random_seed = 30965871;
18#ifdef STORMM_USE_HPC
19constexpr int default_random_streams = 1048576;
20#else
21constexpr int default_random_streams = 1;
22#endif
23constexpr int default_random_stride = 64;
24constexpr int default_random_warmup = 96;
26
33public:
34
46 RandomControls(ExceptionResponse policy_in = ExceptionResponse::DIE,
47 WrapTextSearch wrap = WrapTextSearch::NO);
48 RandomControls(const TextFile &tf, int *start_line, bool *found_nml,
49 ExceptionResponse policy_in = ExceptionResponse::DIE,
50 WrapTextSearch wrap = WrapTextSearch::NO);
52
56 RandomControls(const RandomControls &original) = default;
57 RandomControls(RandomControls &&original) = default;
58 RandomControls& operator=(const RandomControls &original) = default;
59 RandomControls& operator=(RandomControls &&original) = default;
61
63 int getRandomSeed() const;
64
66 int getStreamCount() const;
67
69 int getProductionStride() const;
70
72 int getWarmupCycleCount() const;
73
75 const NamelistEmulator& getTranscript() const;
76
80 void setRandomSeed(const int igseed_in);
81
85 void setStreamCount(const int streams_in);
86
91 void setProductionStride(const int stride_in);
92
97 void setWarmupCycles(const int cycles_in);
98
99private:
100 ExceptionResponse policy;
104 int igseed;
106 int stream_count;
109 int production_stride;
111 int warmup_cycles;
114
116 NamelistEmulator nml_transcript;
117
120 void validateRandomSeed();
121
123 void validateStreamCount();
124
126 void validateProductionStride();
127};
128
142NamelistEmulator randomInput(const TextFile &tf, int *start_line, bool *found,
143 ExceptionResponse policy = ExceptionResponse::DIE,
144 WrapTextSearch wrap = WrapTextSearch::NO);
145
151void validateRandomSeed(int igseed, int *warmup_cycles);
152
153} // namespace namelist
154} // namespace stormm
155
156#endif
Collection of variables to transcribe information contained within a namelist.
Definition namelist_emulator.h:30
int getWarmupCycleCount() const
Get the number of warmup cycles for the prime stream generator.
Definition nml_random.cpp:55
void setStreamCount(const int streams_in)
Set the quantity of random number streams.
Definition nml_random.cpp:71
int getRandomSeed() const
Get the random seed supplied (and possibly, as corrected) from user input.
Definition nml_random.cpp:40
int getStreamCount() const
Get the number of random streams.
Definition nml_random.cpp:45
const NamelistEmulator & getTranscript() const
Get the original namelist emulator object as a transcript of the user input.
Definition nml_random.cpp:60
RandomControls(const RandomControls &original)=default
As with other control objects, copy and move constructors, plus copy and move assignment operators,...
void setProductionStride(const int stride_in)
Set the random number production batch size, the quantity of random numbers that each stream will pro...
Definition nml_random.cpp:77
int getProductionStride() const
Get the quantity of random numbers produced, per stream, each time a cache is filled.
Definition nml_random.cpp:50
void setRandomSeed(const int igseed_in)
Set the random seed.
Definition nml_random.cpp:65
void setWarmupCycles(const int cycles_in)
Set the number of warmup cycles through which to process the prime stream's random generator state pr...
Definition nml_random.cpp:83
RandomControls(ExceptionResponse policy_in=ExceptionResponse::DIE, WrapTextSearch wrap=WrapTextSearch::NO)
The constructor can prepare an object with default settings or read the corresponding namelist to acc...
Definition nml_random.cpp:12
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45