Bridge++  Ver. 2.0.2
test_Mult_Wilson.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "Fopr/fopr_Wilson.h"
17 
18 #include "IO/gaugeConfig.h"
19 
21 
22 //- profiler
23 #ifdef FUJITSU_FX
24 # ifdef __has_include
25 # if __has_include(<fj_tool/fapp.h>)
26 # include <fj_tool/fapp.h>
27 # endif
28 # endif
29 #endif
30 
31 //====================================================================
33 
40 namespace Test_Mult_Wilson {
41  const std::string test_name = "Mult.Wilson";
42 
43  //- test-private parameters
44  namespace {
45  const std::string filename_input = "test_Mult_Wilson.yaml";
46  }
47 
48  //- prototype declaration
49  int mult(void);
50 
51 #ifdef USE_TESTMANAGER_AUTOREGISTER
52  namespace {
53  static const bool is_registered = TestManager::RegisterTest(
54  test_name,
55  mult
56  );
57  }
58 #endif
59 
60  //====================================================================
61  int mult(void)
62  {
63  // #### parameter setup ####
64  const int Nc = CommonParameters::Nc();
65  const int Nd = CommonParameters::Nd();
66  const int Ndim = CommonParameters::Ndim();
67  const int Nvol = CommonParameters::Nvol();
68 
69  const int NPE = CommonParameters::NPE();
70  const int Nthread = ThreadManager::get_num_threads_available();
71 
72  const Parameters params_all = ParameterManager::read(filename_input);
73 
74  const Parameters params_test = params_all.lookup("Test_Mult");
75  const Parameters params_fopr = params_all.lookup("Fopr");
76 
77  const string str_gconf_status = params_test.get_string("gauge_config_status");
78  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
79  const string readfile = params_test.get_string("config_filename_input");
80  const string str_rand_type = params_test.get_string("random_number_type");
81  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
82  const int Nmult = params_test.get_int("number_of_mult");
83  const string str_vlevel = params_test.get_string("verbose_level");
84 
85  const bool do_check = params_test.is_set("expected_result");
86  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
87  const double tolerance = params_test.get_double("tolerance");
88 
89  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
90 
91  //- print input parameters
92  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
93  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
94  vout.general(vl, " readfile = %s\n", readfile.c_str());
95  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
96  vout.general(vl, " seed = %lu\n", seed);
97  vout.general(vl, " Nmult = %d\n", Nmult);
98  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
99 
100  //- input parameter check
101  int err = 0;
102  err += ParameterCheck::non_NULL(str_gconf_status);
103 
104  if (err) {
105  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
106  exit(EXIT_FAILURE);
107  }
108 
109 
110  RandomNumberManager::initialize(str_rand_type, seed);
111 
112 
113  // #### Set up a gauge configuration ####
114  Field_G U(Nvol, Ndim);
115 
116  if (str_gconf_status == "Continue") {
117  GaugeConfig(str_gconf_read).read(U, readfile);
118  } else if (str_gconf_status == "Cold_start") {
119  GaugeConfig("Unit").read(U);
120  } else if (str_gconf_status == "Hot_start") {
121  GaugeConfig("Random").read(U);
122  } else {
123  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
124  exit(EXIT_FAILURE);
125  }
126 
127 
128  // #### object setup #####
129  Fopr_Wilson fopr(params_fopr);
130  fopr.set_config(&U);
131  fopr.set_mode("D");
132 
133  Timer timer(test_name);
134 
135  vout.general(vl, "\n");
136 
137 
138  // #### Execution main part ####
139  Field_F b, y;
140  b.set(1.0);
141 
142  double result = 0.0;
143 
144  timer.start();
145 #ifdef FUJITSU_FX
146  //- profiler starts
147  // fapp_start("Mult.Wilson",1,1);
148 #endif
149 
150 #pragma omp parallel
151  {
152  for (int i = 0; i < Nmult; ++i) {
153  fopr.mult(y, b);
154  }
155  result = y.norm();
156  }
157 
158 #ifdef FUJITSU_FX
159  //- profiler ends
160  // fapp_stop("Mult.Wilson",1,1);
161 #endif
162  timer.stop();
163  const double elapse_sec = timer.elapsed_sec();
164 
165 
166  //- Flops counting in giga unit
167  const double gflops_mult = fopr.flop_count() * Nmult / (elapse_sec * NPE * Nthread);
168 
169  vout.general(vl, "%s: %12.4e GFlops / core\n", test_name.c_str(), gflops_mult);
170  vout.general(vl, "\n");
171 
172 
174 
175 
176  if (do_check) {
177 #if defined(USE_GROUP_SU2)
178  // Nc=2 verificaction data is not available.
179  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
180  return EXIT_SKIP;
181 #else
182  return Test::verify(result, expected_result, tolerance);
183 #endif
184  } else {
185  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
186  return EXIT_SKIP;
187  }
188  }
189 } // namespace Test_Mult_Wilson
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
ParameterCheck::non_NULL
int non_NULL(const std::string v)
Definition: parameterCheck.cpp:65
Org::Fopr_Wilson::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr_Wilson_impl.cpp:200
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Parameters::get_int
int get_int(const string &key) const
Definition: parameters.cpp:192
Bridge::BridgeIO::detailed
void detailed(const char *format,...)
Definition: bridgeIO.cpp:219
GaugeConfig::read
void read(Field_G &U, const string &filename=string())
Definition: gaugeConfig.cpp:121
gaugeConfig.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Timer
Definition: timer.h:31
RandomNumberManager::finalize
static void finalize()
Definition: randomNumberManager.cpp:80
RandomNumberManager::initialize
static bool initialize(const std::string &rng_type, unsigned long seed)
Definition: randomNumberManager.cpp:57
Test_Mult_Wilson
Test of Mult with Wilson fermion, prepared for beginners.
Definition: test_Mult_Wilson.cpp:40
fopr_Wilson.h
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
Field::norm
double norm() const
Definition: field.h:226
Test_Mult_Wilson::mult
int mult(void)
Definition: test_Mult_Wilson.cpp:61
test.h
ParameterManager::read
static void read(const std::string &params_file, Parameters &params)
Definition: parameterManager.cpp:33
Parameters::get_double
double get_double(const string &key) const
Definition: parameters.cpp:175
Org::Fopr_Wilson::mult
void mult(Field &v, const Field &w)
multiplies fermion operator to a given field.
Definition: fopr_Wilson_impl.cpp:210
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Test_Mult_Wilson::test_name
const std::string test_name
Definition: test_Mult_Wilson.cpp:41
Parameters::get_unsigned_long
unsigned long get_unsigned_long(const string &key) const
Definition: parameters.cpp:209
EXIT_SKIP
#define EXIT_SKIP
Definition: test.h:17
ThreadManager::get_num_threads_available
static int get_num_threads_available()
returns number of threads (works outside of parallel region).
Definition: threadManager.h:86
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
randomNumberManager.h
GaugeConfig
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:80
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Parameters::is_set
bool is_set(const string &key) const
Definition: parameters.cpp:525
Org::Fopr_Wilson::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_impl.cpp:188
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Timer::elapsed_sec
double elapsed_sec() const
Definition: timer.cpp:107
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Org::Fopr_Wilson
Definition: fopr_Wilson_impl.h:38
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Timer::stop
void stop()
Definition: timer.cpp:69
Parameters::lookup
Parameters lookup(const string &key) const
Definition: parameters.h:79
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Org::Fopr_Wilson::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Wilson_impl.cpp:449
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69