Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Wilson_impl.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_impl.h"
15 
17 
18 namespace Imp {
19 #if defined USE_GROUP_SU3
21 #elif defined USE_GROUP_SU2
23 #elif defined USE_GROUP_SU_N
25 #endif
26 
27 #ifdef USE_FACTORY_AUTOREGISTER
28  namespace {
29  bool init = Fopr_Wilson::register_factory();
30  }
31 #endif
32 
33  const std::string Fopr_Wilson::class_name = "Imp::Fopr_Wilson";
34 
35 //====================================================================
36  void Fopr_Wilson::init(const std::string repr)
37  {
39 
40  vout.general(m_vl, "%s: Construction of Wilson fermion operator.\n", class_name.c_str());
41 
42  check_Nc();
43 
46  m_Nvc = 2 * m_Nc;
47  m_Ndf = 2 * m_Nc * m_Nc;
48 
53 
56  m_boundary.resize(m_Ndim);
58 
59  m_repr = repr;
60 
61  m_GM.resize(m_Ndim + 1);
62 
63  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(m_repr));
64 
65  m_GM[0] = gmset->get_GM(GammaMatrixSet::GAMMA1);
66  m_GM[1] = gmset->get_GM(GammaMatrixSet::GAMMA2);
67  m_GM[2] = gmset->get_GM(GammaMatrixSet::GAMMA3);
68  m_GM[3] = gmset->get_GM(GammaMatrixSet::GAMMA4);
69  m_GM[4] = gmset->get_GM(GammaMatrixSet::GAMMA5);
70 
71  m_U = 0;
72 
75 
76  if (m_repr == "Dirac") {
82  } else if (m_repr == "Chiral") {
88  } else {
89  vout.crucial(m_vl, "Error at %s: input repr is undefined.\n", class_name.c_str());
90  exit(EXIT_FAILURE);
91  }
92 
93  m_w1.reset(m_Nvc * m_Nd, m_Nvol, 1);
94  m_w2.reset(m_Nvc * m_Nd, m_Nvol, 1);
95 
96  const int Nvx = m_Nvc * 2 * m_Ny * m_Nz * m_Nt;
97  vcp1_xp = new double[Nvx];
98  vcp2_xp = new double[Nvx];
99  vcp1_xm = new double[Nvx];
100  vcp2_xm = new double[Nvx];
101 
102  const int Nvy = m_Nvc * 2 * m_Nx * m_Nz * m_Nt;
103  vcp1_yp = new double[Nvy];
104  vcp2_yp = new double[Nvy];
105  vcp1_ym = new double[Nvy];
106  vcp2_ym = new double[Nvy];
107 
108  const int Nvz = m_Nvc * 2 * m_Nx * m_Ny * m_Nt;
109  vcp1_zp = new double[Nvz];
110  vcp2_zp = new double[Nvz];
111  vcp1_zm = new double[Nvz];
112  vcp2_zm = new double[Nvz];
113 
114  const int Nvt = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
115  vcp1_tp = new double[Nvt];
116  vcp2_tp = new double[Nvt];
117  vcp1_tm = new double[Nvt];
118  vcp2_tm = new double[Nvt];
119 
120  setup_thread();
121  }
122 
123 
124 //====================================================================
125  void Fopr_Wilson::set_mode(const std::string mode)
126  {
127  m_mode = mode;
128 
129  if (m_mode == "D") {
132  } else if (m_mode == "Ddag") {
135  } else if (m_mode == "DdagD") {
138  } else if (m_mode == "DDdag") {
141  } else if (m_mode == "H") {
144  } else {
145  vout.crucial(m_vl, "Error at %s: input mode is undefined.\n", class_name.c_str());
146  exit(EXIT_FAILURE);
147  }
148  }
149 
150 
151 //====================================================================
153  {
154  delete[] vcp1_xp;
155  delete[] vcp2_xp;
156  delete[] vcp1_xm;
157  delete[] vcp2_xm;
158 
159  delete[] vcp1_yp;
160  delete[] vcp2_yp;
161  delete[] vcp1_ym;
162  delete[] vcp2_ym;
163 
164  delete[] vcp1_zp;
165  delete[] vcp2_zp;
166  delete[] vcp1_zm;
167  delete[] vcp2_zm;
168 
169  delete[] vcp1_tp;
170  delete[] vcp2_tp;
171  delete[] vcp1_tm;
172  delete[] vcp2_tm;
173  }
174 
175 
176 //====================================================================
177  std::string Fopr_Wilson::get_mode() const
178  {
179  return m_mode;
180  }
181 
182 
183 //====================================================================
185  {
186  const string str_vlevel = params.get_string("verbose_level");
187 
188  m_vl = vout.set_verbose_level(str_vlevel);
189 
190  //- fetch and check input parameters
191  double kappa;
192  std::vector<int> bc;
193 
194  int err = 0;
195  err += params.fetch_double("hopping_parameter", kappa);
196  err += params.fetch_int_vector("boundary_condition", bc);
197 
198  if (err) {
199  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
200  exit(EXIT_FAILURE);
201  }
202 
203  set_parameters(kappa, bc);
204  }
205 
206 
207 //====================================================================
208  void Fopr_Wilson::set_parameters(const double kappa,
209  const std::vector<int> bc)
210  {
211  //- print input parameters
212  vout.general(m_vl, "%s: input parameters\n", class_name.c_str());
213  vout.general(m_vl, " kappa = %12.8f\n", kappa);
214  for (int mu = 0; mu < m_Ndim; ++mu) {
215  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
216  }
217 
218  //- range check
219  // NB. kappa,cSW == 0 is allowed.
220  assert(bc.size() == m_Ndim);
221 
222  //- store values
223  m_kappa = kappa;
224  m_boundary = bc;
225 
226  for (int idir = 0; idir < m_Ndim; ++idir) {
227  m_boundary_each_node[idir] = 1.0;
228  if (Communicator::ipe(idir) == 0) m_boundary_each_node[idir] = m_boundary[idir];
229  }
230  }
231 
232 
233 //====================================================================
234  void Fopr_Wilson::D_dirac(Field& w, const Field& f)
235  {
236  D_ex_dirac(w, 0, f, 0);
237  }
238 
239 
240 //====================================================================
241  void Fopr_Wilson::D_chiral(Field& w, const Field& f)
242  {
243  D_ex_chiral(w, 0, f, 0);
244  }
245 
246 
247 //====================================================================
248  void Fopr_Wilson::mult_up(const int mu,
249  Field& w, const Field& f)
250  {
251  if (mu == 0) {
252  mult_xp(w, f);
253  } else if (mu == 1) {
254  mult_yp(w, f);
255  } else if (mu == 2) {
256  mult_zp(w, f);
257  } else if (mu == 3) {
258  (this->*m_mult_tp)(w, f);
259  } else {
260  vout.crucial(m_vl, "Error at %s::mult_up: illegal mu=%d\n", class_name.c_str(), mu);
261  exit(EXIT_FAILURE);
262  }
263  }
264 
265 
266 //====================================================================
267  void Fopr_Wilson::mult_dn(const int mu, Field& w, const Field& f)
268  {
269  if (mu == 0) {
270  mult_xm(w, f);
271  } else if (mu == 1) {
272  mult_ym(w, f);
273  } else if (mu == 2) {
274  mult_zm(w, f);
275  } else if (mu == 3) {
276  (this->*m_mult_tm)(w, f);
277  } else {
278  vout.crucial(m_vl, "Error at %s::mult_dn: illegal mu=%d\n", class_name.c_str(), mu);
279  exit(EXIT_FAILURE);
280  }
281  }
282 
283 
284 //====================================================================
285  void Fopr_Wilson::D_ex_dirac(Field& w, const int ex1,
286  const Field& f, const int ex2)
287  {
288  const int Ninvol = m_Nvc * m_Nd * m_Nvol;
289  const double *v1 = f.ptr(Ninvol * ex2);
290  double *v2 = w.ptr(Ninvol * ex1);
291 
292  const int Nthread = ThreadManager_OpenMP::get_num_threads();
293  const int i_thread = ThreadManager_OpenMP::get_thread_id();
294 
295  const int is = m_Ntask * i_thread / Nthread;
296  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
297 
298  for (int i = is; i < is + ns; ++i) {
299  mult_xp1_thread(i, vcp1_xp, v1);
300  mult_xm1_thread(i, vcp1_xm, v1);
301 
302  mult_yp1_thread(i, vcp1_yp, v1);
303  mult_ym1_thread(i, vcp1_ym, v1);
304 
305  mult_zp1_thread(i, vcp1_zp, v1);
306  mult_zm1_thread(i, vcp1_zm, v1);
307 
310  }
311 
312 #pragma omp barrier
313 #pragma omp master
314  {
315  const int Nvx = m_Nvc * 2 * m_Ny * m_Nz * m_Nt;
316  Communicator::exchange(Nvx, vcp2_xp, vcp1_xp, 0, 1, 1);
317  Communicator::exchange(Nvx, vcp2_xm, vcp1_xm, 0, -1, 2);
318 
319  const int Nvy = m_Nvc * 2 * m_Nx * m_Nz * m_Nt;
320  Communicator::exchange(Nvy, vcp2_yp, vcp1_yp, 1, 1, 3);
321  Communicator::exchange(Nvy, vcp2_ym, vcp1_ym, 1, -1, 4);
322 
323  const int Nvz = m_Nvc * 2 * m_Nx * m_Ny * m_Nt;
324  Communicator::exchange(Nvz, vcp2_zp, vcp1_zp, 2, 1, 5);
325  Communicator::exchange(Nvz, vcp2_zm, vcp1_zm, 2, -1, 6);
326 
327  const int Nvt = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
328  Communicator::exchange(Nvt, vcp2_tp, vcp1_tp, 3, 1, 7);
329  Communicator::exchange(Nvt, vcp2_tm, vcp1_tm, 3, -1, 8);
330  }
331 #pragma omp barrier
332 
333  for (int i = is; i < is + ns; ++i) {
334  clear_thread(i, v2);
335  mult_xpb_thread(i, v2, v1);
336  mult_xmb_thread(i, v2, v1);
337 
338  mult_ypb_thread(i, v2, v1);
339  mult_ymb_thread(i, v2, v1);
340 
341  mult_zpb_thread(i, v2, v1);
342  mult_zmb_thread(i, v2, v1);
343 
344  mult_tpb_dirac_thread(i, v2, v1);
345  mult_tmb_dirac_thread(i, v2, v1);
346  }
347 
348  for (int i = is; i < is + ns; ++i) {
349  mult_xp2_thread(i, v2, vcp2_xp);
350  mult_xm2_thread(i, v2, vcp2_xm);
351 
352  mult_yp2_thread(i, v2, vcp2_yp);
353  mult_ym2_thread(i, v2, vcp2_ym);
354 
355  mult_zp2_thread(i, v2, vcp2_zp);
356  mult_zm2_thread(i, v2, vcp2_zm);
357 
360 
361  daypx_thread(i, v2, -m_kappa, v1); // w = -m_kappa * w + f.
362  }
363 
365  }
366 
367 
368 //====================================================================
369  void Fopr_Wilson::D_ex_chiral(Field& w, const int ex1,
370  const Field& f, const int ex2)
371  {
372  const int Ninvol = m_Nvc * m_Nd * m_Nvol;
373  const double *v1 = f.ptr(Ninvol * ex2);
374  double *v2 = w.ptr(Ninvol * ex1);
375 
376  const int Nthread = ThreadManager_OpenMP::get_num_threads();
377  const int i_thread = ThreadManager_OpenMP::get_thread_id();
378 
379  const int is = m_Ntask * i_thread / Nthread;
380  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
381 
382  for (int i = is; i < is + ns; ++i) {
383  mult_xp1_thread(i, vcp1_xp, v1);
384  mult_xm1_thread(i, vcp1_xm, v1);
385 
386  mult_yp1_thread(i, vcp1_yp, v1);
387  mult_ym1_thread(i, vcp1_ym, v1);
388 
389  mult_zp1_thread(i, vcp1_zp, v1);
390  mult_zm1_thread(i, vcp1_zm, v1);
391 
394  }
395 #pragma omp barrier
396 
397 #pragma omp master
398  {
399  const int Nvx = m_Nvc * 2 * m_Ny * m_Nz * m_Nt;
400  Communicator::exchange(Nvx, vcp2_xp, vcp1_xp, 0, 1, 1);
401  Communicator::exchange(Nvx, vcp2_xm, vcp1_xm, 0, -1, 2);
402 
403  const int Nvy = m_Nvc * 2 * m_Nx * m_Nz * m_Nt;
404  Communicator::exchange(Nvy, vcp2_yp, vcp1_yp, 1, 1, 3);
405  Communicator::exchange(Nvy, vcp2_ym, vcp1_ym, 1, -1, 4);
406 
407  const int Nvz = m_Nvc * 2 * m_Nx * m_Ny * m_Nt;
408  Communicator::exchange(Nvz, vcp2_zp, vcp1_zp, 2, 1, 5);
409  Communicator::exchange(Nvz, vcp2_zm, vcp1_zm, 2, -1, 6);
410 
411  const int Nvt = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
412  Communicator::exchange(Nvt, vcp2_tp, vcp1_tp, 3, 1, 7);
413  Communicator::exchange(Nvt, vcp2_tm, vcp1_tm, 3, -1, 8);
414  }
415 #pragma omp barrier
416 
417  for (int i = is; i < is + ns; ++i) {
418  clear_thread(i, v2);
419 
420  mult_xpb_thread(i, v2, v1);
421  mult_xmb_thread(i, v2, v1);
422 
423  mult_ypb_thread(i, v2, v1);
424  mult_ymb_thread(i, v2, v1);
425 
426  mult_zpb_thread(i, v2, v1);
427  mult_zmb_thread(i, v2, v1);
428 
429  mult_tpb_chiral_thread(i, v2, v1);
430  mult_tmb_chiral_thread(i, v2, v1);
431  }
432 
433  for (int i = is; i < is + ns; ++i) {
434  mult_xp2_thread(i, v2, vcp2_xp);
435  mult_xm2_thread(i, v2, vcp2_xm);
436 
437  mult_yp2_thread(i, v2, vcp2_yp);
438  mult_ym2_thread(i, v2, vcp2_ym);
439 
440  mult_zp2_thread(i, v2, vcp2_zp);
441  mult_zm2_thread(i, v2, vcp2_zm);
442 
445 
446  daypx_thread(i, v2, -m_kappa, v1); // w = -m_kappa * w + f.
447  }
448 
450 
451  /*
452  clear(w);
453  mult_xp(w,f);
454  mult_xm(w,f);
455  mult_yp(w,f);
456  mult_ym(w,f);
457  mult_zp(w,f);
458  mult_zm(w,f);
459  mult_tp_chiral(w,f);
460  mult_tm_chiral(w,f);
461  daypx(w, -m_kappa, f); // w = -m_kappa * w + f.
462  */
463  }
464 
465 
466 //====================================================================
467  void Fopr_Wilson::mult_gm5p(const int mu,
468  Field& v, const Field& w)
469  {
470  clear(m_w2);
471 
472  mult_up(mu, m_w2, w);
473  mult_gm5(v, m_w2);
474  }
475 
476 
477 //====================================================================
478  void Fopr_Wilson::proj_chiral(Field& w, const int ex1,
479  const Field& v, const int ex2, const int ipm)
480  {
481  double fpm = 0.0;
482 
483  if (ipm == 1) {
484  fpm = 1.0;
485  } else if (ipm == -1) {
486  fpm = -1.0;
487  } else {
488  vout.crucial(m_vl, "Error at %s: illegal chirality = %d\n", class_name.c_str(), ipm);
489  exit(EXIT_FAILURE);
490  }
491 
492  m_w1.setpart_ex(0, v, ex2);
493  mult_gm5(m_w2, m_w1);
494  m_w1.addpart_ex(0, m_w2, 0, fpm);
495  w.setpart_ex(ex1, m_w1, 0);
496 
497 #pragma omp barrier
498  }
499 
500 
501 //====================================================================
503  const double fac, const Field& f)
504  {
505  double *v2 = w.ptr(0);
506  const double *v1 = f.ptr(0);
507 
508  const int Nthread = ThreadManager_OpenMP::get_num_threads();
509  const int i_thread = ThreadManager_OpenMP::get_thread_id();
510 
511  const int is = m_Ntask * i_thread / Nthread;
512  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
513 
514  for (int i = is; i < is + ns; ++i) {
515  daypx_thread(i, v2, fac, v1);
516  }
517 #pragma omp barrier
518  }
519 
520 
521 //====================================================================
523  {
524  double *v2 = w.ptr(0);
525 
526  const int Nthread = ThreadManager_OpenMP::get_num_threads();
527  const int i_thread = ThreadManager_OpenMP::get_thread_id();
528 
529  const int is = m_Ntask * i_thread / Nthread;
530  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
531 
532  for (int i = is; i < is + ns; ++i) {
533  clear_thread(i, v2);
534  }
535 #pragma omp barrier
536  }
537 
538 
539 //====================================================================
540  void Fopr_Wilson::gm5_dirac(Field& w, const Field& f)
541  {
542  double *v2 = w.ptr(0);
543  const double *v1 = f.ptr(0);
544 
545  const int Nthread = ThreadManager_OpenMP::get_num_threads();
546  const int i_thread = ThreadManager_OpenMP::get_thread_id();
547 
548  const int is = m_Ntask * i_thread / Nthread;
549  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
550 
551  for (int i = is; i < is + ns; ++i) {
552  gm5_dirac_thread(i, v2, v1);
553  }
554 #pragma omp barrier
555  }
556 
557 
558 //====================================================================
560  {
561  double *v2 = w.ptr(0);
562  const double *v1 = f.ptr(0);
563 
564  const int Nthread = ThreadManager_OpenMP::get_num_threads();
565  const int i_thread = ThreadManager_OpenMP::get_thread_id();
566 
567  const int is = m_Ntask * i_thread / Nthread;
568  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
569 
570  for (int i = is; i < is + ns; ++i) {
571  gm5_chiral_thread(i, v2, v1);
572  }
573 #pragma omp barrier
574  }
575 
576 
577 //====================================================================
578  void Fopr_Wilson::mult_xp(Field& w, const Field& f)
579  {
580  double *v2 = w.ptr(0);
581  const double *v1 = f.ptr(0);
582 
583  const int Nthread = ThreadManager_OpenMP::get_num_threads();
584  const int i_thread = ThreadManager_OpenMP::get_thread_id();
585 
586  const int is = m_Ntask * i_thread / Nthread;
587  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
588 
589 #pragma omp barrier
590 
591  for (int i = is; i < is + ns; ++i) {
592  mult_xp1_thread(i, vcp1_xp, v1);
593  }
594 
595 #pragma omp barrier
596 #pragma omp master
597  {
598  const int Nv = m_Nvc * 2 * m_Ny * m_Nz * m_Nt;
599  Communicator::exchange(Nv, vcp2_xp, vcp1_xp, 0, 1, 1);
600  }
601 #pragma omp barrier
602 
603  for (int i = is; i < is + ns; ++i) {
604  mult_xpb_thread(i, v2, v1);
605  }
606 
607  for (int i = is; i < is + ns; ++i) {
608  mult_xp2_thread(i, v2, vcp2_xp);
609  }
610 
612  }
613 
614 
615 //====================================================================
616  void Fopr_Wilson::mult_xm(Field& w, const Field& f)
617  {
618  double *v2 = w.ptr(0);
619  const double *v1 = f.ptr(0);
620 
621  const int Nthread = ThreadManager_OpenMP::get_num_threads();
622  const int i_thread = ThreadManager_OpenMP::get_thread_id();
623 
624  const int is = m_Ntask * i_thread / Nthread;
625  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
626 
627 #pragma omp barrier
628 
629  for (int i = is; i < is + ns; ++i) {
630  mult_xm1_thread(i, vcp1_xm, v1);
631  }
632 
633 #pragma omp barrier
634 #pragma omp master
635  {
636  const int Nv = m_Nvc * 2 * m_Ny * m_Nz * m_Nt;
637  Communicator::exchange(Nv, vcp2_xm, vcp1_xm, 0, -1, 2);
638  }
639 #pragma omp barrier
640 
641  for (int i = is; i < is + ns; ++i) {
642  mult_xmb_thread(i, v2, v1);
643  }
644 
645  for (int i = is; i < is + ns; ++i) {
646  mult_xm2_thread(i, v2, vcp2_xm);
647  }
648 
650  }
651 
652 
653 //====================================================================
654  void Fopr_Wilson::mult_yp(Field& w, const Field& f)
655  {
656  double *v2 = w.ptr(0);
657  const double *v1 = f.ptr(0);
658 
659  const int Nthread = ThreadManager_OpenMP::get_num_threads();
660  const int i_thread = ThreadManager_OpenMP::get_thread_id();
661 
662  const int is = m_Ntask * i_thread / Nthread;
663  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
664 
665 #pragma omp barrier
666 
667  for (int i = is; i < is + ns; ++i) {
668  mult_yp1_thread(i, vcp1_yp, v1);
669  }
670 
671 #pragma omp barrier
672 #pragma omp master
673  {
674  const int Nv = m_Nvc * 2 * m_Nx * m_Nz * m_Nt;
675  Communicator::exchange(Nv, vcp2_yp, vcp1_yp, 1, 1, 3);
676  }
677 #pragma omp barrier
678 
679  for (int i = is; i < is + ns; ++i) {
680  mult_ypb_thread(i, v2, v1);
681  }
682 
683  for (int i = is; i < is + ns; ++i) {
684  mult_yp2_thread(i, v2, vcp2_yp);
685  }
686 
688  }
689 
690 
691 //====================================================================
692  void Fopr_Wilson::mult_ym(Field& w, const Field& f)
693  {
694  double *v2 = w.ptr(0);
695  const double *v1 = f.ptr(0);
696 
697  const int Nthread = ThreadManager_OpenMP::get_num_threads();
698  const int i_thread = ThreadManager_OpenMP::get_thread_id();
699 
700  const int is = m_Ntask * i_thread / Nthread;
701  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
702 
703 #pragma omp barrier
704 
705  for (int i = is; i < is + ns; ++i) {
706  mult_ym1_thread(i, vcp1_ym, v1);
707  }
708 
709 #pragma omp barrier
710 #pragma omp master
711  {
712  const int Nv = m_Nvc * 2 * m_Nx * m_Nz * m_Nt;
713  Communicator::exchange(Nv, vcp2_ym, vcp1_ym, 1, -1, 4);
714  }
715 #pragma omp barrier
716 
717  for (int i = is; i < is + ns; ++i) {
718  mult_ymb_thread(i, v2, v1);
719  }
720 
721  for (int i = is; i < is + ns; ++i) {
722  mult_ym2_thread(i, v2, vcp2_ym);
723  }
724 
726  }
727 
728 
729 //====================================================================
730  void Fopr_Wilson::mult_zp(Field& w, const Field& f)
731  {
732  double *v2 = w.ptr(0);
733  const double *v1 = f.ptr(0);
734 
735  const int Nthread = ThreadManager_OpenMP::get_num_threads();
736  const int i_thread = ThreadManager_OpenMP::get_thread_id();
737 
738  const int is = m_Ntask * i_thread / Nthread;
739  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
740 
741 #pragma omp barrier
742 
743  for (int i = is; i < is + ns; ++i) {
744  mult_zp1_thread(i, vcp1_zp, v1);
745  }
746 
747 #pragma omp barrier
748 #pragma omp master
749  {
750  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nt;
751  Communicator::exchange(Nv, vcp2_zp, vcp1_zp, 2, 1, 5);
752  }
753 #pragma omp barrier
754 
755  for (int i = is; i < is + ns; ++i) {
756  mult_zpb_thread(i, v2, v1);
757  }
758 
759  for (int i = is; i < is + ns; ++i) {
760  mult_zp2_thread(i, v2, vcp2_zp);
761  }
762 
764  }
765 
766 
767 //====================================================================
768  void Fopr_Wilson::mult_zm(Field& w, const Field& f)
769  {
770  double *v2 = w.ptr(0);
771  const double *v1 = f.ptr(0);
772 
773  const int Nthread = ThreadManager_OpenMP::get_num_threads();
774  const int i_thread = ThreadManager_OpenMP::get_thread_id();
775 
776  const int is = m_Ntask * i_thread / Nthread;
777  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
778 
779 #pragma omp barrier
780 
781  for (int i = is; i < is + ns; ++i) {
782  mult_zm1_thread(i, vcp1_zm, v1);
783  }
784 
785 #pragma omp barrier
786 #pragma omp master
787  {
788  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nt;
789  Communicator::exchange(Nv, vcp2_zm, vcp1_zm, 2, -1, 6);
790  }
791 #pragma omp barrier
792 
793  for (int i = is; i < is + ns; ++i) {
794  mult_zmb_thread(i, v2, v1);
795  }
796 
797  for (int i = is; i < is + ns; ++i) {
798  mult_zm2_thread(i, v2, vcp2_zm);
799  }
800 
802  }
803 
804 
805 //====================================================================
807  {
808  double *v2 = w.ptr(0);
809  const double *v1 = f.ptr(0);
810 
811  const int Nthread = ThreadManager_OpenMP::get_num_threads();
812  const int i_thread = ThreadManager_OpenMP::get_thread_id();
813 
814  const int is = m_Ntask * i_thread / Nthread;
815  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
816 
817 #pragma omp barrier
818 
819  for (int i = is; i < is + ns; ++i) {
821  }
822 
823 #pragma omp barrier
824 #pragma omp master
825  {
826  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
827  Communicator::exchange(Nv, vcp2_tp, vcp1_tp, 3, 1, 7);
828  }
829 #pragma omp barrier
830 
831  for (int i = is; i < is + ns; ++i) {
832  mult_tpb_dirac_thread(i, v2, v1);
833  }
834 
835  for (int i = is; i < is + ns; ++i) {
837  }
838 
840  }
841 
842 
843 //====================================================================
845  {
846  double *v2 = w.ptr(0);
847  const double *v1 = f.ptr(0);
848 
849  const int Nthread = ThreadManager_OpenMP::get_num_threads();
850  const int i_thread = ThreadManager_OpenMP::get_thread_id();
851 
852  const int is = m_Ntask * i_thread / Nthread;
853  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
854 
855 #pragma omp barrier
856 
857  for (int i = is; i < is + ns; ++i) {
859  }
860 
861 #pragma omp barrier
862 #pragma omp master
863  {
864  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
865  Communicator::exchange(Nv, vcp2_tm, vcp1_tm, 3, -1, 8);
866  }
867 #pragma omp barrier
868 
869  for (int i = is; i < is + ns; ++i) {
870  mult_tmb_dirac_thread(i, v2, v1);
871  }
872 
873  for (int i = is; i < is + ns; ++i) {
875  }
876 
878  }
879 
880 
881 //====================================================================
883  {
884  double *v2 = w.ptr(0);
885  const double *v1 = f.ptr(0);
886 
887  const int Nthread = ThreadManager_OpenMP::get_num_threads();
888  const int i_thread = ThreadManager_OpenMP::get_thread_id();
889 
890  const int is = m_Ntask * i_thread / Nthread;
891  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
892 
893 #pragma omp barrier
894 
895  for (int i = is; i < is + ns; ++i) {
897  }
898 
899 #pragma omp barrier
900 #pragma omp master
901  {
902  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
903  Communicator::exchange(Nv, vcp2_tp, vcp1_tp, 3, 1, 7);
904  }
905 #pragma omp barrier
906 
907  for (int i = is; i < is + ns; ++i) {
908  mult_tpb_chiral_thread(i, v2, v1);
909  }
910 
911  for (int i = is; i < is + ns; ++i) {
913  }
914 
916  }
917 
918 
919 //====================================================================
921  {
922  double *v2 = w.ptr(0);
923  const double *v1 = f.ptr(0);
924 
925  const int Nthread = ThreadManager_OpenMP::get_num_threads();
926  const int i_thread = ThreadManager_OpenMP::get_thread_id();
927 
928  const int is = m_Ntask * i_thread / Nthread;
929  const int ns = m_Ntask * (i_thread + 1) / Nthread - is;
930 
931 #pragma omp barrier
932 
933  for (int i = is; i < is + ns; ++i) {
935  }
936 
937 #pragma omp barrier
938 #pragma omp master
939  {
940  const int Nv = m_Nvc * 2 * m_Nx * m_Ny * m_Nz;
941  Communicator::exchange(Nv, vcp2_tm, vcp1_tm, 3, -1, 8);
942  }
943 #pragma omp barrier
944 
945  for (int i = is; i < is + ns; ++i) {
946  mult_tmb_chiral_thread(i, v2, v1);
947  }
948 
949  for (int i = is; i < is + ns; ++i) {
951  }
952 
954  }
955 
956 
957 //====================================================================
959  {
960  // Counting of floating point operations in giga unit.
961  // The following counting explicitly depends on the implementation.
962  // It will be recalculated when the code is modified.
963  // The present counting is based on rev.1107. [24 Aug 2014 H.Matsufuru]
964 
965  const int Nvol = CommonParameters::Nvol();
966  const int NPE = CommonParameters::NPE();
967 
968  int flop_site;
969 
970  if (m_repr == "Dirac") {
971  flop_site = m_Nc * m_Nd * (4 + 6 * (4 * m_Nc + 2) + 2 * (4 * m_Nc + 1));
972  } else if (m_repr == "Chiral") {
973  flop_site = m_Nc * m_Nd * (4 + 8 * (4 * m_Nc + 2));
974  } else {
975  vout.crucial(m_vl, "Error at %s: input repr is undefined.\n", class_name.c_str());
976  exit(EXIT_FAILURE);
977  }
978 
979  double gflop = flop_site * (Nvol * (NPE / 1.0e+9));
980 
981  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop *= 2;
982 
983  return gflop;
984  }
985 
986 
987 //====================================================================
988 }
989 //============================================================END=====
void mult_tp_dirac(Field &, const Field &)
void mult_ypb_thread(const int, double *, const double *)
void Ddag(Field &w, const Field &f)
double flop_count()
returns the flop in giga unit
BridgeIO vout
Definition: bridgeIO.cpp:503
void mult_yp2_thread(const int, double *, const double *)
void mult_zp(Field &, const Field &)
void DDdag(Field &w, const Field &f)
void(Fopr_Wilson::* m_mult_dag)(Field &, const Field &)
static int get_num_threads()
returns available number of threads.
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
std::string m_repr
void init(const std::string repr)
void mult_xmb_thread(const int, double *, const double *)
void(Fopr_Wilson::* m_mult)(Field &, const Field &)
void proj_chiral(Field &w, const int ex1, const Field &v, const int ex2, const int ipm)
void(Fopr_Wilson::* m_gm5)(Field &, const Field &)
void mult_tmb_chiral_thread(const int, double *, const double *)
void D_dirac(Field &, const Field &)
void(Fopr_Wilson::* m_mult_tp)(Field &, const Field &)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
void mult_yp(Field &, const Field &)
static Bridge::VerboseLevel Vlevel()
void mult_yp1_thread(const int, double *, const double *)
void mult_xpb_thread(const int, double *, const double *)
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void gm5_chiral(Field &, const Field &)
std::vector< double > m_boundary_each_node
b.c. for each node.
void mult_tm_chiral(Field &, const Field &)
void D(Field &v, const Field &f)
void mult_tp1_chiral_thread(const int, double *, const double *)
double * vcp1_xp
arrays for data transfer.
Bridge::VerboseLevel m_vl
void clear_thread(const int, double *)
void gm5_dirac(Field &, const Field &)
void(Fopr_Wilson::* m_D_ex)(Field &, const int, const Field &, const int)
const Field_G * m_U
gauge configuration.
void mult_tpb_chiral_thread(const int, double *, const double *)
Class for parameters.
Definition: parameters.h:46
void(Fopr_Wilson::* m_D)(Field &, const Field &)
static int ipe(const int dir)
logical coordinate of current proc.
void mult_xm(Field &, const Field &)
void set_parameters(const Parameters &params)
void mult_tpb_dirac_thread(const int, double *, const double *)
void mult_zm2_thread(const int, double *, const double *)
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
void mult_tp1_dirac_thread(const int, double *, const double *)
void mult_zp2_thread(const int, double *, const double *)
static int get_thread_id()
returns thread id.
void mult_xm1_thread(const int, double *, const double *)
void gm5_chiral_thread(const int, double *, const double *)
void mult_xp2_thread(const int, double *, const double *)
void mult_zmb_thread(const int, double *, const double *)
void mult_ymb_thread(const int, double *, const double *)
const Field_F mult_gm5p(const int mu, const Field_F &w)
void mult_tp_chiral(Field &, const Field &)
void daypx_thread(const int, double *, const double, const double *)
std::vector< int > m_boundary
boundary condition.
void D_chiral(Field &, const Field &)
void mult_tm2_dirac_thread(const int, double *, const double *)
void mult_tm1_chiral_thread(const int, double *, const double *)
static void sync_barrier_all()
barrier among all the threads and nodes.
void mult_xp1_thread(const int, double *, const double *)
static int exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int tag)
receive array of double from upstream specified by idir and ipm, and send array to downstream...
void mult_tmb_dirac_thread(const int, double *, const double *)
void mult_tm1_dirac_thread(const int, double *, const double *)
void mult_tp2_dirac_thread(const int, double *, const double *)
void gm5_dirac_thread(const int, double *, const double *)
void mult_zm1_thread(const int, double *, const double *)
std::string m_mode
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
void D_ex_chiral(Field &, const int ex1, const Field &, const int ex2)
void mult_tm_dirac(Field &, const Field &)
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void mult_undef(Field &, const Field &f)
void mult_tm2_chiral_thread(const int, double *, const double *)
void mult_ym(Field &, const Field &)
void mult_up(const int mu, Field &, const Field &)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
void mult_dn(const int mu, Field &, const Field &)
void mult_ym2_thread(const int, double *, const double *)
void mult_tp2_chiral_thread(const int, double *, const double *)
void D_ex_dirac(Field &, const int ex1, const Field &, const int ex2)
void DdagD(Field &w, const Field &f)
void H(Field &w, const Field &f)
void(Fopr_Wilson::* m_mult_tm)(Field &, const Field &)
std::string get_mode() const
only for Fopr_Overlap
void mult_xm2_thread(const int, double *, const double *)
void mult_zp1_thread(const int, double *, const double *)
void mult_xp(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
std::vector< GammaMatrix > m_GM
gamma matrices.
void mult_zm(Field &, const Field &)
void mult_zpb_thread(const int, double *, const double *)
Field m_w2
temporary fields.
void mult_ym1_thread(const int, double *, const double *)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void daypx(Field &, const double, const Field &)
void mult_gm5(Field &v, const Field &f)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
static const std::string class_name