QUDA  v0.7.0
A library for QCD on GPUs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  namespace domainwall4d {
8 #include <dslash_init.cuh>
9  }
10 
11 // Modification for the 4D preconditioned domain wall operator
13  : DiracDomainWallPC(param)
14  {
15  domainwall4d::initConstants(*param.gauge, profile);
16  }
17 
19  : DiracDomainWallPC(dirac)
20  {
21  domainwall4d::initConstants(dirac.gauge, profile);
22  }
23 
25  {
26 
27  }
28 
30  {
31  if (&dirac != this) {
33  }
34 
35  return *this;
36  }
37 
38 // Modification for the 4D preconditioned 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  domainwall4d::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
47 
48  domainWallDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, 0, commDim, 0, profile);
49 
50  flops += 1320LL*(long long)in.Volume();
51  }
52 
54  const QudaParity parity) const
55  {
56  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
57  checkParitySpinor(in, out);
58  checkSpinorAlias(in, out);
59 
60  domainwall4d::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
61 
62  domainWallDslashCuda(&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 += 96LL*bulk + 120LL*wall;
68  }
69 
71  const QudaParity parity, const double &k) const
72  {
73  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
74 
75  checkParitySpinor(in, out);
76  checkSpinorAlias(in, out);
77 
78  domainwall4d::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
79 
80  domainWallDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, k, commDim, 2, profile);
81 
82  long long Ls = in.X(4);
83  flops += 144LL*(long long)in.Volume()*Ls + 3LL*Ls*(Ls-1LL);
84  }
85 
86  // Modification for the 4D preconditioned domain wall operator
89  const double &k) const
90  {
91  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
92 
93  checkParitySpinor(in, out);
94  checkSpinorAlias(in, out);
95 
96  domainwall4d::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
97 
98  domainWallDslashCuda(&out, gauge, &in, parity, dagger, &x, mass, k, commDim, 0, profile);
99 
100  flops += (1320LL+48LL)*(long long)in.Volume();
101  }
102 
104  const QudaParity parity, const cudaColorSpinorField &x,
105  const double &k) const
106  {
107  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
108  checkParitySpinor(in, out);
109  checkSpinorAlias(in, out);
110 
111  domainwall4d::setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda
112 
113  domainWallDslashCuda(&out, gauge, &in, parity, dagger, &x, mass, k, commDim, 1, profile);
114 
115  long long Ls = in.X(4);
116  long long bulk = (Ls-2)*(in.Volume()/Ls);
117  long long wall = 2*in.Volume()/Ls;
118  flops += (48LL)*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
119  }
120 
121  // Apply the 4D even-odd preconditioned domain-wall Dirac operator
123  {
124  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
125  double kappa2 = -kappa5*kappa5;
126 
127  bool reset1 = newTmp(&tmp1, in);
128 
129  //QUDA_MATPC_EVEN_EVEN : 1 - k D5 - k^2 D4_eo D5inv D4_oe
130  //QUDA_MATPC_ODD_ODD : 1 - k D5 - k^2 D4_oe D5inv D4_eo
133  Dslash5inv(out, *tmp1, QUDA_ODD_PARITY, kappa5);
134  Dslash4Xpay(*tmp1, out, QUDA_ODD_PARITY, in, kappa2);
135  Dslash5Xpay(out, in, QUDA_EVEN_PARITY,*tmp1, -kappa5);
136  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
138  Dslash5inv(out, *tmp1, QUDA_EVEN_PARITY, kappa5);
139  Dslash4Xpay(*tmp1, out, QUDA_EVEN_PARITY, in, kappa2);
140  Dslash5Xpay(out, in, QUDA_ODD_PARITY, *tmp1, -kappa5);
141  } else {
142  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
143  }
144 
145  deleteTmp(&tmp1, reset1);
146  }
147 
149  {
150  bool reset = newTmp(&tmp2, in);
151  M(*tmp2, in);
152  Mdag(out, *tmp2);
153  deleteTmp(&tmp2, reset);
154  }
155 
158  const QudaSolutionType solType) const
159  {
160  bool reset = newTmp(&tmp1, b);
161  // we desire solution to preconditioned system
162  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
163  src = &b;
164  sol = &x;
165  } else {
166  // we desire solution to full system
168  // src = b_e + k D4_eo*D5inv b_o
171  src = &(x.Odd());
172  sol = &(x.Even());
173  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
174  // src = b_o + k D4_oe*D5inv b_e
177  src = &(x.Even());
178  sol = &(x.Odd());
179  } else {
180  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
181  }
182  // here we use final solution to store parity solution and parity source
183  // b is now up for grabs if we want
184  }
185  deleteTmp(&tmp1, reset);
186  }
187 
189  const QudaSolutionType solType) const
190  {
191  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
192  return;
193  }
194 
195  bool reset1 = newTmp(&tmp1, x);
196 
197  // create full solution
198 
199  checkFullSpinor(x, b);
201  // x_o = D5inv b_o - k D5inv D4_oe x_e
204  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
205  // x_e = D5inv b_e - k D5inv D4_eo x_o
208  } else {
209  errorQuda("MatPCType %d not valid for DiracDomainWall4DPC", matpcType);
210  }
211  deleteTmp(&tmp1, reset1);
212  }
213 
214 } // end namespace quda
FaceBuffer face1
Definition: dirac_quda.h:148
void Dslash5(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity) const
cudaGaugeField & gauge
Definition: dirac_quda.h:88
virtual void checkParitySpinor(const cudaColorSpinorField &, const cudaColorSpinorField &) const
Definition: dirac.cpp:84
void MdagM(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
unsigned long long flops
Definition: dirac_quda.h:93
DiracDomainWall4DPC & operator=(const DiracDomainWall4DPC &dirac)
const int * X() const
#define errorQuda(...)
Definition: util_quda.h:73
void reconstruct(cudaColorSpinorField &x, const cudaColorSpinorField &b, const QudaSolutionType) const
void prepare(cudaColorSpinorField *&src, cudaColorSpinorField *&sol, cudaColorSpinorField &x, cudaColorSpinorField &b, const QudaSolutionType) const
bool newTmp(cudaColorSpinorField **, const cudaColorSpinorField &) const
Definition: dirac.cpp:51
TimeProfile profile
Definition: dirac_quda.h:104
void Dslash5inv(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const double &k) const
cudaGaugeField * gauge
Definition: dirac_quda.h:30
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, const QudaDslashPolicy &dslashPolicy=QUDA_DSLASH)
QudaGaugeParam param
Definition: pack_test.cpp:17
void checkSpinorAlias(const cudaColorSpinorField &, const cudaColorSpinorField &) const
Definition: dirac.cpp:129
cudaColorSpinorField & Odd() const
void Dslash4Xpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
int commDim[QUDA_MAX_DIM]
Definition: dirac_quda.h:102
void M(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
DiracDomainWall4DPC(const DiracParam &param)
cpuColorSpinorField * in
double mass
Definition: dirac_quda.h:90
enum QudaSolutionType_s QudaSolutionType
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
void Dslash5Xpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, const QudaParity parity, const cudaColorSpinorField &x, const double &k) const
void Dslash4(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 Mdag(cudaColorSpinorField &out, const cudaColorSpinorField &in) const
Definition: dirac.cpp:68
const QudaParity parity
Definition: dslash_test.cpp:29
cudaColorSpinorField & Even() const