Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_Mult_Wilson_eo.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "gaugeConfig.h"
17 #include "randomNumbers_Mseries.h"
18 
19 #include "fopr_Wilson_eo.h"
20 #include "gammaMatrixSet.h"
21 
22 //- profiler of fx10
23 //#include "fj_tool/fapp.h"
24 
25 //====================================================================
27 
32 namespace Test_Mult_Wilson_eo {
33  const std::string test_name = "Mult.Wilson_eo";
34 
35  //- test-private parameters
36  namespace {
37  const std::string filename_input = "test_Mult_Wilson_eo.yaml";
38  const std::string filename_output = "stdout";
39 
40  class Parameters_Test_Mult_Wilson : public Parameters {
41  public:
42  Parameters_Test_Mult_Wilson()
43  {
44  Register_string("gauge_config_status", "NULL");
45  Register_string("gauge_config_type_input", "NULL");
46  Register_string("config_filename_input", "NULL");
47 
48  Register_int("number_of_mult", 0);
49 
50  Register_string("verbose_level", "NULL");
51 
52  Register_double("expected_result", 0.0);
53  }
54  };
55  }
56 
57  //- prototype declaration
58  int mult(void);
59 
60 #ifdef USE_TESTMANAGER_AUTOREGISTER
61  namespace {
62 #if defined(USE_GROUP_SU2)
63  // Nc=2 is not available.
64 #else
65  static const bool is_registered = TestManager::RegisterTest(
66  test_name,
67  mult
68  );
69 #endif
70  }
71 #endif
72 
73  //====================================================================
74  int mult(void)
75  {
76  // #### parameter setup ####
77  int Nc = CommonParameters::Nc();
78  int Nd = CommonParameters::Nd();
79  int Ndim = CommonParameters::Ndim();
80  int Nvol = CommonParameters::Nvol();
81 
82  int Lvol = CommonParameters::Lvol();
83  int NPE = CommonParameters::NPE();
85 
86  Parameters *params_test = new Parameters_Test_Mult_Wilson;
87  Parameters *params_wilson = ParametersFactory::New("Fopr.Wilson");
88  Parameters *params_all = new Parameters;
89 
90  params_all->Register_Parameters("Test_Mult_Wilson", params_test);
91  params_all->Register_Parameters("Fopr_Wilson", params_wilson);
92 
93  ParameterManager_YAML params_manager;
94  params_manager.read_params(filename_input, params_all);
95 
96  const string str_gconf_status = params_test->get_string("gauge_config_status");
97  const string str_gconf_read = params_test->get_string("gauge_config_type_input");
98  const string readfile = params_test->get_string("config_filename_input");
99  const int Nmult = params_test->get_int("number_of_mult");
100  const string str_vlevel = params_test->get_string("verbose_level");
101 
102  const bool do_check = params_test->is_set("expected_result");
103  const double expected_result = do_check ? params_test->get_double("expected_result") : 0.0;
104 
105  const string str_gmset_type = params_wilson->get_string("gamma_matrix_type");
106 
108 
109  //- print input parameters
110  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
111  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
112  vout.general(vl, " readfile = %s\n", readfile.c_str());
113  vout.general(vl, " Nmult = %d\n", Nmult);
114  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
115  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
116 
117  //- input parameter check
118  int err = 0;
119  err += ParameterCheck::non_NULL(str_gconf_status);
120 
121  if (err) {
122  vout.crucial(vl, "%s: Input parameters have not been set.\n", test_name.c_str());
123  abort();
124  }
125 
126 
127  // #### Set up a gauge configuration ####
128  Field_G *U = new Field_G(Nvol, Ndim);
129  GaugeConfig *gconf_read = new GaugeConfig(str_gconf_read);
130 
131  if (str_gconf_status == "Continue") {
132  gconf_read->read_file((Field *)U, readfile);
133  } else if (str_gconf_status == "Cold_start") {
134  U->set_unit();
135  } else if (str_gconf_status == "Hot_start") {
136  RandomNumbers_Mseries rand(1234567);
137  U->set_random(&rand);
138  } else {
139  vout.crucial(vl, "%s: unsupported gconf status \"%s\".\n", test_name.c_str(), str_gconf_status.c_str());
140  abort();
141  }
142 
143 
144  // #### object setup #####
145  GammaMatrixSet *gmset = GammaMatrixSet::New(str_gmset_type);
146 
147  Fopr_Wilson_eo *fopr_w = new Fopr_Wilson_eo(str_gmset_type);
148  fopr_w->set_parameters(*params_wilson);
149  fopr_w->set_config(U);
150  fopr_w->set_mode("D");
151 
152  Timer *timer = new Timer(test_name);
153 
154  vout.general(vl, "\n");
155 
156 
157  // #### Execution main part ####
158  Field_F b;
159  int Nin = b.nin();
160  // int Nvol = b.nvol();
161  int Nex = b.nex();
162 
163  Field be(Nin, Nvol / 2, Nex);
164  Field ye(Nin, Nvol / 2, Nex);
165  be = 1.0;
166 
167  double result = 0.0;
168 
169 
170  timer->start();
171  //- profiler of fx10 starts
172  // fapp_start("Mult.Wilson_eo",1,1);
173 
174 #pragma omp parallel
175  {
176  for (int i = 0; i < Nmult; ++i) {
177  fopr_w->mult(ye, be);
178  }
179  result = ye.norm();
180  }
181 
182  //- profiler of fx10 ends
183  // fapp_stop("Mult.Wilson_eo",1,1);
184  timer->stop();
185  double elapse_sec = timer->elapsed_sec();
186 
187 
188  //- Flops counting
189  double gflo_mult = fopr_w->flop_count() / 1.0e+9;
190  double gflops_mult = gflo_mult * Nmult / (elapse_sec * NPE * Nthread);
191 
192  vout.general(vl, "%s: %12.4e GFlops / core\n", test_name.c_str(), gflops_mult);
193  vout.general(vl, "\n");
194 
195 
196  // #### tidy up ####
197  delete params_test;
198  delete params_wilson;
199  delete params_all;
200 
201  delete timer;
202 
203  delete gconf_read;
204  delete U;
205 
206  delete fopr_w;
207  delete gmset;
208 
209 
210  if (do_check) {
211  return Test::verify(expected_result, result);
212  } else {
213  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
214  return EXIT_SKIP;
215  }
216  }
217 } // namespace Test_Mult_Wilson_eo
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:207
void read_params(const std::string &params_file, Parameters *params)
read parameters from file.
void detailed(const char *format,...)
Definition: bridgeIO.cpp:50
double elapsed_sec() const
Definition: timer.cpp:107
void general(const char *format,...)
Definition: bridgeIO.cpp:38
Container of Field-type object.
Definition: field.h:37
void set_parameters(const Parameters &params)
int get_int(const string &key) const
Definition: parameters.cpp:40
Class for parameters.
Definition: parameters.h:40
const Field mult(const Field &f)
multiplies fermion operator to a given field and returns the resultant field.
static int Lvol()
static Parameters * New(const std::string &realm)
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:62
Wilson-type fermion field.
Definition: field_F.h:37
const std::string test_name
double flop_count()
this returns the number of floating point number operations.
void set_unit()
Definition: field_G_imp.cpp:39
int nin() const
Definition: field.h:100
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:79
SU(N) gauge field.
Definition: field_G.h:36
bool is_set(const string &) const
Definition: parameters.cpp:366
double get_double(const string &key) const
Definition: parameters.cpp:25
void set_config(Field *U)
setting pointer to the gauge configuration.
double norm() const
Definition: field.h:210
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:102
static int get_num_threads_available()
returns number of threads (works outside of parallel region).
int non_NULL(const std::string v)
Definition: checker.cpp:61
void start()
Definition: timer.cpp:44
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
Even-odd Wilson fermion operator.
void Register_Parameters(const string &, Parameters *const)
Definition: parameters.cpp:359
Bridge::VerboseLevel vl
Definition: checker.cpp:18
VerboseLevel
Definition: bridgeIO.h:25
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Parameter manager with YAML parser.
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:56
Definition: timer.h:31
int verify(const double expected, const double result)
Definition: test.cpp:27
void read_file(Field *u, const string &filename)
Definition: gaugeConfig.cpp:85
string get_string(const string &key) const
Definition: parameters.cpp:85
void stop()
Definition: timer.cpp:69
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
static int NPE()