32 namespace Test_RandomNumbers_MT19937 {
33 const std::string
test_name =
"RandomNumbers.MT19937.Global";
37 const std::string filename_input =
"test_RandomNumbers_MT19937_Global.yaml";
43 #ifdef USE_TESTMANAGER_AUTOREGISTER
61 const int iseed = params_test.
get_int(
"int_seed");
62 const string str_vlevel = params_test.
get_string(
"verbose_level");
64 const bool do_check = params_test.
is_set(
"expected_result");
65 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
71 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
83 vout.
general(vl,
"Serial and Node-parallel test of Random Number Generator:\n");
94 const size_t nsample = 1024;
96 for (
size_t i = 0; i < nsample; ++i) {
102 Field field1(nin, nvol, nex);
112 for (
size_t i = 0; i < nsample; ++i) {
113 data[i] = rand->
get();
118 Field field2(0, 0, 0);
123 field2.
reset(nin, lvol, nex);
125 double *p = field2.
ptr(0);
127 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
133 Field field1b(0, 0, 0);
136 field1b.
reset(nin, lvol, nex);
141 fieldio.
gather(&field1b, &field1);
147 if (field1b.
size() != field2.
size()) {
152 double *p1 = field1b.
ptr(0);
153 double *p2 = field2.
ptr(0);
155 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
156 if (*p1++ != *p2++) ++err1;
171 for (
size_t i = 0; i < nsample; ++i) {
172 if (data[i] != buf[i]) ++err2;
192 for (
size_t i = 0; i < nsample; ++i) {
193 data[i] = rand->
get();
202 for (
size_t i = 0; i < nsample; ++i) {
203 if (data[i] != rand->
get()) ++err3_part;
212 field1.
reset(nin, nvol, nex);
225 field2.
reset(nin, lvol, nex);
227 double *p = field2.
ptr(0);
229 if (field2.
nin() % 2 == 0) {
232 for (
int j = 0, Nex = field2.
nex(); j < Nex; ++j) {
233 for (
int isite = 0, Nvol = field2.
nvol(); isite < Nvol; ++isite) {
234 for (
int i = 0, Nin = field2.
nin(); i < Nin; i += 2) {
244 for (
int j = 0, Nex = field2.
nex(); j < Nex; ++j) {
245 for (
int isite = 0, Nvol = field2.
nvol(); isite < Nvol; ++isite) {
246 for (
int i = 0, Nin = field2.
nin(); i < Nin; ++i) {
256 field1b.
reset(nin, lvol, nex);
259 fieldio.
gather(&field1b, &field1);
264 if (field1b.
size() != field2.
size()) {
269 double *p1 = field1b.
ptr(0);
270 double *p2 = field2.
ptr(0);
272 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
273 if (*p1++ != *p2++) ++err4;
282 const double result = err1 + err2 + err3 + err4;
290 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
void detailed(const char *format,...)
const double * ptr(const int jin, const int site, const int jex) const
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
virtual void uniform_lex_global(Field &)
uniform random number defined on global lattice.
void general(const char *format,...)
Container of Field-type object.
FieldIO_Text class for file I/O of Field data in plain text format.
int get_int(const string &key) const
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
static int send_1to1(int count, double *recv_buf, double *send_buf, int p_to, int p_from, int tag)
send array of double from rank p_from to rank p_to. communication distinguished by tag...
void write_file(const std::string &)
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
double get_double(const string &key) const
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
bool is_set(const string &key) const
long long_t
definition of long for Bridge++
const std::string test_name
void read_file(const std::string &)
save and load random number status.
void crucial(const char *format,...)
static void read(const std::string ¶ms_file, Parameters ¶ms)
int verify(const double result, const double expected, double eps)
static int size()
size of small world.
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
static int broadcast(int count, double *data, int sender)
broadcast array of double from sender.
static bool is_primary()
check if the present node is primary in small communicator.
string get_string(const string &key) const
void gather(Field *vglobal, Field *vlocal)
gather data on parallel nodes to primary node.
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
void gauss(double &rand1, double &rand2)
static VerboseLevel set_verbose_level(const std::string &str)