Bridge++  Ver. 2.0.2
test_Mult_Overlap.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
17 
18 #include "Fopr/fopr_Wilson.h"
19 #include "Fopr/fopr_Overlap.h"
20 
21 #include "IO/gaugeConfig.h"
22 
24 
25 //- profiler
26 #ifdef FUJITSU_FX
27 # ifdef __has_include
28 # if __has_include(<fj_tool/fapp.h>)
29 # include <fj_tool/fapp.h>
30 # endif
31 # endif
32 #endif
33 
34 //====================================================================
36 
43 namespace Test_Mult_Overlap {
44  const std::string test_name = "Mult.Overlap";
45 
46  //- test-private parameters
47  namespace {
48  const std::string filename_input = "test_Mult_Overlap.yaml";
49  }
50 
51  //- prototype declaration
52  int mult(void);
53 
54 #ifdef USE_TESTMANAGER_AUTOREGISTER
55  namespace {
56 #if defined(USE_GROUP_SU2)
57  // Nc=2 is not available.
58 #else
59  static const bool is_registered = TestManager::RegisterTest(
60  test_name,
61  mult
62  );
63 #endif
64  }
65 #endif
66 
67  //====================================================================
68  int mult(void)
69  {
70  // #### parameter setup ####
71  const int Ndim = CommonParameters::Ndim();
72  const int Nc = CommonParameters::Nc();
73  const int Nd = CommonParameters::Nd();
74  const int Nvol = CommonParameters::Nvol();
75 
76  const int NPE = CommonParameters::NPE();
77  const int Nthread = ThreadManager::get_num_threads_available();
78 
79  const Parameters params_all = ParameterManager::read(filename_input);
80 
81  const Parameters params_test = params_all.lookup("Test_Mult_Overlap");
82  const Parameters params_wilson = params_all.lookup("Fopr_Wilson");
83  const Parameters params_overlap = params_all.lookup("Fopr_Overlap");
84  const Parameters params_irlanczos = params_all.lookup("Eigensolver");
85 
86  const string str_gconf_status = params_test.get_string("gauge_config_status");
87  const string str_gconf_read = params_test.get_string("gauge_config_type_input");
88  const string readfile = params_test.get_string("config_filename_input");
89  const string str_rand_type = params_test.get_string("random_number_type");
90  const unsigned long seed = params_test.get_unsigned_long("seed_for_random_number");
91  const int Nmult = params_test.get_int("number_of_mult");
92  const string str_vlevel = params_test.get_string("verbose_level");
93 
94  const bool do_check = params_test.is_set("expected_result");
95  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
96  const double tolerance = params_test.get_double("tolerance");
97 
98  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
99 
100  //- print input parameters
101  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
102  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
103  vout.general(vl, " readfile = %s\n", readfile.c_str());
104  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
105  vout.general(vl, " seed = %lu\n", seed);
106  vout.general(vl, " Nmult = %d\n", Nmult);
107  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
108 
109  //- input parameter check
110  int err = 0;
111  err += ParameterCheck::non_NULL(str_gconf_status);
112 
113  if (err) {
114  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
115  exit(EXIT_FAILURE);
116  }
117 
118 
119  RandomNumberManager::initialize(str_rand_type, seed);
120 
121 
122  // #### Set up a gauge configuration ####
123  Field_G U(Nvol, Ndim);
124 
125  if (str_gconf_status == "Continue") {
126  GaugeConfig(str_gconf_read).read(U, readfile);
127  } else if (str_gconf_status == "Cold_start") {
128  GaugeConfig("Unit").read(U);
129  } else if (str_gconf_status == "Hot_start") {
130  GaugeConfig("Random").read(U);
131  } else {
132  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
133  exit(EXIT_FAILURE);
134  }
135 
136 
137  // #### object setup ####
138  unique_ptr<Fopr_Wilson> fopr_w(new Fopr_Wilson(params_wilson));
139  fopr_w->set_config(&U);
140 
141  //- with low-mode subtraction
142  // int Nsbt = 0;
143  // std::vector<double> TDa;
144  // std::vector<Field> vk;
145  // calc_lowmodes(params_irlanczos, Nsbt, TDa, vk, fopr_w);
146 
147  unique_ptr<Fopr> fopr_overlap(new Fopr_Overlap(fopr_w.get(), params_overlap));
148  fopr_overlap->set_config(&U);
149  fopr_overlap->set_mode("D");
150  // dynamic_cast<Fopr_Overlap*>(fopr_overlap)->set_lowmodes(Nsbt, &TDa, &vk);
151 
152  Timer timer(test_name);
153 
154 
155  // #### Execution main part ####
156  Field_F b, y;
157  b.set(1.0);
158 
159  double result = 0.0;
160 
161  timer.start();
162 #ifdef FUJITSU_FX
163  //- profiler starts
164  // fapp_start("Mult.Overlap",1,1);
165 #endif
166 
167 #pragma omp parallel
168  {
169  for (int i = 0; i < Nmult; ++i) {
170  fopr_overlap->mult(y, b);
171  }
172  result = y.norm();
173  }
174 
175 #ifdef FUJITSU_FX
176  //- profiler ends
177  // fapp_stop("Mult.Overlap",1,1);
178 #endif
179  timer.stop();
180  const double elapse_sec = timer.elapsed_sec();
181 
182 
183  //- Flops counting in giga unit
184  vout.general(vl, "Warning at %s: flop_count has not been implemented.\n", test_name.c_str());
185  vout.general(vl, "\n");
186 
187 
189 
190 
191  if (do_check) {
192  return Test::verify(result, expected_result, tolerance);
193  } else {
194  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
195  return EXIT_SKIP;
196  }
197  }
198 } // namespace Test_Mult_Overlap
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
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
fopr_Overlap.h
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
Test_Mult_Overlap::mult
int mult(void)
Definition: test_Mult_Overlap.cpp:68
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_Wilson.h
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Fopr_Overlap
AFopr_Overlap< Field > Fopr_Overlap
Overlap fermion operator.
Definition: fopr_Overlap.h:31
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
eigensolver_IRLanczos.h
Test_Mult_Overlap
Test of Mult with Overlap fermion.
Definition: test_Mult_Overlap.cpp:43
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_Overlap::test_name
const std::string test_name
Definition: test_Mult_Overlap.cpp:44
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
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
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
Fopr_Wilson
Org::Fopr_Wilson Fopr_Wilson
Wilson fermion operator.
Definition: fopr_Wilson.h:50