Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_Mult_eo.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "Fopr/fopr_eo.h"
17 
18 #include "IO/gaugeConfig.h"
19 
20 #include "Tools/gammaMatrixSet.h"
22 
23 //- profiler
24 #ifdef FUJITSU_FX
25 # ifdef __has_include
26 # if __has_include(<fj_tool/fapp.h>)
27 # include <fj_tool/fapp.h>
28 # endif
29 # endif
30 #endif
31 
32 //====================================================================
34 
41 namespace Test_Mult_eo {
42  const std::string test_name = "Mult";
43 
44  //- test-private parameters
45  namespace {
46  // const std::string filename_input = "test_Mult_eo.yaml";
47  }
48 
49  //- prototype declaration
50  int mult(const std::string&);
51 
52  //- mult for various fermions
54  {
55  return mult("test_Mult_Clover_eo.yaml");
56  }
57 
58 
60  {
61  return mult("test_Mult_Wilson_eo.yaml");
62  }
63 
64 
65 #ifdef USE_TESTMANAGER_AUTOREGISTER
66  namespace {
67 #if defined(USE_GROUP_SU2)
68  // Nc=2 is not available.
69 #else
70  static const bool is_registered_Clover_eo = TestManager::RegisterTest(
71  "Mult.Clover_eo",
73  );
74 
75  static const bool is_registered_Wilson_eo = TestManager::RegisterTest(
76  "Mult.Wilson_eo",
78  );
79 #endif
80  }
81 #endif
82 
83  //====================================================================
84  int mult(const std::string& filename_input)
85  {
86  // #### parameter setup ####
87  const int Nc = CommonParameters::Nc();
88  const int Nd = CommonParameters::Nd();
89  const int Ndim = CommonParameters::Ndim();
90  const int Nvol = CommonParameters::Nvol();
91 
92  const int NPE = CommonParameters::NPE();
94 
95  const Parameters params_all = ParameterManager::read(filename_input);
96 
97  const Parameters params_test = params_all.lookup("Test_Mult");
98  const Parameters params_fopr = params_all.lookup("Fopr");
99 
100  const string str_gconf_status = params_test.get_string("gauge_config_status");
101  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
102  const string readfile = params_test.get_string("config_filename_input");
103  const string str_rand_type = params_test.get_string("random_number_type");
104  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
105  const int Nmult = params_test.get_int("number_of_mult");
106  const string str_vlevel = params_test.get_string("verbose_level");
107 
108  const bool do_check = params_test.is_set("expected_result");
109  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
110  const double tolerance = params_test.get_double("tolerance");
111 
112  const string str_fopr_type = params_fopr.get_string("fermion_type");
113  const string str_gmset_type = params_fopr.get_string("gamma_matrix_type");
114 
115  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
116 
117  //- print input parameters
118  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
119  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
120  vout.general(vl, " readfile = %s\n", readfile.c_str());
121  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
122  vout.general(vl, " seed = %lu\n", seed);
123  vout.general(vl, " Nmult = %d\n", Nmult);
124  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
125  vout.general(vl, " gmset_type = %s\n", str_gmset_type.c_str());
126 
127  //- input parameter check
128  int err = 0;
129  err += ParameterCheck::non_NULL(str_gconf_status);
130 
131  if (err) {
132  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
133  exit(EXIT_FAILURE);
134  }
135 
136 
137  RandomNumberManager::initialize(str_rand_type, seed);
138 
139 
140  // #### Set up a gauge configuration ####
141  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
142 
143  if (str_gconf_status == "Continue") {
144  GaugeConfig(str_gconf_read).read(U, readfile);
145  } else if (str_gconf_status == "Cold_start") {
146  GaugeConfig("Unit").read(U);
147  } else if (str_gconf_status == "Hot_start") {
148  GaugeConfig("Random").read(U);
149  } else {
150  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
151  exit(EXIT_FAILURE);
152  }
153 
154 
155  // #### object setup #####
156  const unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
157 
158  const unique_ptr<Fopr> fopr(Fopr::New(str_fopr_type, str_gmset_type));
159  fopr->set_parameters(params_fopr);
160  fopr->set_config(U);
161  fopr->set_mode("D");
162 
163  const unique_ptr<Timer> timer(new Timer(test_name));
164 
165  vout.general(vl, "\n");
166 
167 
168  // #### Execution main part ####
169  Field_F b;
170  const int Nin = b.nin();
171  // const int Nvol = b.nvol();
172  const int Nex = b.nex();
173 
174  Field be(Nin, Nvol / 2, Nex);
175  Field ye(Nin, Nvol / 2, Nex);
176  be.set(1.0);
177 
178  double result = 0.0;
179 
180  timer->start();
181 #ifdef FUJITSU_FX
182  //- profiler starts
183  // fapp_start("Mult_eo",1,1);
184 #endif
185 
186 #pragma omp parallel
187  {
188  for (int i = 0; i < Nmult; ++i) {
189  fopr->mult(ye, be);
190  }
191  result = ye.norm();
192  }
193 
194 #ifdef FUJITSU_FX
195  //- profiler ends
196  // fapp_stop("Mult_eo",1,1);
197 #endif
198  timer->stop();
199  const double elapse_sec = timer->elapsed_sec();
200 
201  //- Flops counting
202  const double gflops_mult = fopr->flop_count() * Nmult / (elapse_sec * NPE * Nthread);
203 
204  vout.general(vl, "%s: %12.4e GFlops / core\n", test_name.c_str(), gflops_mult);
205  vout.general(vl, "\n");
206 
207 
209 
210 
211  if (do_check) {
212  return Test::verify(result, expected_result, tolerance);
213  } else {
214  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
215  return EXIT_SKIP;
216  }
217  }
218 } // namespace Test_Mult_eo
#define EXIT_SKIP
Definition: test.h:17
BridgeIO vout
Definition: bridgeIO.cpp:503
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
int mult(const std::string &)
double elapsed_sec() const
Definition: timer.cpp:107
void general(const char *format,...)
Definition: bridgeIO.cpp:197
virtual void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr.h:94
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Container of Field-type object.
Definition: field.h:45
int get_int(const string &key) const
Definition: parameters.cpp:192
Class for parameters.
Definition: parameters.h:46
Wilson-type fermion field.
Definition: field_F.h:37
int nin() const
Definition: field.h:126
Parameters lookup(const string &key) const
Definition: parameters.h:79
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
static bool initialize(const std::string &rng_type, unsigned long seed)
SU(N) gauge field.
Definition: field_G.h:38
void read(Field_G *U, const string &filename=string())
unsigned long get_unsigned_long(const string &key) const
Definition: parameters.cpp:209
double get_double(const string &key) const
Definition: parameters.cpp:175
int mult_Clover_eo()
virtual double flop_count()
returns the flop in giga unit
Definition: fopr.h:120
double norm() const
Definition: field.h:222
int nex() const
Definition: field.h:128
const std::string test_name
virtual void set_parameters(const Parameters &)=0
static int get_num_threads_available()
returns number of threads (works outside of parallel region).
int non_NULL(const std::string v)
bool is_set(const string &key) const
Definition: parameters.cpp:528
void start()
Definition: timer.cpp:44
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
static void read(const std::string &params_file, Parameters &params)
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
int mult_Wilson_eo()
GaugeConfig class for file I/O of gauge configuration.
Definition: gaugeConfig.h:78
Definition: timer.h:31
string get_string(const string &key) const
Definition: parameters.cpp:221
void stop()
Definition: timer.cpp:69
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131