QUDA  0.9.0
dirac_domain_wall_4d.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  // Modification for the 4D preconditioned domain wall operator
10 
13 
15 
17  {
18  if (&dirac != this) {
20  }
21 
22  return *this;
23  }
24 
25 // Modification for the 4D preconditioned domain wall operator
27  const QudaParity parity) const
28  {
29  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
32 
33  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
34  &static_cast<const cudaColorSpinorField&>(in),
35  parity, dagger, 0, mass, 0, 0, commDim, 0, profile);
36 
37  flops += 1320LL*(long long)in.Volume();
38  }
39 
41  const QudaParity parity) const
42  {
43  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
46 
47  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
48  &static_cast<const cudaColorSpinorField&>(in),
49  parity, dagger, 0, mass, 0, 0, commDim, 1, profile);
50 
51  long long Ls = in.X(4);
52  long long bulk = (Ls-2)*(in.Volume()/Ls);
53  long long wall = 2*in.Volume()/Ls;
54  flops += 96LL*bulk + 120LL*wall;
55  }
56 
57  // I think this is misnamed and should be M5inv
59  const QudaParity parity, const double &k) const
60  {
61  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
62 
65 
66  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
67  &static_cast<const cudaColorSpinorField&>(in),
68  parity, dagger, 0, mass, k, 0, commDim, 2, profile);
69 
70 
71  long long Ls = in.X(4);
72  flops += 144LL*(long long)in.Volume()*Ls + 3LL*Ls*(Ls-1LL);
73  }
74 
75  // Modification for the 4D preconditioned domain wall operator
77  const QudaParity parity, const ColorSpinorField &x,
78  const double &k) const
79  {
80  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
81 
84 
85  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
86  &static_cast<const cudaColorSpinorField&>(in),
87  parity, dagger, &static_cast<const cudaColorSpinorField&>(x),
88  mass, k, 0, commDim, 0, profile);
89 
90  flops += (1320LL+48LL)*(long long)in.Volume();
91  }
92 
94  const QudaParity parity, const ColorSpinorField &x,
95  const double &k) const
96  {
97  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
100 
101  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
102  &static_cast<const cudaColorSpinorField&>(in),
103  parity, dagger, &static_cast<const cudaColorSpinorField&>(x),
104  mass, k, 0, commDim, 1, profile);
105 
106  long long Ls = in.X(4);
107  long long bulk = (Ls-2)*(in.Volume()/Ls);
108  long long wall = 2*in.Volume()/Ls;
109  flops += (48LL)*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
110  }
111 
113  const QudaParity parity, const double &a,
114  const ColorSpinorField &x, const double &b) const
115  {
116  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
117 
120 
121  domainWallDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
122  &static_cast<const cudaColorSpinorField&>(in),
123  parity, dagger, &static_cast<const cudaColorSpinorField&>(x),
124  mass, a, b, commDim, 2, profile);
125 
126  long long Ls = in.X(4);
127  flops += (144LL*Ls + 48LL)*(long long)in.Volume() + 3LL*Ls*(Ls-1LL);
128  }
129 
130  // Apply the 4D even-odd preconditioned domain-wall Dirac operator
132  {
133  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
134  double kappa2 = kappa5*kappa5;
135 
136  bool reset1 = newTmp(&tmp1, in);
137 
138  int odd_bit = (matpcType == QUDA_MATPC_ODD_ODD || matpcType == QUDA_MATPC_ODD_ODD_ASYMMETRIC) ? 1 : 0;
139  bool symmetric =(matpcType == QUDA_MATPC_EVEN_EVEN || matpcType == QUDA_MATPC_ODD_ODD) ? true : false;
140  QudaParity parity[2] = {static_cast<QudaParity>((1 + odd_bit) % 2), static_cast<QudaParity>((0 + odd_bit) % 2)};
141 
142  if (symmetric && !dagger) {
143  // 1 - k^2 M5^-1 D4 M5^-1 D4
144  Dslash4(*tmp1, in, parity[0]);
145  Dslash5inv(out, *tmp1, parity[0], kappa5);
146  Dslash4(*tmp1, out, parity[1]);
147  Dslash5invXpay(out, *tmp1, parity[1], kappa5, in, -kappa2);
148  } else if (symmetric && dagger) {
149  // 1 - k^2 D4 M5^-1 D4 M5^-1
150  Dslash5inv(*tmp1, in, parity[1], kappa5);
151  Dslash4(out, *tmp1, parity[0]);
152  Dslash5inv(*tmp1, out, parity[0], kappa5);
153  Dslash4Xpay(out, *tmp1, parity[1], in, -kappa2);
154  } else {
155  // 1 - k D5 - k^2 D4 M5^-1 D4_oe
156  Dslash4(*tmp1, in, parity[0]);
157  Dslash5inv(out, *tmp1, parity[0], kappa5);
158  Dslash4Xpay(*tmp1, out, parity[1], in, -kappa2);
159  Dslash5Xpay(out, in, parity[1], *tmp1, -kappa5);
160  }
161 
162  deleteTmp(&tmp1, reset1);
163  }
164 
166  {
167  bool reset = newTmp(&tmp2, in);
168  M(*tmp2, in);
169  Mdag(out, *tmp2);
170  deleteTmp(&tmp2, reset);
171  }
172 
175  const QudaSolutionType solType) const
176  {
177  // we desire solution to preconditioned system
178  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
179  src = &b;
180  sol = &x;
181  } else { // we desire solution to full system
182  bool reset = newTmp(&tmp1, b.Even());
183 
185  // src = M5^-1 (b_e + k D4_eo*M5^-1 b_o)
186  src = &(x.Odd());
190  sol = &(x.Even());
191  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
192  // src = M5^-1 (b_o + k D4_oe*M5^-1 b_e)
193  src = &(x.Even());
194  Dslash5inv(*src, b.Even(), QUDA_EVEN_PARITY, kappa5);
197  sol = &(x.Odd());
199  // src = b_e + k D4_eo*M5^-1 b_o
200  src = &(x.Odd());
203  sol = &(x.Even());
205  // src = b_o + k D4_oe*M5^-1 b_e
206  src = &(x.Even());
209  sol = &(x.Odd());
210  } else {
211  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
212  }
213  // here we use final solution to store parity solution and parity source
214  // b is now up for grabs if we want
215 
216  deleteTmp(&tmp1, reset);
217  }
218  }
219 
221  const QudaSolutionType solType) const
222  {
223  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
224  return;
225  }
226 
227  checkFullSpinor(x, b);
228 
229  bool reset1 = newTmp(&tmp1, b.Even());
230 
231  // create full solution
232 
235  // x_o = M5^-1 (b_o + k D4_oe x_e)
236  Dslash4Xpay(*tmp1, x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa5);
238  } else if (matpcType == QUDA_MATPC_ODD_ODD ||
240  // x_e = M5^-1 (b_e + k D4_eo x_o)
241  Dslash4Xpay(*tmp1, x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa5);
243  } else {
244  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
245  }
246 
247  deleteTmp(&tmp1, reset1);
248  }
249 
250 } // end namespace quda
unsigned long long flops
Definition: dirac_quda.h:100
void Dslash5(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
DiracDomainWall4DPC & operator=(const DiracDomainWall4DPC &dirac)
const void * src
#define errorQuda(...)
Definition: util_quda.h:90
cudaGaugeField * gauge
Definition: dirac_quda.h:95
virtual void checkFullSpinor(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:129
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
void deleteTmp(ColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:64
TimeProfile profile
Definition: dirac_quda.h:112
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
QudaGaugeParam param
Definition: pack_test.cpp:17
bool newTmp(ColorSpinorField **, const ColorSpinorField &) const
Definition: dirac.cpp:53
#define b
int commDim[QUDA_MAX_DIM]
Definition: dirac_quda.h:110
void Dslash5inv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const double &kappa5) const
void Dslash5invXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const double &kappa5, const ColorSpinorField &x, const double &k) const
void checkSpinorAlias(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:137
DiracDomainWall4DPC(const DiracParam &param)
cpuColorSpinorField * in
double mass
Definition: dirac_quda.h:97
enum QudaSolutionType_s QudaSolutionType
void Dslash4Xpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
QudaDagType dagger
Definition: dirac_quda.h:99
enum QudaParity_s QudaParity
DiracDomainWallPC & operator=(const DiracDomainWallPC &dirac)
QudaMatPCType matpcType
Definition: dirac_quda.h:98
void Dslash4(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const
Definition: dirac.cpp:73
void Dslash5Xpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
GaugeCovDev * dirac
Definition: covdev_test.cpp:75
cpuColorSpinorField * out
void domainWallDslashCuda(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, TimeProfile &profile)
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
virtual void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:89
QudaParity parity
Definition: covdev_test.cpp:53
ColorSpinorField * tmp2
Definition: dirac_quda.h:102
void M(ColorSpinorField &out, const ColorSpinorField &in) const
#define a
ColorSpinorField * tmp1
Definition: dirac_quda.h:101