QUDA  v1.1.0
A library for QCD on GPUs
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 
8 
10 
12 
14  {
15  if (&dirac != this) { DiracDomainWall::operator=(dirac); }
16 
17  return *this;
18  }
19 
20 // Modification for the 4D preconditioned domain wall operator
22  {
23  checkDWF(in, out);
24  checkParitySpinor(in, out);
25  checkSpinorAlias(in, out);
26 
27  ApplyDomainWall4D(out, in, *gauge, 0.0, 0.0, nullptr, nullptr, in, parity, dagger, commDim, profile);
28  flops += 1320LL*(long long)in.Volume();
29  }
30 
32  {
33  checkDWF(in, out);
34  checkParitySpinor(in, out);
35  checkSpinorAlias(in, out);
36 
37  ApplyDslash5(out, in, in, mass, 0.0, nullptr, nullptr, 0.0, dagger, DSLASH5_DWF);
38 
39  long long Ls = in.X(4);
40  long long bulk = (Ls-2)*(in.Volume()/Ls);
41  long long wall = 2*in.Volume()/Ls;
42  flops += 96LL*bulk + 120LL*wall;
43  }
44 
45  // Modification for the 4D preconditioned domain wall operator
47  const ColorSpinorField &x, const double &k) const
48  {
49  checkDWF(in, out);
50  checkParitySpinor(in, out);
51  checkSpinorAlias(in, out);
52 
53  ApplyDomainWall4D(out, in, *gauge, k, 0.0, nullptr, nullptr, x, parity, dagger, commDim, profile);
54 
55  flops += (1320LL+48LL)*(long long)in.Volume();
56  }
57 
59  const ColorSpinorField &x, const double &k) const
60  {
61  checkDWF(out, in);
62  checkParitySpinor(in, out);
63  checkSpinorAlias(in, out);
64 
65  ApplyDslash5(out, in, x, mass, 0.0, nullptr, nullptr, k, dagger, DSLASH5_DWF);
66 
67  long long Ls = in.X(4);
68  long long bulk = (Ls-2)*(in.Volume()/Ls);
69  long long wall = 2*in.Volume()/Ls;
70  flops += (48LL)*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
71  }
72 
74  {
75  checkFullSpinor(out, in);
76 
77  ApplyDomainWall4D(out, in, *gauge, 0.0, 0.0, nullptr, nullptr, in, QUDA_INVALID_PARITY, dagger, commDim, profile);
78  flops += 1320LL * (long long)in.Volume();
79  ApplyDslash5(out, in, out, mass, 0.0, nullptr, nullptr, 1.0, dagger, DSLASH5_DWF);
80  long long Ls = in.X(4);
81  long long bulk = (Ls - 2) * (in.Volume() / Ls);
82  long long wall = 2 * in.Volume() / Ls;
83  flops += (48LL) * (long long)in.Volume() + 96LL * bulk + 120LL * wall;
84 
85  blas::xpay(const_cast<ColorSpinorField &>(in), -kappa5, out);
86  }
87 
89  {
90  checkFullSpinor(out, in);
91 
92  bool reset = newTmp(&tmp1, in);
93 
94  M(*tmp1, in);
95  Mdag(out, *tmp1);
96 
97  deleteTmp(&tmp1, reset);
98  }
99 
101  ColorSpinorField &b, const QudaSolutionType solType) const
102  {
103  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
104  errorQuda("Preconditioned solution requires a preconditioned solve_type");
105  }
106 
107  src = &b;
108  sol = &x;
109  }
110 
112  {
113  // do nothing
114  }
115 
116  // Modification for the 4D preconditioned domain wall operator
118 
120 
122 
124  {
125  if (&dirac != this) { DiracDomainWall4D::operator=(dirac); }
126 
127  return *this;
128  }
129 
130  // I think this is misnamed and should be M5inv
132  ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const double &k) const
133  {
134  checkDWF(in, out);
135  checkParitySpinor(in, out);
136  checkSpinorAlias(in, out);
137 
138  ApplyDslash5(out, in, in, mass, m5, nullptr, nullptr, 0.0, dagger, M5_INV_DWF);
139 
140  long long Ls = in.X(4);
141  flops += 144LL * (long long)in.Volume() * Ls + 3LL * Ls * (Ls - 1LL);
142  }
143 
145  const QudaParity parity, const double &a,
146  const ColorSpinorField &x, const double &b) const
147  {
148  checkDWF(out, in);
149  checkParitySpinor(in, out);
150  checkSpinorAlias(in, out);
151 
152  ApplyDslash5(out, in, x, mass, m5, nullptr, nullptr, b, dagger, M5_INV_DWF);
153 
154  long long Ls = in.X(4);
155  flops += (144LL*Ls + 48LL)*(long long)in.Volume() + 3LL*Ls*(Ls-1LL);
156  }
157 
158  // Apply the 4D even-odd preconditioned domain-wall Dirac operator
160  {
161  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
162  double kappa2 = kappa5*kappa5;
163 
164  bool reset1 = newTmp(&tmp1, in);
165 
166  int odd_bit = (matpcType == QUDA_MATPC_ODD_ODD || matpcType == QUDA_MATPC_ODD_ODD_ASYMMETRIC) ? 1 : 0;
167  bool symmetric =(matpcType == QUDA_MATPC_EVEN_EVEN || matpcType == QUDA_MATPC_ODD_ODD) ? true : false;
168  QudaParity parity[2] = {static_cast<QudaParity>((1 + odd_bit) % 2), static_cast<QudaParity>((0 + odd_bit) % 2)};
169 
170  if (symmetric && !dagger) {
171  // 1 - k^2 M5^-1 D4 M5^-1 D4
172  Dslash4(*tmp1, in, parity[0]);
173  Dslash5inv(out, *tmp1, parity[0], kappa5);
174  Dslash4(*tmp1, out, parity[1]);
175  Dslash5invXpay(out, *tmp1, parity[1], kappa5, in, -kappa2);
176  } else if (symmetric && dagger) {
177  // 1 - k^2 D4 M5^-1 D4 M5^-1
178  Dslash5inv(*tmp1, in, parity[1], kappa5);
179  Dslash4(out, *tmp1, parity[0]);
180  Dslash5inv(*tmp1, out, parity[0], kappa5);
181  Dslash4Xpay(out, *tmp1, parity[1], in, -kappa2);
182  } else {
183  // 1 - k D5 - k^2 D4 M5^-1 D4_oe
184  Dslash4(*tmp1, in, parity[0]);
185  Dslash5inv(out, *tmp1, parity[0], kappa5);
186  Dslash4Xpay(*tmp1, out, parity[1], in, -kappa2);
187  Dslash5Xpay(out, in, parity[1], *tmp1, -kappa5);
188  }
189 
190  deleteTmp(&tmp1, reset1);
191  }
192 
194  {
195  bool reset = newTmp(&tmp2, in);
196  M(*tmp2, in);
197  Mdag(out, *tmp2);
198  deleteTmp(&tmp2, reset);
199  }
200 
203  const QudaSolutionType solType) const
204  {
205  // we desire solution to preconditioned system
206  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
207  src = &b;
208  sol = &x;
209  } else { // we desire solution to full system
210  bool reset = newTmp(&tmp1, b.Even());
211 
213  // src = M5^-1 (b_e + k D4_eo*M5^-1 b_o)
214  src = &(x.Odd());
215  Dslash5inv(*src, b.Odd(), QUDA_ODD_PARITY, kappa5);
218  sol = &(x.Even());
219  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
220  // src = M5^-1 (b_o + k D4_oe*M5^-1 b_e)
221  src = &(x.Even());
222  Dslash5inv(*src, b.Even(), QUDA_EVEN_PARITY, kappa5);
223  Dslash4Xpay(*tmp1, *src, QUDA_ODD_PARITY, b.Odd(), kappa5);
225  sol = &(x.Odd());
227  // src = b_e + k D4_eo*M5^-1 b_o
228  src = &(x.Odd());
231  sol = &(x.Even());
233  // src = b_o + k D4_oe*M5^-1 b_e
234  src = &(x.Even());
236  Dslash4Xpay(*src, *tmp1, QUDA_ODD_PARITY, b.Odd(), kappa5);
237  sol = &(x.Odd());
238  } else {
239  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
240  }
241  // here we use final solution to store parity solution and parity source
242  // b is now up for grabs if we want
243 
244  deleteTmp(&tmp1, reset);
245  }
246  }
247 
249  const QudaSolutionType solType) const
250  {
251  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
252  return;
253  }
254 
255  checkFullSpinor(x, b);
256 
257  bool reset1 = newTmp(&tmp1, b.Even());
258 
259  // create full solution
260 
263  // x_o = M5^-1 (b_o + k D4_oe x_e)
266  } else if (matpcType == QUDA_MATPC_ODD_ODD ||
268  // x_e = M5^-1 (b_e + k D4_eo x_o)
271  } else {
272  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
273  }
274 
275  deleteTmp(&tmp1, reset1);
276  }
277 
278 } // end namespace quda
const ColorSpinorField & Odd() const
const ColorSpinorField & Even() const
const int * X() const
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
Apply MdagM operator which may be optimized.
void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
DiracDomainWall4D(const DiracParam &param)
DiracDomainWall4D & operator=(const DiracDomainWall4D &dirac)
void Dslash4Xpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
void Dslash5(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
void Dslash4(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
Apply the local MdagM operator: equivalent to applying zero Dirichlet boundary condition to MdagM on ...
void Dslash5Xpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
DiracDomainWall4DPC & operator=(const DiracDomainWall4DPC &dirac)
void Dslash5invXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const double &kappa5, const ColorSpinorField &x, const double &k) const
DiracDomainWall4DPC(const DiracParam &param)
void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
Apply MdagM operator which may be optimized.
void Dslash5inv(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const double &kappa5) const
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
DiracDomainWall & operator=(const DiracDomainWall &dirac)
void checkDWF(const ColorSpinorField &out, const ColorSpinorField &in) const
unsigned long long flops
Definition: dirac_quda.h:150
bool newTmp(ColorSpinorField **, const ColorSpinorField &) const
Definition: dirac.cpp:72
QudaMatPCType matpcType
Definition: dirac_quda.h:148
cudaGaugeField * gauge
Definition: dirac_quda.h:144
double mass
Definition: dirac_quda.h:146
void deleteTmp(ColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:83
virtual void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const
Check parity spinors are usable (check geometry ?)
Definition: dirac.cpp:108
ColorSpinorField * tmp1
Definition: dirac_quda.h:151
TimeProfile profile
Definition: dirac_quda.h:161
QudaDagType dagger
Definition: dirac_quda.h:149
void checkSpinorAlias(const ColorSpinorField &, const ColorSpinorField &) const
check spinors do not alias
Definition: dirac.cpp:146
virtual void checkFullSpinor(const ColorSpinorField &, const ColorSpinorField &) const
check full spinors are compatible (check geometry ?)
Definition: dirac.cpp:138
ColorSpinorField * tmp2
Definition: dirac_quda.h:152
int commDim[QUDA_MAX_DIM]
Definition: dirac_quda.h:159
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const
Apply Mdag (daggered operator of M.
Definition: dirac.cpp:92
GaugeCovDev * dirac
Definition: covdev_test.cpp:42
QudaParity parity
Definition: covdev_test.cpp:40
@ QUDA_EVEN_PARITY
Definition: enum_quda.h:284
@ QUDA_ODD_PARITY
Definition: enum_quda.h:284
@ QUDA_INVALID_PARITY
Definition: enum_quda.h:284
enum QudaSolutionType_s QudaSolutionType
@ QUDA_MATPC_ODD_ODD_ASYMMETRIC
Definition: enum_quda.h:219
@ QUDA_MATPC_EVEN_EVEN_ASYMMETRIC
Definition: enum_quda.h:218
@ QUDA_MATPC_ODD_ODD
Definition: enum_quda.h:217
@ QUDA_MATPC_EVEN_EVEN
Definition: enum_quda.h:216
@ QUDA_MATPC_SOLUTION
Definition: enum_quda.h:159
@ QUDA_MATPCDAG_MATPC_SOLUTION
Definition: enum_quda.h:161
enum QudaParity_s QudaParity
void xpay(ColorSpinorField &x, double a, ColorSpinorField &y)
Definition: blas_quda.h:45
void ApplyDomainWall4D(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, double a, double m_5, const Complex *b_5, const Complex *c_5, const ColorSpinorField &x, int parity, bool dagger, const int *comm_override, TimeProfile &profile)
Driver for applying the batched Wilson 4-d stencil to a 5-d vector with 4-d preconditioned data order...
@ DSLASH5_DWF
Definition: dslash_quda.h:558
@ M5_INV_DWF
Definition: dslash_quda.h:561
void ApplyDslash5(ColorSpinorField &out, const ColorSpinorField &in, const ColorSpinorField &x, double m_f, double m_5, const Complex *b_5, const Complex *c_5, double a, bool dagger, Dslash5Type type)
Apply either the domain-wall / mobius Dslash5 operator or the M5 inverse operator....
QudaGaugeParam param
Definition: pack_test.cpp:18
#define errorQuda(...)
Definition: util_quda.h:120