Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_Mult_Wilson.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "Fopr/fopr_Wilson.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 
40 namespace Test_Mult_Wilson {
41  const std::string test_name = "Mult.Wilson";
42 
43  //- test-private parameters
44  namespace {
45  const std::string filename_input = "test_Mult_Wilson.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();
71 
72  const Parameters params_all = ParameterManager::read(filename_input);
73 
74  const Parameters params_test = params_all.lookup("Test_Mult");
75  const Parameters params_fopr = params_all.lookup("Fopr");
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 string str_gmset_type = params_fopr.get_string("gamma_matrix_type");
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, " gmset_type = %s\n", str_gmset_type.c_str());
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  unique_ptr<Field_G> U(new Field_G(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  const unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(str_gmset_type));
133 
134  const unique_ptr<Fopr> fopr(Fopr::New("Wilson", str_gmset_type));
135  fopr->set_parameters(params_fopr);
136  fopr->set_config(U);
137  fopr->set_mode("D");
138 
139  const unique_ptr<Timer> timer(new Timer(test_name));
140 
141  vout.general(vl, "\n");
142 
143 
144  // #### Execution main part ####
145  Field_F b, y;
146  b.set(1.0);
147 
148  double result = 0.0;
149 
150  timer->start();
151 #ifdef FUJITSU_FX
152  //- profiler starts
153  // fapp_start("Mult.Wilson",1,1);
154 #endif
155 
156 #pragma omp parallel
157  {
158  for (int i = 0; i < Nmult; ++i) {
159  fopr->mult(y, b);
160  }
161  result = y.norm();
162  }
163 
164 #ifdef FUJITSU_FX
165  //- profiler ends
166  // fapp_stop("Mult.Wilson",1,1);
167 #endif
168  timer->stop();
169  const double elapse_sec = timer->elapsed_sec();
170 
171 
172  //- Flops counting in giga unit
173  const double gflops_mult = fopr->flop_count() * Nmult / (elapse_sec * NPE * Nthread);
174 
175  vout.general(vl, "%s: %12.4e GFlops / core\n", test_name.c_str(), gflops_mult);
176  vout.general(vl, "\n");
177 
178 
180 
181 
182  if (do_check) {
183 #if defined(USE_GROUP_SU2)
184  // Nc=2 verificaction data is not available.
185  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
186  return EXIT_SKIP;
187 #else
188  return Test::verify(result, expected_result, tolerance);
189 #endif
190  } else {
191  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
192  return EXIT_SKIP;
193  }
194  }
195 } // namespace Test_Mult_Wilson
#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
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.
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
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
virtual double flop_count()
returns the flop in giga unit
Definition: fopr.h:120
double norm() const
Definition: field.h:222
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)
const std::string test_name
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