34 namespace Test_RandomNumbers_Mseries {
35 const std::string
test_name =
"RandomNumbers.Mseries.Global";
39 const std::string filename_input =
"test_RandomNumbers_Mseries_Global.yaml";
45 #ifdef USE_TESTMANAGER_AUTOREGISTER
63 const int iseed = params_test.
get_int(
"int_seed");
64 const string str_vlevel = params_test.
get_string(
"verbose_level");
66 const bool do_check = params_test.
is_set(
"expected_result");
67 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
73 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
85 vout.
general(vl,
"Serial and Node-parallel test of Random Number Generator:\n");
94 vout.
general(vl,
"field size: nin = %d, nex = %d, nvol = %d, lvol = %d\n", nin, nex, nvol, lvol);
97 const size_t nsample = 1024;
99 for (
size_t i = 0; i < nsample; ++i) {
105 Field field1(nin, nvol, nex);
115 for (
size_t i = 0; i < nsample; ++i) {
116 data[i] = rand->
get();
121 Field field2(0, 0, 0);
126 field2.
reset(nin, lvol, nex);
128 double *p = field2.
ptr(0);
130 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
136 Field field1b(0, 0, 0);
139 field1b.
reset(nin, lvol, nex);
144 fieldio.
gather(&field1b, &field1);
150 if (field1b.
size() != field2.
size()) {
155 double *p1 = field1b.
ptr(0);
156 double *p2 = field2.
ptr(0);
158 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
159 if (*p1++ != *p2++) ++err1;
174 for (
size_t i = 0; i < nsample; ++i) {
175 if (data[i] != buf[i]) ++err2;
195 for (
size_t i = 0; i < nsample; ++i) {
196 data[i] = rand->
get();
205 for (
size_t i = 0; i < nsample; ++i) {
206 if (data[i] != rand->
get()) ++err3_part;
215 field1.
reset(nin, nvol, nex);
228 field2.
reset(nin, lvol, nex);
230 double *p = field2.
ptr(0);
232 if (field2.
nin() % 2 == 0) {
235 for (
int j = 0, Nex = field2.
nex(); j < Nex; ++j) {
236 for (
int isite = 0, Nvol = field2.
nvol(); isite < Nvol; ++isite) {
237 for (
int i = 0, Nin = field2.
nin(); i < Nin; i += 2) {
247 for (
int j = 0, Nex = field2.
nex(); j < Nex; ++j) {
248 for (
int isite = 0, Nvol = field2.
nvol(); isite < Nvol; ++isite) {
249 for (
int i = 0, Nin = field2.
nin(); i < Nin; ++i) {
259 field1b.
reset(nin, lvol, nex);
262 fieldio.
gather(&field1b, &field1);
267 if (field1b.
size() != field2.
size()) {
272 double *p1 = field1b.
ptr(0);
273 double *p2 = field2.
ptr(0);
275 for (
size_t i = 0, n = field2.
size(); i < n; ++i) {
276 if (*p1++ != *p2++) ++err4;
285 const double result = err1 + err2 + err3 + err4;
293 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
Random number generator base on M-series.
void detailed(const char *format,...)
const double * ptr(const int jin, const int site, const int jex) const
void read_file(const std::string &)
save and load random number status.
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...
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 write_file(const std::string &)
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 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)