Bridge++  Ver. 2.0.2
shiftAField_eo-tmpl.h
Go to the documentation of this file.
1 
11 template<typename AFIELD>
12 const std::string ShiftAField_eo<AFIELD>::class_name =
13  "ShiftAField_eo<AFIELD>";
14 //====================================================================
15 template<typename AFIELD>
17 {
18  int Ndim = CommonParameters::Ndim();
19  std::vector<int> bc(Ndim);
20  for (int mu = 0; mu < Ndim; ++mu) {
21  bc[mu] = 1;
22  }
23 
24  init(Nin, bc);
25 }
26 
27 
28 //====================================================================
29 template<typename AFIELD>
30 void ShiftAField_eo<AFIELD>::init(int Nin, std::vector<int>& bc)
31 {
32  m_vl = CommonParameters::Vlevel();
33 
34  int req_comm = 0;
35  //int req_comm = 1; // set 1 if communication forced any time
36 
37  vout.general(m_vl, "%s: being constructed.\n", class_name.c_str());
38 
39  m_Nin = Nin;
40  vout.general(m_vl, " Nin = %d\n", m_Nin);
41 
42  m_Nx = CommonParameters::Nx();
43  m_Ny = CommonParameters::Ny();
44  m_Nz = CommonParameters::Nz();
45  m_Nt = CommonParameters::Nt();
46  m_Nvol = m_Nx * m_Ny * m_Nz * m_Nt;
47  m_Nx2 = m_Nx / 2;
48  m_Nvol2 = m_Nvol / 2;
49 
50  m_Ndim = CommonParameters::Ndim();
51 
52  m_Nx2v = m_Nx2 / VLENX;
53  m_Nyv = m_Ny / VLENY;
54  m_Nst2v = m_Nvol2 / VLEN;
55 
56  vout.general(m_vl, " VLENX = %d VLENY = %d\n", VLENX, VLENY);
57  vout.general(m_vl, " Nx2 = %d Nvol2 = %d\n", m_Nx2, m_Nvol2);
58  vout.general(m_vl, " Nx2v = %d Nyv = %d\n", m_Nx2v, m_Nyv);
59 
60  if (bc.size() != m_Ndim) {
61  vout.crucial(m_vl, "%s: incorrect size of boundary condition\n",
62  class_name.c_str());
63  exit(EXIT_FAILURE);
64  }
65 
66  m_boundary.resize(m_Ndim);
67 
68  for (int mu = 0; mu < m_Ndim; ++mu) {
69  m_boundary[mu] = bc[mu];
70  vout.general(m_vl, " boundary[%d] = %2d\n", mu, m_boundary[mu]);
71  }
72 
73  do_comm_any = 0;
74  for (int mu = 0; mu < m_Ndim; ++mu) {
75  do_comm[mu] = 1;
76  if ((req_comm == 0) && (Communicator::npe(mu) == 1)) do_comm[mu] = 0;
77  do_comm_any += do_comm[mu];
78  vout.general(" do_comm[%d] = %d\n", mu, do_comm[mu]);
79  }
80 
81  m_Nbdsize.resize(m_Ndim);
82  m_Nbdsize[0] = m_Nin * m_Ny * m_Nz * m_Nt;
83  m_Nbdsize[1] = m_Nin * m_Nx * m_Nz * m_Nt;
84  m_Nbdsize[2] = m_Nin * m_Nx * m_Ny * m_Nt;
85  m_Nbdsize[3] = m_Nin * m_Nx * m_Ny * m_Nz;
86 
87  setup_channels();
88 
89  vout.general(m_vl, "%s: construction finished.\n", class_name.c_str());
90 }
91 
92 
93 //====================================================================
94 template<typename AFIELD>
96 {
97 }
98 
99 
100 //====================================================================
101 template<typename AFIELD>
103 {
104  chsend_up.resize(m_Ndim);
105  chrecv_up.resize(m_Ndim);
106  chsend_dn.resize(m_Ndim);
107  chrecv_dn.resize(m_Ndim);
108 
109  for (int mu = 0; mu < m_Ndim; ++mu) {
110  int Nvsize = m_Nbdsize[mu] * sizeof(real_t);
111 
112  chsend_dn[mu].send_init(Nvsize, mu, -1);
113  chsend_up[mu].send_init(Nvsize, mu, 1);
114 #ifdef USE_MPI
115  chrecv_up[mu].recv_init(Nvsize, mu, 1);
116  chrecv_dn[mu].recv_init(Nvsize, mu, -1);
117 #else
118  void *buf_up = (void *)chsend_dn[mu].ptr();
119  chrecv_up[mu].recv_init(Nvsize, mu, 1, buf_up);
120  void *buf_dn = (void *)chsend_up[mu].ptr();
121  chrecv_dn[mu].recv_init(Nvsize, mu, -1, buf_dn);
122 #endif
123  if (do_comm[mu] == 1) {
124  chset_send.append(chsend_up[mu]);
125  chset_send.append(chsend_dn[mu]);
126  chset_recv.append(chrecv_up[mu]);
127  chset_recv.append(chrecv_dn[mu]);
128  }
129  }
130 }
131 
132 
133 //====================================================================
134 template<typename AFIELD>
136  const int mu, const int ieo)
137 {
138  int Nex = w.nex();
139  assert(w.check_size(m_Nin, m_Nvol, Nex));
140  assert(v.check_size(m_Nin, m_Nvol, Nex));
141 
143 
144  for (int ex = 0; ex < Nex; ++ex) {
145  real_t *vp = v.ptr(index.idxh(0, m_Nin, 0, ex));
146  real_t *wp = const_cast<AFIELD *>(&w)->ptr(index.idxh(0, m_Nin, 0, ex));
147 
148  if (mu == 0) {
149  //up_xh_simd(vp, wp, ieo);
150  up_xh_naive(vp, wp, ieo);
151  } else if (mu == 1) {
152  up_yh_nv(vp, wp, ieo);
153  } else if (mu == 2) {
154  up_zh_nv(vp, wp, ieo);
155  } else if (mu == 3) {
156  up_th_nv(vp, wp, ieo);
157  } else {
158  vout.crucial(m_vl, "Error at %s: wrong parameter\n",
159  class_name.c_str());
160  exit(EXIT_FAILURE);
161  }
162  }
163 }
164 
165 
166 //====================================================================
167 template<typename AFIELD>
169  const AFIELD& w, const int ex2,
170  const int mu, const int ieo)
171 {
172  int Nex = v.nex();
173  assert(v.check_size(m_Nin, m_Nvol, Nex));
174  assert(ex1 < Nex);
175  Nex = w.nex();
176  assert(w.check_size(m_Nin, m_Nvol, Nex));
177  assert(ex2 < Nex);
178 
180 
181  real_t *vp = v.ptr(index.idxh(0, m_Nin, 0, ex1));
182  real_t *wp = const_cast<AFIELD *>(&w)->ptr(index.idxh(0, m_Nin, 0, ex2));
183 
184  if (mu == 0) {
185  //up_xh_simd(vp, wp, ieo);
186  up_xh_naive(vp, wp, ieo);
187  } else if (mu == 1) {
188  up_yh_nv(vp, wp, ieo);
189  } else if (mu == 2) {
190  up_zh_nv(vp, wp, ieo);
191  } else if (mu == 3) {
192  up_th_nv(vp, wp, ieo);
193  } else {
194  vout.crucial(m_vl, "Error at %s: wrong parameter\n",
195  class_name.c_str());
196  exit(EXIT_FAILURE);
197  }
198 }
199 
200 
201 //====================================================================
202 template<typename AFIELD>
204  const int mu, const int ieo)
205 {
206  int Nex = w.nex();
207  assert(w.check_size(m_Nin, m_Nvol, Nex));
208  assert(v.check_size(m_Nin, m_Nvol, Nex));
209 
211 
212  for (int ex = 0; ex < Nex; ++ex) {
213  real_t *vp = v.ptr(index.idxh(0, m_Nin, 0, ex));
214  real_t *wp = const_cast<AFIELD *>(&w)->ptr(index.idxh(0, m_Nin, 0, ex));
215 
216  if (mu == 0) {
217  //dn_xh_simd(vp, wp, ieo);
218  dn_xh_naive(vp, wp, ieo);
219  } else if (mu == 1) {
220  dn_yh_nv(vp, wp, ieo);
221  } else if (mu == 2) {
222  dn_zh_nv(vp, wp, ieo);
223  } else if (mu == 3) {
224  dn_th_nv(vp, wp, ieo);
225  } else {
226  vout.crucial(m_vl, "Error at %s: wrong parameter\n",
227  class_name.c_str());
228  exit(EXIT_FAILURE);
229  }
230  }
231 }
232 
233 
234 //====================================================================
235 template<typename AFIELD>
237  const AFIELD& w, const int ex2,
238  const int mu, const int ieo)
239 {
240  int Nex = v.nex();
241  assert(v.check_size(m_Nin, m_Nvol, Nex));
242  assert(ex1 < Nex);
243  Nex = w.nex();
244  assert(w.check_size(m_Nin, m_Nvol, Nex));
245  assert(ex2 < Nex);
246 
248 
249  real_t *vp = v.ptr(index.idxh(0, m_Nin, 0, ex1));
250  real_t *wp = const_cast<AFIELD *>(&w)->ptr(index.idxh(0, m_Nin, 0, ex2));
251 
252  if (mu == 0) {
253  //dn_xh_simd(vp, wp, ieo);
254  dn_xh_naive(vp, wp, ieo);
255  } else if (mu == 1) {
256  dn_yh_nv(vp, wp, ieo);
257  } else if (mu == 2) {
258  dn_zh_nv(vp, wp, ieo);
259  } else if (mu == 3) {
260  dn_th_nv(vp, wp, ieo);
261  } else {
262  vout.crucial(m_vl, "Error at %s: wrong parameter\n",
263  class_name.c_str());
264  exit(EXIT_FAILURE);
265  }
266 }
267 
268 
269 //====================================================================
270 #ifdef USE_QXS_ACLE
271 
272 template<typename AFIELD>
274  const int ieo)
275 {
276  real_t bc2 = 1.0;
277  if (Communicator::ipe(0) == 0) bc2 = real_t(m_boundary[0]);
278 
279  int ex = 0; // ex loop is outside this method
280 
281  real_t *buf1 = (real_t *)chsend_dn[0].ptr();
282  real_t *buf2 = (real_t *)chrecv_up[0].ptr();
283 
285 
286  // qqqqqq
287 
288  int ith, nth, is, ns;
289  set_threadtask(ith, nth, is, ns, m_Nst2v);
290 
291 #pragma omp barrier
292 
293  if (do_comm[0] == 1) {
294 #pragma omp barrier
295 
296 #pragma omp master
297  {
298  chrecv_up[0].start();
299  chsend_dn[0].start();
300  // communication is not overlapped in x-direction.
301  chrecv_up[0].wait();
302  chsend_dn[0].wait();
303  }
304 
305 #pragma omp barrier
306  }
307 
308  Vsimd_t xt;
309  for (int site = is; site < ns; ++site) {
310  int ix2 = site % m_Nx2v;
311  int iyzt = site / m_Nx2v;
312  int leo = index_alt.leo(VLENY * iyzt);
313  int jeo = (ieo + leo) % 2;
314  if ((ix2 < m_Nx2v - 1) || (do_comm[0] == 0)) {
315  int nei = site + 1;
316  if (ix2 == m_Nx2v - 1) nei = 0 + m_Nx2v * iyzt;
317  for (int in = 0; in < m_Nin; ++in) {
318  int iw1 = VLEN * (in + m_Nin * site);
319  int iw2 = VLEN * (in + m_Nin * nei);
320  shift_vec2_xbw_eo(&xt, &wp[iw1], &wp[iw2], jeo, 1);
321  save_vec(&vp[iw1], &xt, 1);
322  }
323  }
324  }
325 
326 
327 #pragma omp barrier
328 }
329 
330 
331 #endif
332 
333 //====================================================================
334 template<typename AFIELD>
336  const int ieo)
337 {
338  real_t bc2 = 1.0;
339  if (Communicator::ipe(0) == 0) bc2 = real_t(m_boundary[0]);
340 
341  int ex = 0; // ex loop is outside this method
342 
343  real_t *buf1 = (real_t *)chsend_dn[0].ptr();
344  real_t *buf2 = (real_t *)chrecv_up[0].ptr();
345 
347 
348  int ith, nth, is, ns;
349  set_threadtask(ith, nth, is, ns, m_Nvol2);
350 
351 #pragma omp barrier
352 
353  if (do_comm[0] == 1) {
354  for (int site = is; site < ns; ++site) {
355  int ix2 = site % m_Nx2;
356  int iyzt = site / m_Nx2;
357  int iyzt2 = iyzt / 2;
358  int leo = index_alt.leo(iyzt);
359  if ((ix2 == 0) && (leo == (1 - ieo))) {
360  for (int in = 0; in < m_Nin; ++in) {
361  int index = index_alt.idxh(in, m_Nin, site, ex);
362  buf1[in + m_Nin * iyzt2] = bc2 * wp[index];
363  }
364  }
365  }
366 
367 #pragma omp barrier
368 
369 #pragma omp master
370  {
371  chrecv_up[0].start();
372  chsend_dn[0].start();
373  // communication is not overlapped in x-direction.
374  chrecv_up[0].wait();
375  chsend_dn[0].wait();
376  }
377 
378 #pragma omp barrier
379  }
380 
381  for (int site = is; site < ns; ++site) {
382  int ix2 = site % m_Nx2;
383  int iyzt = site / m_Nx2;
384  int leo = index_alt.leo(iyzt);
385  if (leo == ieo) {
386  for (int in = 0; in < m_Nin; ++in) {
387  int iv = index_alt.idxh(in, m_Nin, site, ex);
388  vp[iv] = wp[iv];
389  }
390  } else {
391  if ((ix2 < m_Nx2 - 1) || (do_comm[0] == 0)) {
392  int nei = ix2 + 1 + m_Nx2 * iyzt;
393  int bc3 = 1.0;
394  if (ix2 == m_Nx2 - 1) {
395  nei = 0 + m_Nx2 * iyzt;
396  bc3 = bc2;
397  }
398  for (int in = 0; in < m_Nin; ++in) {
399  int iv = index_alt.idxh(in, m_Nin, site, ex);
400  int iw = index_alt.idxh(in, m_Nin, nei, ex);
401  vp[iv] = bc3 * wp[iw];
402  }
403  } else {
404  for (int in = 0; in < m_Nin; ++in) {
405  int iv = index_alt.idxh(in, m_Nin, site, ex);
406  int iyzt2 = iyzt / 2;
407  vp[iv] = buf2[in + m_Nin * iyzt2];
408  }
409  }
410  }
411  }
412 
413 #pragma omp barrier
414 }
415 
416 
417 //====================================================================
418 #ifdef USE_QXS_ACLE
419 
420 template<typename AFIELD>
422  const int ieo)
423 {
424  real_t bc2 = 1.0;
425  if (Communicator::ipe(0) == Communicator::npe(0) - 1) {
426  bc2 = real_t(m_boundary[0]);
427  }
428 
429  int ex = 0; // ex loop is outside this method
430 
431  real_t *buf1 = (real_t *)chsend_up[0].ptr();
432  real_t *buf2 = (real_t *)chrecv_dn[0].ptr();
433 
435 
436  int ith, nth, is, ns;
437  set_threadtask(ith, nth, is, ns, m_Nst2v);
438 
439 #pragma omp barrier
440 
441  if (do_comm[0] == 1) {
442 #pragma omp barrier
443 
444 #pragma omp master
445  {
446  chrecv_dn[0].start();
447  chsend_up[0].start();
448  // communication is not overlapped in x-direction.
449  chrecv_dn[0].wait();
450  chsend_up[0].wait();
451  }
452 
453 #pragma omp barrier
454  }
455 
456  Vsimd_t xt;
457  for (int site = is; site < ns; ++site) {
458  int ix2 = site % m_Nx2v;
459  int iyzt = site / m_Nx2v;
460  int leo = index_alt.leo(VLENY * iyzt);
461  int jeo = (ieo + leo) % 2;
462  if ((ix2 > 0) || (do_comm[0] == 0)) {
463  int nei = site - 1;
464  if (ix2 == 0) nei = m_Nx2v - 1 + m_Nx2v * iyzt;
465  for (int in = 0; in < m_Nin; ++in) {
466  int iw1 = VLEN * (in + m_Nin * site);
467  int iw2 = VLEN * (in + m_Nin * nei);
468  shift_vec2_xfw_eo(&xt, &wp[iw1], &wp[iw2], jeo, 1);
469  save_vec(&vp[iw1], &xt, 1);
470  }
471  }
472  }
473 
474 
475 
476 #pragma omp barrier
477 }
478 
479 
480 #endif
481 
482 //====================================================================
483 template<typename AFIELD>
485  const int ieo)
486 {
487  real_t bc2 = 1.0;
488  if (Communicator::ipe(0) == Communicator::npe(0) - 1) {
489  bc2 = real_t(m_boundary[0]);
490  }
491 
492  int ex = 0; // ex loop is outside this method
493 
494  real_t *buf1 = (real_t *)chsend_up[0].ptr();
495  real_t *buf2 = (real_t *)chrecv_dn[0].ptr();
496 
498 
499  int ith, nth, is, ns;
500  set_threadtask(ith, nth, is, ns, m_Nvol2);
501 
502 #pragma omp barrier
503 
504  if (do_comm[0] == 1) {
505  for (int site = is; site < ns; ++site) {
506  int ix2 = site % m_Nx2;
507  int iyzt = site / m_Nx2;
508  int iyzt2 = iyzt / 2;
509  int leo = index_alt.leo(iyzt);
510  if ((ix2 == m_Nx2 - 1) && (leo == ieo)) {
511  for (int in = 0; in < m_Nin; ++in) {
512  int index = index_alt.idxh(in, m_Nin, site, ex);
513  buf1[in + m_Nin * iyzt2] = bc2 * wp[index];
514  }
515  }
516  }
517 
518 #pragma omp barrier
519 
520 #pragma omp master
521  {
522  chrecv_dn[0].start();
523  chsend_up[0].start();
524  // communication is not overlapped in x-direction.
525  chrecv_dn[0].wait();
526  chsend_up[0].wait();
527  }
528 
529 #pragma omp barrier
530  }
531 
532  for (int site = is; site < ns; ++site) {
533  int ix2 = site % m_Nx2;
534  int iyzt = site / m_Nx2;
535  int leo = index_alt.leo(iyzt);
536  if (leo == (1 - ieo)) {
537  for (int in = 0; in < m_Nin; ++in) {
538  int iv = index_alt.idxh(in, m_Nin, site, ex);
539  vp[iv] = wp[iv];
540  }
541  } else {
542  if ((ix2 > 0) || (do_comm[0] == 0)) {
543  int nei = ix2 - 1 + m_Nx2 * iyzt;
544  int bc3 = 1.0;
545  if (ix2 == 0) {
546  nei = m_Nx2 - 1 + m_Nx2 * iyzt;
547  bc3 = bc2;
548  }
549  for (int in = 0; in < m_Nin; ++in) {
550  int iv = index_alt.idxh(in, m_Nin, site, ex);
551  int iw = index_alt.idxh(in, m_Nin, nei, ex);
552  vp[iv] = bc3 * wp[iw];
553  }
554  } else {
555  for (int in = 0; in < m_Nin; ++in) {
556  int iv = index_alt.idxh(in, m_Nin, site, ex);
557  int iyzt2 = iyzt / 2;
558  vp[iv] = buf2[in + m_Nin * iyzt2];
559  }
560  }
561  }
562  }
563 
564 #pragma omp barrier
565 }
566 
567 
568 //====================================================================
569 template<typename AFIELD>
571  const int ieo)
572 {
573  real_t bc2 = 1.0;
574  if (Communicator::ipe(1) == 0) bc2 = real_t(m_boundary[1]);
575 
576  int ex = 0;
577 
578  real_t *buf1 = (real_t *)chsend_dn[1].ptr();
579  real_t *buf2 = (real_t *)chrecv_up[1].ptr();
580 
582 
583  int ith, nth, is, ns;
584  set_threadtask(ith, nth, is, ns, m_Nvol2);
585 
586 #pragma omp barrier
587 
588  if (do_comm[1] == 1) {
589 #pragma omp master
590  {
591  chrecv_up[1].start();
592  }
593  for (int site = is; site < ns; ++site) {
594  int ix = site % m_Nx2;
595  int iy = (site / m_Nx2) % m_Ny;
596  int izt = site / (m_Nx2 * m_Ny);
597  if (iy == 0) {
598  for (int in = 0; in < m_Nin; ++in) {
599  int iw = index_alt.idxh(in, m_Nin, site, ex);
600  int ixzt = ix + m_Nx2 * izt;
601  buf1[in + m_Nin * ixzt] = bc2 * wp[iw];
602  }
603  }
604  }
605 
606 #pragma omp barrier
607 #pragma omp master
608  {
609  chsend_dn[1].start();
610  }
611  } // if(do_comm[1] == 1)
612 
613  for (int site = is; site < ns; ++site) {
614  int ix = site % m_Nx2;
615  int iy = (site / m_Nx2) % m_Ny;
616  int izt = site / (m_Nx2 * m_Ny);
617  if ((iy < m_Ny - 1) || (do_comm[1] == 0)) {
618  int iy2 = (iy + 1) % m_Ny;
619  int nei = ix + m_Nx2 * (iy2 + m_Ny * izt);
620  real_t bc3 = 1.0;
621  if (iy == m_Ny - 1) bc3 = bc2;
622  for (int in = 0; in < m_Nin; ++in) {
623  int iv = index_alt.idxh(in, m_Nin, site, ex);
624  int iw = index_alt.idxh(in, m_Nin, nei, ex);
625  vp[iv] = bc3 * wp[iw];
626  }
627  }
628  }
629 
630  if (do_comm[1] == 1) {
631 #pragma omp master
632  {
633  chrecv_up[1].wait();
634  }
635 
636 #pragma omp barrier
637 
638  for (int site = is; site < ns; ++site) {
639  int ix = site % m_Nx2;
640  int iy = (site / m_Nx2) % m_Ny;
641  int izt = site / (m_Nx2 * m_Ny);
642  int ixzt = ix + m_Nx2 * izt;
643  if (iy == m_Ny - 1) {
644  for (int in = 0; in < m_Nin; ++in) {
645  int iv = index_alt.idxh(in, m_Nin, site, ex);
646  vp[iv] = buf2[in + m_Nin * ixzt];
647  }
648  }
649  }
650 #pragma omp master
651  {
652  chsend_dn[1].wait();
653  }
654  } // if(do_comm[1] == 1)
655 
656 #pragma omp barrier
657 }
658 
659 
660 //====================================================================
661 template<typename AFIELD>
663  const int ieo)
664 {
665  real_t bc2 = 1.0;
666  if (Communicator::ipe(1) == 0) bc2 = real_t(m_boundary[1]);
667 
668  int ex = 0;
669 
670  real_t *buf1 = (real_t *)chsend_up[1].ptr();
671  real_t *buf2 = (real_t *)chrecv_dn[1].ptr();
672 
674 
675  int ith, nth, is, ns;
676  set_threadtask(ith, nth, is, ns, m_Nvol2);
677 
678 #pragma omp barrier
679 
680  if (do_comm[1] == 1) {
681 #pragma omp master
682  {
683  chrecv_dn[1].start();
684  }
685  for (int site = is; site < ns; ++site) {
686  int ix = site % m_Nx2;
687  int iy = (site / m_Nx2) % m_Ny;
688  int izt = site / (m_Nx2 * m_Ny);
689  if (iy == m_Ny - 1) {
690  for (int in = 0; in < m_Nin; ++in) {
691  int iw = index_alt.idxh(in, m_Nin, site, ex);
692  int ixzt = ix + m_Nx2 * izt;
693  buf1[in + m_Nin * ixzt] = wp[iw];
694  }
695  }
696  }
697 
698 #pragma omp barrier
699 
700 #pragma omp master
701  {
702  chsend_up[1].start();
703  }
704  } // if(do_comm[1] == 1)
705 
706  for (int site = is; site < ns; ++site) {
707  int ix = site % m_Nx2;
708  int iy = (site / m_Nx2) % m_Ny;
709  int izt = site / (m_Nx2 * m_Ny);
710  if ((iy > 0) || (do_comm[1] == 0)) {
711  int iy2 = (iy - 1 + m_Ny) % m_Ny;
712  int nei = ix + m_Nx2 * (iy2 + m_Ny * izt);
713  real_t bc3 = 1.0;
714  if (iy == 0) bc3 = bc2;
715  for (int in = 0; in < m_Nin; ++in) {
716  int iv = index_alt.idxh(in, m_Nin, site, ex);
717  int iw = index_alt.idxh(in, m_Nin, nei, ex);
718  vp[iv] = bc3 * wp[iw];
719  }
720  }
721  }
722 
723  if (do_comm[1] == 1) {
724 #pragma omp master
725  {
726  chrecv_dn[1].wait();
727  }
728 
729 #pragma omp barrier
730 
731  for (int site = is; site < ns; ++site) {
732  int ix = site % m_Nx2;
733  int iy = (site / m_Nx2) % m_Ny;
734  int izt = site / (m_Nx2 * m_Ny);
735  int ixzt = ix + m_Nx2 * izt;
736  if (iy == 0) {
737  for (int in = 0; in < m_Nin; ++in) {
738  int iv = index_alt.idxh(in, m_Nin, site, ex);
739  vp[iv] = bc2 * buf2[in + m_Nin * ixzt];
740  }
741  }
742  }
743 
744 #pragma omp master
745  {
746  chsend_up[1].wait();
747  }
748  } // if(do_comm[1] == 1)
749 
750 #pragma omp barrier
751 }
752 
753 
754 //====================================================================
755 template<typename AFIELD>
757  const int ieo)
758 {
759  real_t bc2 = 1.0;
760  if (Communicator::ipe(2) == 0) bc2 = real_t(m_boundary[2]);
761 
762  int ex = 0;
763 
764  real_t *buf1 = (real_t *)chsend_dn[2].ptr();
765  real_t *buf2 = (real_t *)chrecv_up[2].ptr();
766 
768 
769  int ith, nth, is, ns;
770  set_threadtask(ith, nth, is, ns, m_Nvol2);
771 
772  int Nxy = m_Nx2 * m_Ny;
773 
774 #pragma omp barrier
775 
776  if (do_comm[2] == 1) {
777 #pragma omp master
778  {
779  chrecv_up[2].start();
780  }
781  for (int site = is; site < ns; ++site) {
782  int ixy = site % Nxy;
783  int iz = (site / Nxy) % m_Nz;
784  int it = site / (Nxy * m_Nz);
785  if (iz == 0) {
786  for (int in = 0; in < m_Nin; ++in) {
787  int iw = index_alt.idxh(in, m_Nin, site, ex);
788  int ixyt = ixy + Nxy * it;
789  buf1[in + m_Nin * ixyt] = bc2 * wp[iw];
790  }
791  }
792  }
793 
794 #pragma omp barrier
795 
796 #pragma omp master
797  {
798  chsend_dn[2].start();
799  }
800  } // if(do_comm[2] == 1)
801 
802  for (int site = is; site < ns; ++site) {
803  int ixy = site % Nxy;
804  int iz = (site / Nxy) % m_Nz;
805  int it = site / (Nxy * m_Nz);
806  if ((iz < m_Nz - 1) || (do_comm[2] == 0)) {
807  int iz2 = (iz + 1) % m_Nz;
808  int nei = ixy + Nxy * (iz2 + m_Nz * it);
809  real_t bc3 = 1.0;
810  if (iz == m_Nz - 1) bc3 = bc2;
811  for (int in = 0; in < m_Nin; ++in) {
812  int iv = index_alt.idxh(in, m_Nin, site, ex);
813  int iw = index_alt.idxh(in, m_Nin, nei, ex);
814  vp[iv] = bc3 * wp[iw];
815  }
816  }
817  }
818 
819  if (do_comm[2] == 1) {
820 #pragma omp master
821  {
822  chrecv_up[2].wait();
823  }
824 
825 #pragma omp barrier
826 
827  for (int site = is; site < ns; ++site) {
828  int ixy = site % Nxy;
829  int iz = (site / Nxy) % m_Nz;
830  int it = site / (Nxy * m_Nz);
831  if (iz == m_Nz - 1) {
832  for (int in = 0; in < m_Nin; ++in) {
833  int iv = index_alt.idxh(in, m_Nin, site, ex);
834  int ixyt = ixy + Nxy * it;
835  vp[iv] = buf2[in + m_Nin * ixyt];
836  }
837  }
838  }
839 #pragma omp master
840  {
841  chsend_dn[2].wait();
842  }
843  } // if(do_comm[2] == 1)
844 
845 #pragma omp barrier
846 }
847 
848 
849 //====================================================================
850 template<typename AFIELD>
852  const int ieo)
853 {
854  real_t bc2 = 1.0;
855  if (Communicator::ipe(2) == 0) bc2 = real_t(m_boundary[2]);
856 
857 
858 
859  int ex = 0;
860 
861  real_t *buf1 = (real_t *)chsend_up[2].ptr();
862  real_t *buf2 = (real_t *)chrecv_dn[2].ptr();
863 
865 
866  int ith, nth, is, ns;
867  set_threadtask(ith, nth, is, ns, m_Nvol2);
868 
869  int Nxy = m_Nx2 * m_Ny;
870 
871 #pragma omp barrier
872 
873  if (do_comm[2] == 1) {
874 #pragma omp master
875  {
876  chrecv_dn[2].start();
877  }
878 
879  for (int site = is; site < ns; ++site) {
880  int ixy = site % Nxy;
881  int iz = (site / Nxy) % m_Nz;
882  int it = site / (Nxy * m_Nz);
883  if (iz == m_Nz - 1) {
884  for (int in = 0; in < m_Nin; ++in) {
885  int iw = index_alt.idxh(in, m_Nin, site, ex);
886  int ixyt = ixy + Nxy * it;
887  buf1[in + m_Nin * ixyt] = wp[iw];
888  }
889  }
890  }
891 
892 #pragma omp barrier
893 
894 #pragma omp master
895  {
896  chsend_up[2].start();
897  }
898  } // if(do_comm[2] == 1)
899 
900  for (int site = is; site < ns; ++site) {
901  int ixy = site % Nxy;
902  int iz = (site / Nxy) % m_Nz;
903  int it = site / (Nxy * m_Nz);
904  if ((iz > 0) || (do_comm[2] == 0)) {
905  int iz2 = (iz - 1 + m_Nz) % m_Nz;
906  int nei = ixy + Nxy * (iz2 + m_Nz * it);
907  real_t bc3 = 1.0;
908  if (iz == 0) bc3 = bc2;
909  for (int in = 0; in < m_Nin; ++in) {
910  int iv = index_alt.idxh(in, m_Nin, site, ex);
911  int iw = index_alt.idxh(in, m_Nin, nei, ex);
912  vp[iv] = bc3 * wp[iw];
913  }
914  }
915  }
916 
917  if (do_comm[2] == 1) {
918 #pragma omp master
919  {
920  chrecv_dn[2].wait();
921  }
922 
923 #pragma omp barrier
924 
925  for (int site = is; site < ns; ++site) {
926  int ixy = site % Nxy;
927  int iz = (site / Nxy) % m_Nz;
928  int it = site / (Nxy * m_Nz);
929  if (iz == 0) {
930  for (int in = 0; in < m_Nin; ++in) {
931  int iv = index_alt.idxh(in, m_Nin, site, ex);
932  int ixyt = ixy + Nxy * it;
933  vp[iv] = bc2 * buf2[in + m_Nin * ixyt];
934  }
935  }
936  }
937 
938 #pragma omp master
939  {
940  chsend_up[2].wait();
941  }
942  } // if(do_comm[2] == 1)
943 
944 #pragma omp barrier
945 }
946 
947 
948 //====================================================================
949 template<typename AFIELD>
951  const int ieo)
952 {
953  real_t bc2 = 1.0;
954  if (Communicator::ipe(3) == 0) bc2 = real_t(m_boundary[3]);
955 
956  int ex = 0;
957 
958  real_t *buf1 = (real_t *)chsend_dn[3].ptr();
959  real_t *buf2 = (real_t *)chrecv_up[3].ptr();
960 
962 
963  int ith, nth, is, ns;
964  set_threadtask(ith, nth, is, ns, m_Nvol2);
965 
966  int Nxyz = m_Nx2 * m_Ny * m_Nz;
967 
968 #pragma omp barrier
969 
970  if (do_comm[3] == 1) {
971 #pragma omp master
972  {
973  chrecv_up[3].start();
974  }
975  for (int site = is; site < ns; ++site) {
976  int ixyz = site % Nxyz;
977  int it = site / Nxyz;
978  if (it == 0) {
979  for (int in = 0; in < m_Nin; ++in) {
980  int iw = index_alt.idxh(in, m_Nin, site, ex);
981  buf1[in + m_Nin * ixyz] = bc2 * wp[iw];
982  }
983  }
984  }
985 
986 #pragma omp barrier
987 
988 #pragma omp master
989  {
990  chsend_dn[3].start();
991  }
992  } // if(do_comm[3] == 1)
993 
994 
995  for (int site = is; site < ns; ++site) {
996  int ixyz = site % Nxyz;
997  int it = site / Nxyz;
998  if ((it < m_Nt - 1) || (do_comm[3] == 0)) {
999  int it2 = (it + 1) % m_Nt;
1000  int nei = ixyz + Nxyz * it2;
1001  real_t bc3 = 1.0;
1002  if (it == m_Nt - 1) bc3 = bc2;
1003  for (int in = 0; in < m_Nin; ++in) {
1004  int iv = index_alt.idxh(in, m_Nin, site, ex);
1005  int iw = index_alt.idxh(in, m_Nin, nei, ex);
1006  vp[iv] = bc3 * wp[iw];
1007  }
1008  }
1009  }
1010 
1011  if (do_comm[3] == 1) {
1012 #pragma omp master
1013  {
1014  chrecv_up[3].wait();
1015  }
1016 
1017 #pragma omp barrier
1018 
1019  for (int site = is; site < ns; ++site) {
1020  int ixyz = site % Nxyz;
1021  int it = site / Nxyz;
1022  if (it == m_Nt - 1) {
1023  for (int in = 0; in < m_Nin; ++in) {
1024  int iv = index_alt.idxh(in, m_Nin, site, ex);
1025  vp[iv] = buf2[in + m_Nin * ixyz];
1026  }
1027  }
1028  }
1029 #pragma omp master
1030  {
1031  chsend_dn[3].wait();
1032  }
1033  } // if(do_comm[3] == 1)
1034 
1035 #pragma omp barrier
1036 }
1037 
1038 
1039 //====================================================================
1040 template<typename AFIELD>
1042  const int ieo)
1043 {
1044  real_t bc2 = 1.0;
1045  if (Communicator::ipe(3) == 0) bc2 = real_t(m_boundary[3]);
1046 
1047  int ex = 0;
1048 
1049  real_t *buf1 = (real_t *)chsend_up[3].ptr();
1050  real_t *buf2 = (real_t *)chrecv_dn[3].ptr();
1051 
1053 
1054  int ith, nth, is, ns;
1055  set_threadtask(ith, nth, is, ns, m_Nvol2);
1056 
1057  int Nxyz = m_Nx2 * m_Ny * m_Nz;
1058 
1059 #pragma omp barrier
1060 
1061  if (do_comm[3] == 1) {
1062 #pragma omp master
1063  {
1064  chrecv_dn[3].start();
1065  }
1066  for (int site = is; site < ns; ++site) {
1067  int ixyz = site % Nxyz;
1068  int it = site / Nxyz;
1069  if (it == m_Nt - 1) {
1070  for (int in = 0; in < m_Nin; ++in) {
1071  int iw = index_alt.idxh(in, m_Nin, site, ex);
1072  buf1[in + m_Nin * ixyz] = wp[iw];
1073  }
1074  }
1075  }
1076 
1077 #pragma omp barrier
1078 
1079 #pragma omp master
1080  {
1081  chsend_up[3].start();
1082  }
1083  } // if(do_comm[3] == 1)
1084 
1085  for (int site = is; site < ns; ++site) {
1086  int ixyz = site % Nxyz;
1087  int it = site / Nxyz;
1088  if ((it > 0) || (do_comm[3] == 0)) {
1089  int it2 = (it - 1 + m_Nt) % m_Nt;
1090  int nei = ixyz + Nxyz * it2;
1091  real_t bc3 = 1.0;
1092  if (it == 0) bc3 = bc2;
1093  for (int in = 0; in < m_Nin; ++in) {
1094  int iv = index_alt.idxh(in, m_Nin, site, ex);
1095  int iw = index_alt.idxh(in, m_Nin, nei, ex);
1096  vp[iv] = bc3 * wp[iw];
1097  }
1098  }
1099  }
1100 
1101  if (do_comm[3] == 1) {
1102 #pragma omp master
1103  {
1104  chrecv_dn[3].wait();
1105  }
1106 
1107 #pragma omp barrier
1108 
1109  for (int site = is; site < ns; ++site) {
1110  int ixyz = site % Nxyz;
1111  int it = site / Nxyz;
1112  if (it == 0) {
1113  for (int in = 0; in < m_Nin; ++in) {
1114  int iv = index_alt.idxh(in, m_Nin, site, ex);
1115  vp[iv] = bc2 * buf2[in + m_Nin * ixyz];
1116  }
1117  }
1118  }
1119 
1120 #pragma omp master
1121  {
1122  chsend_up[3].wait();
1123  }
1124  } // if(do_comm[3] == 1)
1125 
1126 #pragma omp barrier
1127 }
1128 
1129 
1130 //============================================================END=====
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
ShiftAField_eo::dn_zh_nv
void dn_zh_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:851
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
ShiftAField_eo::dn_xh_naive
void dn_xh_naive(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:484
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
ShiftAField_eo::dn_th_nv
void dn_th_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:1041
ShiftAField_eo::dn_xh_simd
void dn_xh_simd(real_t *, real_t *, const int)
VLEN
#define VLEN
Definition: bridgeQXS_Clover_coarse_double.cpp:12
Field::nex
int nex() const
Definition: field.h:128
Field::check_size
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
Definition: field.h:135
Vsimd_t
Definition: vsimd_double-inc.h:13
ShiftAField_eo::setup_channels
void setup_channels()
setup channels for communication.
Definition: shiftAField_eo-tmpl.h:102
ShiftAField_eo::up_yh_nv
void up_yh_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:570
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
ShiftAField_eo::up_xh_naive
void up_xh_naive(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:335
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
ShiftAField_eo::tidyup
void tidyup()
Definition: shiftAField_eo-tmpl.h:95
ShiftAField_eo::up_xh_simd
void up_xh_simd(real_t *, real_t *, const int)
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
Communicator::npe
static int npe(const int dir)
logical grid extent
Definition: communicator.cpp:112
ShiftAField_eo< Field >::real_t
Field ::real_t real_t
Definition: shiftAField_eo.h:34
ShiftAField_eo::backward
void backward(AFIELD &, const AFIELD &, const int mu, const int ieo)
Definition: shiftAField_eo-tmpl.h:135
ShiftAField_eo::up_th_nv
void up_th_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:950
VLENY
#define VLENY
Definition: bridgeQXS_Clover_coarse_double.cpp:14
ShiftAField_eo::init
void init(int Nin)
Definition: shiftAField_eo-tmpl.h:16
Field::ptr
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
VLENX
#define VLENX
Definition: bridgeQXS_Clover_coarse_double.cpp:13
Communicator::ipe
static int ipe(const int dir)
logical coordinate of current proc.
Definition: communicator.cpp:105
ShiftAField_eo::up_zh_nv
void up_zh_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:756
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
ShiftAField_eo::forward
void forward(AFIELD &, const AFIELD &, const int mu, const int ieo)
Definition: shiftAField_eo-tmpl.h:203
Field
Container of Field-type object.
Definition: field.h:46
ShiftAField_eo
Methods to shift a field in the even-odd site index.
Definition: shiftAField_eo.h:32
ShiftAField_eo::dn_yh_nv
void dn_yh_nv(real_t *, real_t *, const int)
Definition: shiftAField_eo-tmpl.h:662
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AIndex_eo< real_t, AFIELD::IMPL >