Bridge++  Ver. 2.0.2
test_Mult_Domainwall.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "Fopr/fopr_Domainwall.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 
41  const std::string test_name = "Mult.Domainwall";
42 
43  //- test-private parameters
44  namespace {
45  const std::string filename_input = "test_Mult_Domainwall.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_Domainwall");
75  const Parameters params_dwall = params_all.lookup("Fopr_Domainwall");
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 int Ns = params_dwall.get_int("extent_of_5th_dimension");
90 
91  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
92 
93  //- print input parameters
94  vout.general(vl, " gconf_status = %s\n", str_gconf_status.c_str());
95  vout.general(vl, " gconf_read = %s\n", str_gconf_read.c_str());
96  vout.general(vl, " readfile = %s\n", readfile.c_str());
97  vout.general(vl, " rand_type = %s\n", str_rand_type.c_str());
98  vout.general(vl, " seed = %lu\n", seed);
99  vout.general(vl, " Nmult = %d\n", Nmult);
100  vout.general(vl, " vlevel = %s\n", str_vlevel.c_str());
101  vout.general(vl, " Ns = %d\n", Ns);
102 
103  //- input parameter check
104  int err = 0;
105  err += ParameterCheck::non_NULL(str_gconf_status);
106 
107  if (err) {
108  vout.crucial(vl, "Error at %s: input parameters have not been set\n", test_name.c_str());
109  exit(EXIT_FAILURE);
110  }
111 
112 
113  RandomNumberManager::initialize(str_rand_type, seed);
114 
115 
116  // #### Set up a gauge configuration ####
117  Field_G U(Nvol, Ndim);
118 
119  if (str_gconf_status == "Continue") {
120  GaugeConfig(str_gconf_read).read(U, readfile);
121  } else if (str_gconf_status == "Cold_start") {
122  GaugeConfig("Unit").read(U);
123  } else if (str_gconf_status == "Hot_start") {
124  GaugeConfig("Random").read(U);
125  } else {
126  vout.crucial(vl, "Error at %s: unsupported gconf status \"%s\"\n", test_name.c_str(), str_gconf_status.c_str());
127  exit(EXIT_FAILURE);
128  }
129 
130 
131  // #### object setup #####
132 
133  //TODO
134  Fopr_Domainwall fopr_dw(params_dwall);
135 
136  fopr_dw.set_config(&U);
137  fopr_dw.set_mode("D");
138 
139  Timer timer(test_name);
140 
141  vout.general(vl, "\n");
142 
143 
144  // #### Execution main part ####
145  const int Nin_dw = fopr_dw.field_nin();
146  const int Nvol_dw = fopr_dw.field_nvol();
147  const int Nex_dw = fopr_dw.field_nex();
148 
149  Field y(Nin_dw, Nvol_dw, Nex_dw);
150  Field b(Nin_dw, Nvol_dw, Nex_dw);
151  //b = 1.0;
152  b.set(1.0);
153 
154  double result = 0.0;
155 
156  timer.start();
157 #ifdef FUJITSU_FX
158  //- profiler starts
159  // fapp_start("Mult.Domainwall",1,1);
160 #endif
161 
162 #pragma omp parallel
163  {
164  for (int i = 0; i < Nmult; ++i) {
165  fopr_dw.mult(y, b);
166  }
167  result = y.norm();
168  }
169 
170 #ifdef FUJITSU_FX
171  //- profiler ends
172  // fapp_stop("Mult.Domainwall",1,1);
173 #endif
174  timer.stop();
175  const double elapse_sec = timer.elapsed_sec();
176 
177 
178  //- #floating-point operations(flo) of mult_Domainwall(Imp version)
179  // #(D_DW) = (464 * Nc + 240) * Ns * site
180  // #(D_W) = 464 * Nc * site
181  // 10 * Nin * site = 240 * site
182 
183  const double gflo_mult_Domainwall = (464 * Nc + 240) * Ns * (Nvol * (NPE / 1.0e+9));
184  const double gflops_mult_Domainwall = gflo_mult_Domainwall * Nmult / (elapse_sec * NPE * Nthread);
185 
186  vout.general(vl, "%s(Imp): %12.4e GFlops / core\n\n", test_name.c_str(), gflops_mult_Domainwall);
187 
188 
190 
191 
192  if (do_check) {
193 #if defined(USE_GROUP_SU2)
194  // Nc=2 verificaction data is not available.
195  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
196  return EXIT_SKIP;
197 #else
198  return Test::verify(result, expected_result, tolerance);
199 #endif
200  } else {
201  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
202  return EXIT_SKIP;
203  }
204  }
205 } // namespace Test_Mult_Domainwall
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
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
Test_Mult_Domainwall
Test of Mult with Domainwall fermion.
Definition: test_Mult_Domainwall.cpp:40
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
fopr_Domainwall.h
AFopr_Domainwall
Domain-wall fermion operator.
Definition: afopr_Domainwall.h:38
AFopr_Domainwall::mult
void mult(AFIELD &v, const AFIELD &w)
multiplies fermion operator to a given field.
Definition: afopr_Domainwall-tmpl.h:513
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
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
AFopr_Domainwall::field_nvol
int field_nvol()
returns the volume of the fermion field.
Definition: afopr_Domainwall.h:151
test.h
ParameterManager::read
static void read(const std::string &params_file, Parameters &params)
Definition: parameterManager.cpp:33
Test_Mult_Domainwall::mult
int mult(void)
Definition: test_Mult_Domainwall.cpp:61
Parameters::get_double
double get_double(const string &key) const
Definition: parameters.cpp:175
AFopr_Domainwall::field_nex
int field_nex()
returns the external degree of freedom of the fermion field.
Definition: afopr_Domainwall.h:152
AFopr_Domainwall::field_nin
int field_nin()
returns the on-site degree of freedom of the fermion field.
Definition: afopr_Domainwall.h:150
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
AFopr_Domainwall::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: afopr_Domainwall.h:125
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_Domainwall::test_name
const std::string test_name
Definition: test_Mult_Domainwall.cpp:41
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
AFopr_Domainwall::set_mode
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr_Domainwall-tmpl.h:500
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
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