QUDA  v0.7.0
A library for QCD on GPUs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dirac_mobius.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <dirac_quda.h>
3 #include <blas_quda.h>
4 
5 namespace quda {
6 
7  namespace mobius {
8 #include <dslash_init.cuh>
9  }
10 
11 // Modification for the 4D preconditioned Mobius domain wall operator
13  : DiracDomainWallPC(param) {
14  memcpy(b_5, param.b_5, sizeof(double)*param.Ls);
15  memcpy(c_5, param.c_5, sizeof(double)*param.Ls);
16  mobius::initConstants(*param.gauge, profile);
17  }
18 
20  : DiracDomainWallPC(dirac) {
21  memcpy(b_5, dirac.b_5, Ls);
22  memcpy(c_5, dirac.c_5, Ls);
23  mobius::initConstants(dirac.gauge, profile);
24  }
25 
27  { }
28 
30  {
31  if (&dirac != this) {
33  }
34 
35  return *this;
36  }
37 
38 // Modification for the 4D preconditioned Mobius domain wall operator
40  const QudaParity parity) const
41  {
42  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
43  checkParitySpinor(in, out);
44  checkSpinorAlias(in, out);
45 
46  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
47 
48  MDWFDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, 0, commDim, 0, profile);
49 
50  flops += 1320LL*(long long)in.Volume();
51  }
52 
54  {
55  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
56  checkParitySpinor(in, out);
57  checkSpinorAlias(in, out);
58 
60  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
61 
62  MDWFDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, 0, commDim, 1, profile);
63 
64  long long Ls = in.X(4);
65  long long bulk = (Ls-2)*(in.Volume()/Ls);
66  long long wall = 2*in.Volume()/Ls;
67  flops += 72LL*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
68  }
69 
71  {
72  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
73  checkParitySpinor(in, out);
74  checkSpinorAlias(in, out);
75 
77  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
78 
79  MDWFDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, 0, commDim, 2, profile);
80 
81  long long Ls = in.X(4);
82  long long bulk = (Ls-2)*(in.Volume()/Ls);
83  long long wall = 2*in.Volume()/Ls;
84  flops += 48LL*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
85  }
86 
88  {
89  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
90 
91  checkParitySpinor(in, out);
92  checkSpinorAlias(in, out);
93 
95  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
96 
97  MDWFDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, k, commDim, 3, profile);
98 
99  long long Ls = in.X(4);
100  flops += 144LL*(long long)in.Volume()*Ls + 3LL*Ls*(Ls-1LL);
101  }
102 
103  // Modification for the 4D preconditioned Mobius domain wall operator
105  const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
106  {
107  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
108 
109  checkParitySpinor(in, out);
110  checkSpinorAlias(in, out);
111 
112  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
113 
114  MDWFDslashCuda(&out, gauge, &in, parity, dagger, &x, mass, k, commDim, 0, profile);
115 
116  flops += (1320LL+48LL)*(long long)in.Volume();
117  }
118 
120  const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
121  {
122  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
123  checkParitySpinor(in, out);
124  checkSpinorAlias(in, out);
125 
127  mobius::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
128 
129  MDWFDslashCuda(&out, gauge, &in, parity, dagger, &x, mass, k, commDim, 2, profile);
130 
131  long long Ls = in.X(4);
132  long long bulk = (Ls-2)*(in.Volume()/Ls);
133  long long wall = 2*in.Volume()/Ls;
134  flops += (96LL)*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
135  }
136 
137  // Apply the even-odd preconditioned mobius DWF operator
139  {
140  if(dagger == QUDA_DAG_NO)
141  {
142  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
143 
144  bool reset1 = newTmp(&tmp1, in);
145 
146  //QUDA_MATPC_EVEN_EVEN_ASYMMETRIC : M5 - kappa_b^2 * D4_{eo}D4pre_{oe}D5inv_{ee}D4_{eo}D4pre_{oe}
147  //QUDA_MATPC_ODD_ODD_ASYMMETRIC : M5 - kappa_b^2 * D4_{oe}D4pre_{eo}D5inv_{oo}D4_{oe}D4pre_{eo}
148  //Actually, Dslash5 will return M5 operation and M5 = 1 + 0.5*kappa_b/kappa_c * D5
151  Dslash4(out, *tmp1, QUDA_EVEN_PARITY);
152  Dslash5inv(*tmp1, out, QUDA_ODD_PARITY, kappa5); //kappa5 is dummy value
154  Dslash4(*tmp1, out, QUDA_ODD_PARITY);
155  Dslash5Xpay(out, in, QUDA_EVEN_PARITY, *tmp1, 1.0);
158  Dslash4(out, *tmp1, QUDA_ODD_PARITY);
159  Dslash5inv(*tmp1, out, QUDA_EVEN_PARITY, kappa5); //kappa5 is dummy value
161  Dslash4(*tmp1, out, QUDA_EVEN_PARITY);
162  Dslash5Xpay(out, in, QUDA_ODD_PARITY, *tmp1, 1.0);
163  } else {
164  errorQuda("MatPCType %d not valid for DiracMobiusDomainWallPC", matpcType);
165  }
166 
167  deleteTmp(&tmp1, reset1);
168  }
169  else
170  {
171  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
172 
173  bool reset1 = newTmp(&tmp1, in);
174 
175  //QUDA_MATPC_EVEN_EVEN : M5 - kappa_b^2 * D4_{eo}D4pre_{oe}D5inv_{ee}D4_{eo}D4pre_{oe}
176  //QUDA_MATPC_ODD_ODD : M5 - kappa_b^2 * D4_{oe}D4pre_{eo}D5inv_{oo}D4_{oe}D4pre_{eo}
177  //Actually, Dslash5 will return M5 operation and M5 = 1 + 0.5*kappa_b/kappa_c * D5
182  Dslash4(out, *tmp1, QUDA_ODD_PARITY);
184  //Dslash5Xpay(out, in, QUDA_EVEN_PARITY, *tmp1, 1.0);
185  Dslash5Xpay(out, in, QUDA_ODD_PARITY, *tmp1, 1.0);
190  Dslash4(out, *tmp1, QUDA_EVEN_PARITY);
192  //Dslash5Xpay(out, in, QUDA_ODD_PARITY, *tmp1, 1.0);
193  Dslash5Xpay(out, in, QUDA_EVEN_PARITY, *tmp1, 1.0);
194  } else {
195  errorQuda("MatPCType %d not valid for DiracMobiusDomainWallPC", matpcType);
196  }
197  deleteTmp(&tmp1, reset1);
198  }
199  }
200 
202  {
203  bool reset = newTmp(&tmp2, in);
204  M(*tmp2, in);
205  Mdag(out, *tmp2);
206  deleteTmp(&tmp2, reset);
207  }
208 
211  const QudaSolutionType solType) const
212  {
213  // prepare function in MDWF is not tested yet.
214  bool reset = newTmp(&tmp1, b);
215  // we desire solution to preconditioned system
216  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
217  src = &b;
218  sol = &x;
219  } else {
220  // we desire solution to full system
222  // src = b_e + k D4_eo*D5inv b_o
223  Dslash5inv(x.Odd(), b.Odd(), QUDA_ODD_PARITY, kappa5);//kappa5 is dummy
225  Dslash4Xpay(x.Odd(), *tmp1, QUDA_ODD_PARITY, b.Even(), 1.0);
226  src = &(x.Odd());
227  sol = &(x.Even());
229  // src = b_o + k D4_oe*D5inv b_e
230  Dslash5inv(x.Even(), b.Even(), QUDA_EVEN_PARITY, kappa5);//kappa5 is dummy
232  Dslash4Xpay(x.Even(), *tmp1, QUDA_EVEN_PARITY, b.Odd(), 1.0);
233  src = &(x.Even());
234  sol = &(x.Odd());
235  } else {
236  errorQuda("MatPCType %d not valid for DiracMobiusDomainWallPC", matpcType);
237  }
238  // here we use final solution to store parity solution and parity source
239  // b is now up for grabs if we want
240  }
241  deleteTmp(&tmp1, reset);
242  }
243 
245  const QudaSolutionType solType) const
246  {
247  // reconstruct function in MDWF is not tested yet.
248  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
249  return;
250  }
251 
252  bool reset1 = newTmp(&tmp1, x);
253 
254  // create full solution
255  checkFullSpinor(x, b);
257  // psi_e = M5inv in_e - k_b M5inv D4_eo psi_o
258  Dslash4pre(x.Even(), x.Odd(), QUDA_ODD_PARITY);
259  Dslash4Xpay(*tmp1, x.Even(), QUDA_ODD_PARITY, b.Even(), -1.0);
260  Dslash5inv(x.Even(), *tmp1, QUDA_ODD_PARITY, kappa5); //kappa5 is dummy
262  // psi_o = M5inv in_o - k_b M5inv D4_oe psi_e
263  Dslash4pre(x.Odd(), x.Even(), QUDA_EVEN_PARITY);
264  Dslash4Xpay(*tmp1, x.Odd(), QUDA_EVEN_PARITY, b.Odd(), -1.0);
265  Dslash5inv(x.Odd(), *tmp1, QUDA_EVEN_PARITY, kappa5); //kappa5 is dummy
266  } else {
267  errorQuda("MatPCType %d not valid for DiracMobiusDomainWallPC", matpcType);
268  }
269  deleteTmp(&tmp1, reset1);
270  }
271 
272 } // namespace quda
FaceBuffer face1
Definition: dirac_quda.h:148
cudaGaugeField & gauge
Definition: dirac_quda.h:88
virtual void checkParitySpinor(const cudaColorSpinorField &, const cudaColorSpinorField &) const
Definition: dirac.cpp:84
double c_5[QUDA_MAX_DWF_LS]
NEW: used by mobius domain wall only.
Definition: dirac_quda.h:27
unsigned long long flops
Definition: dirac_quda.h:93
void Dslash5inv(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const double &k) const
void initMDWFConstants(const double *b_5, const double *c_5, int dim_s, const double m5h, TimeProfile &profile)
const int * X() const
void MdagM(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
#define errorQuda(...)
Definition: util_quda.h:73
void M(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
bool newTmp(cudaColorSpinorField **, const cudaColorSpinorField &) const
Definition: dirac.cpp:51
double c_5[QUDA_MAX_DWF_LS]
Definition: dirac_quda.h:333
TimeProfile profile
Definition: dirac_quda.h:104
void prepare(cudaColorSpinorField *&src, cudaColorSpinorField *&sol, cudaColorSpinorField &x, cudaColorSpinorField &b, const QudaSolutionType) const
cudaGaugeField * gauge
Definition: dirac_quda.h:30
DiracMobiusDomainWallPC & operator=(const DiracMobiusDomainWallPC &dirac)
QudaGaugeParam param
Definition: pack_test.cpp:17
void checkSpinorAlias(const cudaColorSpinorField &, const cudaColorSpinorField &) const
Definition: dirac.cpp:129
cudaColorSpinorField & Odd() const
int commDim[QUDA_MAX_DIM]
Definition: dirac_quda.h:102
void Dslash4(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity) const
void Dslash5(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity) const
cpuColorSpinorField * in
void Dslash5Xpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
double mass
Definition: dirac_quda.h:90
enum QudaSolutionType_s QudaSolutionType
double b_5[QUDA_MAX_DWF_LS]
NEW: used by domain wall and twisted mass.
Definition: dirac_quda.h:26
void MDWFDslashCuda(cudaColorSpinorField *out, const cudaGaugeField &gauge, const cudaColorSpinorField *in, const int parity, const int dagger, const cudaColorSpinorField *x, const double &m_f, const double &k, const int *commDim, const int DS_type, TimeProfile &profile, const QudaDslashPolicy &dslashPolicy=QUDA_DSLASH2)
void deleteTmp(cudaColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:59
Dirac * dirac
Definition: dslash_test.cpp:45
QudaDagType dagger
Definition: dirac_quda.h:92
enum QudaParity_s QudaParity
DiracDomainWallPC & operator=(const DiracDomainWallPC &dirac)
int x[4]
QudaMatPCType matpcType
Definition: dirac_quda.h:91
DiracMobiusDomainWallPC(const DiracParam &param)
void Dslash4pre(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity) const
FaceBuffer face2
Definition: dirac_quda.h:148
cudaColorSpinorField * tmp2
Definition: dirac_quda.h:95
virtual void checkFullSpinor(const cudaColorSpinorField &, const cudaColorSpinorField &) const
Definition: dirac.cpp:121
cpuColorSpinorField * out
cudaColorSpinorField * tmp1
Definition: dirac_quda.h:94
void Dslash4Xpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
double b_5[QUDA_MAX_DWF_LS]
Definition: dirac_quda.h:332
void Mdag(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
Definition: dirac.cpp:68
const QudaParity parity
Definition: dslash_test.cpp:29
cudaColorSpinorField & Even() const
void reconstruct(cudaColorSpinorField &x, const cudaColorSpinorField &b, const QudaSolutionType) const