Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Wilson_eo_impl.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_eo_impl.h"
15 
16 namespace Org {
17  const std::string Fopr_Wilson_eo::class_name = "Org::Fopr_Wilson_eo";
18 
19 #ifdef USE_FACTORY_AUTOREGISTER
20  namespace {
21  bool init = Fopr_Wilson_eo::register_factory();
22  }
23 #endif
24 
25 //===================================================================
26  namespace {
30  void mult_Field_Gn_eo(Field_F& w, int ex,
31  const Field_G& U, const int ex1,
32  const Field_F& x, const int ex2,
33  const int ieo)
34  {
35  assert(ex < w.nex());
36  assert(ex1 < U.nex());
37  assert(ex2 < x.nex());
38  assert(U.nvol() == w.nvol() * 2);
39  assert(x.nvol() == w.nvol());
40 
41  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
42  for (int s = 0, nd = w.nd(); s < nd; ++s) {
43  Vec_SU_N vec(w.nc());
44  vec = U.mat(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
45  w.set_vec(s, site, ex, vec);
46  }
47  }
48  }
49 
50 
51  //====================================================================
55  void mult_Field_Gd_eo(Field_F& w, int ex,
56  const Field_G& U, int ex1,
57  const Field_F& x, int ex2,
58  const int ieo)
59  {
60  assert(ex < w.nex());
61  assert(ex1 < U.nex());
62  assert(ex2 < x.nex());
63  assert(U.nvol() == w.nvol() * 2);
64  assert(x.nvol() == w.nvol());
65 
66  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
67  for (int s = 0, nd = w.nd(); s < nd; ++s) {
68  Vec_SU_N vec(w.nc());
69  vec = U.mat_dag(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
70  w.set_vec(s, site, ex, vec);
71  }
72  }
73  }
74  }
75 
76 //====================================================================
78  {
79  const string str_vlevel = params.get_string("verbose_level");
80 
81  m_vl = vout.set_verbose_level(str_vlevel);
82 
83  //- fetch and check input parameters
84  double kappa;
85  std::vector<int> bc;
86 
87  int err = 0;
88  err += params.fetch_double("hopping_parameter", kappa);
89  err += params.fetch_int_vector("boundary_condition", bc);
90 
91  if (err) {
92  vout.crucial(m_vl, "Error at %s: fetch error, input parameter not found.\n", class_name.c_str());
93  exit(EXIT_FAILURE);
94  }
95 
96  set_parameters(kappa, bc);
97  }
98 
99 
100 //====================================================================
101  void Fopr_Wilson_eo::set_parameters(const double kappa, const std::vector<int> bc)
102  {
103  //- print input parameters
104  vout.general(m_vl, "%s:\n", class_name.c_str());
105  vout.general(m_vl, " kappa = %12.8f\n", kappa);
106  for (int mu = 0; mu < m_Ndim; ++mu) {
107  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
108  }
109 
110  //- range check
111  // NB. kappa = 0 is allowed.
112  assert(bc.size() == m_Ndim);
113 
114  //- store values
115  m_kappa = kappa;
116 
117  // m_boundary.resize(m_Ndim); // NB. already resized in init.
118  m_boundary = bc;
119  }
120 
121 
122 //====================================================================
124  {
125  const int Ndim = CommonParameters::Ndim();
126  const int Nvol = CommonParameters::Nvol();
127 
128  m_index.convertField(*m_Ueo, *U);
129  }
130 
131 
132 //====================================================================
133  void Fopr_Wilson_eo::set_mode(const std::string mode)
134  {
135  m_mode = mode;
136 
137  if (m_mode == "D") {
142  } else if (m_mode == "Ddag") {
147  } else if (m_mode == "DdagD") {
150  } else if (m_mode == "DDdag") {
153  } else if (m_mode == "H") {
156  } else {
157  vout.crucial("Error at %s: input mode is undefined.\n", class_name.c_str());
158  exit(EXIT_FAILURE);
159  }
160  }
161 
162 
163 //====================================================================
164  std::string Fopr_Wilson_eo::get_mode() const
165  {
166  return m_mode;
167  }
168 
169 
170 //====================================================================
171  void Fopr_Wilson_eo::init(const std::string repr)
172  {
173  m_repr = repr;
174 
175  m_boundary.resize(m_Ndim);
176  m_GM.resize(m_Ndim + 1);
177 
178  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(m_repr));
179 
180  m_GM[0] = gmset->get_GM(gmset->GAMMA1);
181  m_GM[1] = gmset->get_GM(gmset->GAMMA2);
182  m_GM[2] = gmset->get_GM(gmset->GAMMA3);
183  m_GM[3] = gmset->get_GM(gmset->GAMMA4);
184  m_GM[4] = gmset->get_GM(gmset->GAMMA5);
185 
186  m_Ueo = new Field_G(m_Nvol, m_Ndim);
187  }
188 
189 
190 //====================================================================
191  void Fopr_Wilson_eo::prePropD(Field& Be, Field& bo, const Field& b)
192  {
193 #pragma omp master
194  {
195  const int Nin = b.nin();
196  const int Nex = b.nex();
197 
198  Field be(Nin, m_Nvol2, Nex);
199  m_index.convertField(be, b, 0);
200 
201  m_index.convertField(bo, b, 1);
202 
203  Be.reset(Nin, m_Nvol2, Nex);
204 
205  // Be = be - (Field)Meo(bo, 0);
206  copy(Be, be);
207 
208  Field_F v1(m_Nvol2, Nex);
209  Meo(v1, bo, 0);
210 
211  axpy(Be, -1.0, v1);
212  }
213 #pragma omp barrier
214  }
215 
216 
217 //====================================================================
218  void Fopr_Wilson_eo::postPropD(Field& x, const Field& xe, const Field& bo)
219  {
220 #pragma omp master
221  {
222  const int Nin = xe.nin();
223  const int Nex = xe.nex();
224 
225  // xo = bo - (Field)Meo(xe, 1);
226  Field xo(Nin, m_Nvol2, Nex);
227  copy(xo, bo);
228 
229  Field_F v1(m_Nvol2, Nex);
230  Meo(v1, xe, 1);
231 
232  axpy(xo, -1.0, v1);
233 
234  x.reset(Nin, m_Nvol2 * 2, Nex);
235  m_index.reverseField(x, xe, 0);
236  m_index.reverseField(x, xo, 1);
237  }
238 #pragma omp barrier
239  }
240 
241 
242 //====================================================================
243  void Fopr_Wilson_eo::prePropDag(Field& Be, Field& bo, const Field& b)
244  {
245 #pragma omp master
246  {
247  const int Nin = b.nin();
248  const int Nex = b.nex();
249 
250  Field be(Nin, m_Nvol2, Nex);
251  m_index.convertField(be, b, 0);
252 
253  m_index.convertField(bo, b, 1);
254 
255  Be.reset(Nin, m_Nvol2, Nex);
256 
257  // Be = be - (Field)Mdageo(bo, 0);
258  copy(Be, be);
259 
260  Field_F v1(m_Nvol2, Nex);
261  Mdageo(v1, bo, 0);
262 
263  axpy(Be, -1.0, v1);
264  }
265 #pragma omp barrier
266  }
267 
268 
269 //====================================================================
270  void Fopr_Wilson_eo::postPropDag(Field& x, const Field& xe, const Field& bo)
271  {
272 #pragma omp master
273  {
274  //Field bo();
275  //index.convertField(bo, b, 1);
276  const int Nin = xe.nin();
277  const int Nex = xe.nex();
278 
279  // xo = bo - (Field)Mdageo(xe, 1);
280  Field xo(Nin, m_Nvol2, Nex);
281  copy(xo, bo);
282 
283  Field_F v1(m_Nvol2, Nex);
284  Mdageo(v1, xe, 1);
285  axpy(xo, -1.0, v1);
286 
287  x.reset(Nin, m_Nvol2 * 2, Nex);
288  m_index.reverseField(x, xe, 0);
289  m_index.reverseField(x, xo, 1);
290  }
291 #pragma omp barrier
292  }
293 
294 
295 //====================================================================
296  void Fopr_Wilson_eo::D(Field& v, const Field& f)
297  {
298 #pragma omp master
299  {
300  assert(f.nex() == 1);
301 
302  copy(v, f); // v = f;
303 
304  // v -= (Field)Meo(Meo(f, 1), 0);
305  Field_F v1(m_Nvol2, 1);
306  Meo(v1, f, 1);
307 
308  Field_F v2(m_Nvol2, 1);
309  Meo(v2, v1, 0);
310 
311  axpy(v, -1.0, v2);
312  }
313 #pragma omp barrier
314  }
315 
316 
317 //====================================================================
318  void Fopr_Wilson_eo::Ddag(Field& v, const Field& f)
319  {
320 #pragma omp master
321  {
322  copy(v, f); // v = f;
323 
324  // v -= (Field)Mdageo(Mdageo(f, 1), 0);
325  Field_F v1(m_Nvol2, 1);
326  Mdageo(v1, f, 1);
327 
328  Field_F v2(m_Nvol2, 1);
329  Mdageo(v2, v1, 0);
330 
331  axpy(v, -1.0, v2);
332  }
333 #pragma omp barrier
334  }
335 
336 
337 //====================================================================
338  void Fopr_Wilson_eo::DdagD(Field& v, const Field& f)
339  {
340 #pragma omp master
341  {
342  Field w(v);
343  D(w, f);
344  Ddag(v, w);
345  }
346 #pragma omp barrier
347  }
348 
349 
350 //====================================================================
351  void Fopr_Wilson_eo::DDdag(Field& v, const Field& f)
352  {
353 #pragma omp master
354  {
355  Field w(v);
356  Ddag(w, f);
357  D(v, w);
358  }
359 #pragma omp barrier
360  }
361 
362 
363 //====================================================================
364  void Fopr_Wilson_eo::H(Field& v, const Field& f)
365  {
366 #pragma omp master
367  {
368  Field w(v);
369  D(w, f);
370  mult_gm5(v, w);
371  }
372 #pragma omp barrier
373  }
374 
375 
376 //====================================================================
377  void Fopr_Wilson_eo::MeoMoe(Field& v, const Field& f)
378  {
379 #pragma omp master
380  {
381  // v -= (Field)Meo(Meo(f, 1), 0);
382  Field_F v1(m_Nvol2, 1);
383  Meo(v1, f, 1);
384 
385  Field_F v2(m_Nvol2, 1);
386  Meo(v2, v1, 0);
387 
388  axpy(v, -1.0, v2);
389  }
390 #pragma omp barrier
391  }
392 
393 
394 //====================================================================
396  const Field& f, const int ieo)
397  {
398 #pragma omp master
399  {
400  Field_F f2(m_Nvol2, 1);
401  copy(f2, f);
402 
403  Field_F w2(m_Nvol2, 1);
404  w2.set(0.0); // w2 = 0.0
405 
406  for (int mu = 0; mu < m_Ndim; ++mu) {
407  mult_p(mu, w2, f2, ieo);
408  mult_m(mu, w2, f2, ieo);
409  }
410 
411  scal(w2, -m_kappa); // w *= -m_kappa;
412 
413  copy(w, w2);
414  }
415  }
416 
417 
418 //====================================================================
420  const Field& f, const int ieo)
421  {
422 #pragma omp master
423  {
424  Field_F v(m_Nvol2, f.nex());
425  mult_gm5(v, f);
426  Meo_gm5(w, v, ieo);
427  }
428  }
429 
430 
431 //====================================================================
433  const Field& f, const int ieo)
434  {
435  Field_F w(m_Nvol2, f.nex());
436 
437  Meo(w, f, ieo);
438  mult_gm5(v, w);
439  }
440 
441 
442 //====================================================================
444  {
445 #pragma omp master
446  {
447  Field_F w2 = (Field_F)f;
448  mult_GM(w2, m_GM[4], (Field_F)f);
449  w = w2;
450  }
451 #pragma omp barrier
452  }
453 
454 
455 //====================================================================
456  void Fopr_Wilson_eo::gm5p(const int mu,
457  Field& w, const Field& f)
458  {
459  for (int ex = 0; ex < f.nex(); ++ex) {
460  Field_F vt1(f.nvol(), 1);
461  vt1.setpart_ex(0, f, ex);
462 
463  Field_F vt2(f.nvol(), 1);
464  shift.backward(vt2, vt1, m_boundary[mu], mu); // vt2 = vt1(x+mu)
465 
466  mult_GMproj2(vt1, -1, m_GM[mu], vt2); // vt1 = (1 - gamma_mu) vt2
467  mult_GM(vt2, m_GM[4], vt1); // vt2 = gamma_5 vt1
468 
469  w.addpart_ex(ex, vt2, 0);
470  }
471  }
472 
473 
474 //====================================================================
475  void Fopr_Wilson_eo::mult_p(const int mu,
476  Field_F& w, const Field_F& f,
477  const int ieo)
478  {
479  for (int ex = 0; ex < f.nex(); ++ex) {
480  Field_F vt(f.nvol(), 1);
481  vt.setpart_ex(0, f, ex);
482 
483  shift.backward_h(trf, vt, m_boundary[mu], mu, ieo);
484 
485  mult_Field_Gn_eo(trf2, 0, *m_Ueo, mu, trf, 0, ieo);
486  mult_GMproj2(vt, -1, m_GM[mu], trf2);
487 
488  w.addpart_ex(ex, vt, 0);
489  }
490  }
491 
492 
493 //=====================================================================
494  void Fopr_Wilson_eo::mult_m(const int mu,
495  Field_F& w, const Field_F& f,
496  const int ieo)
497  {
498  for (int ex = 0; ex < f.nex(); ++ex) {
499  mult_Field_Gd_eo(trf, 0, *m_Ueo, mu, f, ex, 1 - ieo);
500  shift.forward_h(trf2, trf, m_boundary[mu], mu, ieo);
501 
502  Field_F vt(f.nvol(), 1);
503  mult_GMproj2(vt, 1, m_GM[mu], trf2);
504 
505  w.addpart_ex(ex, vt, 0);
506  }
507  }
508 
509 
510 //====================================================================
512  {
513  // Counting of floating point operations in giga unit.
514  // this counting is based on the Org-implementation of ver.1.2.0.
515  // Flop count of mult_GMproj2 is different for upward and downward
516  // directions due to the implemetation in Field_F.cpp.
517  // Present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
518 
519  const int Nvol = CommonParameters::Nvol();
520  const int NPE = CommonParameters::NPE();
521 
522  const int Nc = m_Nc;
523  const int Nd = m_Nd;
524 
525  int flop_Meo = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
526 
527  flop_Meo += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
528  flop_Meo += Nc * Nd * 2 * 8; // #(addpart_ex)
529  flop_Meo += Nc * Nd * 2; // #(scal(kappa))
530 
531  const int flop_per_site = 2 * flop_Meo + Nc * Nd * 2 * 2; // #(2*Meo + axpy)
532 
533  double gflop = flop_per_site * ((Nvol / 2) * (NPE / 1.0e+9));
534 
535  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
536  gflop *= 2;
537  }
538 
539  return gflop;
540  }
541 
542 
543 //====================================================================
544 }
545 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
void backward(Field &, const Field &, const int mu)
BridgeIO vout
Definition: bridgeIO.cpp:503
void mult_gm5(Field &, const Field &)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
static const std::string class_name
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:134
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void Meo_gm5(Field &, const Field &, const int ieo)
int nvol() const
Definition: field.h:127
void(Fopr_Wilson_eo::* m_preProp)(Field &, Field &, const Field &)
void prePropDag(Field &, Field &, const Field &)
void mult_m(const int mu, Field_F &, const Field_F &, const int ieo)
void H(Field &v, const Field &f)
Class for parameters.
Definition: parameters.h:46
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:532
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
double flop_count()
this returns the number of floating point operations of Meo.
void(Fopr_Wilson_eo::* m_mult)(Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
void(Fopr_Wilson_eo::* m_postProp)(Field &, const Field &, const Field &)
int nin() const
Definition: field.h:126
SU(N) gauge field.
Definition: field_G.h:38
void postPropDag(Field &, const Field &, const Field &)
Bridge::VerboseLevel m_vl
Definition: fopr.h:127
int nex() const
Definition: field.h:128
void DdagD(Field &v, const Field &f)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
void mult_p(const int mu, Field_F &, const Field_F &, const int ieo)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void init(const std::string)
std::string get_mode() const
only for Fopr_Overlap
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
void Ddag(Field &v, const Field &f)
int nc() const
Definition: field_F.h:89
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:112
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:122
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
void set_config(Field *U)
setting pointer to the gauge configuration.
void(Fopr_Wilson_eo::* m_mult_dag)(Field &, const Field &)
void backward_h(Field &, const Field &, const int mu, const int ieo)
void set_parameters(const Parameters &params)
void postPropD(Field &, const Field &, const Field &)
int nd() const
Definition: field_F.h:91
void DDdag(Field &v, const Field &f)
void prePropD(Field &, Field &, const Field &)
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
string get_string(const string &key) const
Definition: parameters.cpp:221
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
void MeoMoe(Field &v, const Field &f)
void gm5p(const int mu, Field &, const Field &v)
gamma_5 (1 - gamma_mu) v(x + mu)
void D(Field &v, const Field &f)
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
void forward_h(Field &, const Field &, const int mu, const int ieo)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
std::vector< int > m_boundary
void Meo(Field &, const Field &, const int ieo)
void Mdageo(Field &, const Field &, const int ieo)
std::vector< GammaMatrix > m_GM