Bridge++  Ver. 2.0.2
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 "Field/field_F.h"
19 #include "IO/gaugeConfig.h"
20 
21 #include "Tools/gammaMatrixSet.h"
23 
24 //- profiler
25 #ifdef FUJITSU_FX
26 # ifdef __has_include
27 # if __has_include(<fj_tool/fapp.h>)
28 # include <fj_tool/fapp.h>
29 # endif
30 # endif
31 #endif
32 
33 //====================================================================
35 
42 namespace Test_Mult_eo {
43  const std::string test_name = "Mult";
44 
45  //- test-private parameters
46  namespace {
47  // const std::string filename_input = "test_Mult_eo.yaml";
48  }
49 
50  //- prototype declaration
51  int mult(const std::string&);
52 
53  //- mult for various fermions
55  {
56  return mult("test_Mult_Clover_eo.yaml");
57  }
58 
59 
61  {
62  return mult("test_Mult_Wilson_eo.yaml");
63  }
64 
65 
66 #ifdef USE_TESTMANAGER_AUTOREGISTER
67  namespace {
68 #if defined(USE_GROUP_SU2)
69  // Nc=2 is not available.
70 #else
71  static const bool is_registered_Clover_eo = TestManager::RegisterTest(
72  "Mult.Clover_eo",
74  );
75 
76  static const bool is_registered_Wilson_eo = TestManager::RegisterTest(
77  "Mult.Wilson_eo",
79  );
80 #endif
81  }
82 #endif
83 
84  //====================================================================
85  int mult(const std::string& filename_input)
86  {
87  // #### parameter setup ####
88  const int Nc = CommonParameters::Nc();
89  const int Nd = CommonParameters::Nd();
90  const int Ndim = CommonParameters::Ndim();
91  const int Nvol = CommonParameters::Nvol();
92 
93  const int NPE = CommonParameters::NPE();
94  const int Nthread = ThreadManager::get_num_threads_available();
95 
96  const Parameters params_all = ParameterManager::read(filename_input);
97 
98  const Parameters params_test = params_all.lookup("Test_Mult");
99  const Parameters params_fopr = params_all.lookup("Fopr");
100 
101  const string str_gconf_status = params_test.get_string("gauge_config_status");
102  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
103  const string readfile = params_test.get_string("config_filename_input");
104  const string str_rand_type = params_test.get_string("random_number_type");
105  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
106  const int Nmult = params_test.get_int("number_of_mult");
107  const string str_vlevel = params_test.get_string("verbose_level");
108 
109  const bool do_check = params_test.is_set("expected_result");
110  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
111  const double tolerance = params_test.get_double("tolerance");
112 
113  const string str_fopr_type = params_fopr.get_string("fermion_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 
126  //- input parameter check
127  int err = 0;
128  err += ParameterCheck::non_NULL(str_gconf_status);
129 
130  if (err) {
131  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
132  exit(EXIT_FAILURE);
133  }
134 
135 
136  RandomNumberManager::initialize(str_rand_type, seed);
137 
138 
139  // #### Set up a gauge configuration ####
140  Field_G U(Nvol, Ndim);
141 
142  if (str_gconf_status == "Continue") {
143  GaugeConfig(str_gconf_read).read(U, readfile);
144  } else if (str_gconf_status == "Cold_start") {
145  GaugeConfig("Unit").read(U);
146  } else if (str_gconf_status == "Hot_start") {
147  GaugeConfig("Random").read(U);
148  } else {
149  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
150  exit(EXIT_FAILURE);
151  }
152 
153 
154  // #### object setup #####
155  unique_ptr<Fopr> fopr(Fopr::New(str_fopr_type, params_fopr));
156 
157  fopr->set_config(&U);
158  fopr->set_mode("D");
159 
160  Timer timer(test_name);
161 
162  vout.general(vl, "\n");
163 
164 
165  // #### Execution main part ####
166  Field_F b;
167  const int Nin = b.nin();
168  // const int Nvol = b.nvol();
169  const int Nex = b.nex();
170 
171  Field be(Nin, Nvol / 2, Nex);
172  Field ye(Nin, Nvol / 2, Nex);
173  be.set(1.0);
174 
175  double result = 0.0;
176 
177  timer.start();
178 #ifdef FUJITSU_FX
179  //- profiler starts
180  // fapp_start("Mult_eo",1,1);
181 #endif
182 
183 #pragma omp parallel
184  {
185  for (int i = 0; i < Nmult; ++i) {
186  fopr->mult(ye, be);
187  }
188  result = ye.norm();
189  }
190 
191 #ifdef FUJITSU_FX
192  //- profiler ends
193  // fapp_stop("Mult_eo",1,1);
194 #endif
195  timer.stop();
196  const double elapse_sec = timer.elapsed_sec();
197 
198 
199  //- Flops counting
200  const double gflops_mult = fopr->flop_count() * Nmult / (elapse_sec * NPE * Nthread);
201 
202  vout.general(vl, "%s: %12.4e GFlops / core\n", test_name.c_str(), gflops_mult);
203  vout.general(vl, "\n");
204 
205 
207 
208 
209  if (do_check) {
210  return Test::verify(result, expected_result, tolerance);
211  } else {
212  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
213  return EXIT_SKIP;
214  }
215  }
216 } // namespace Test_Mult_eo
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
field_F.h
Test_Mult_eo::test_name
const std::string test_name
Definition: test_Mult_eo.cpp:43
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
Field::nex
int nex() const
Definition: field.h:128
gaugeConfig.h
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field::nin
int nin() const
Definition: field.h:126
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
fopr_eo.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.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
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
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
Test_Mult_eo::mult_Clover_eo
int mult_Clover_eo()
Definition: test_Mult_eo.cpp:54
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Test_Mult_eo
Test of Mult with even-odd preconditioning.
Definition: test_Mult_eo.cpp:42
Test_Mult_eo::mult_Wilson_eo
int mult_Wilson_eo()
Definition: test_Mult_eo.cpp:60
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
Field
Container of Field-type object.
Definition: field.h:46
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
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
gammaMatrixSet.h
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
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
Test_Mult_eo::mult
int mult(const std::string &)
Definition: test_Mult_eo.cpp:85