QUDA  0.9.0
dirac_wilson.cpp
Go to the documentation of this file.
1 #include <dirac_quda.h>
2 #include <blas_quda.h>
3 #include <iostream>
4 #include <multigrid.h>
5 
6 namespace quda {
7 
9 
11 
12  // hack (for DW and TM operators)
13  DiracWilson::DiracWilson(const DiracParam &param, const int nDims) : Dirac(param) { }
14 
16 
18  {
19  if (&dirac != this) {
21  }
22  return *this;
23  }
24 
26  const QudaParity parity) const
27  {
30 
32  wilsonDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
33  &static_cast<const cudaColorSpinorField&>(in), parity, dagger, 0, 0.0, commDim, profile);
34  } else {
35  errorQuda("Not supported");
36  }
37 
38  flops += 1320ll*in.Volume();
39  }
40 
42  const QudaParity parity, const ColorSpinorField &x,
43  const double &k) const
44  {
47 
49  wilsonDslashCuda(&static_cast<cudaColorSpinorField&>(out), *gauge,
50  &static_cast<const cudaColorSpinorField&>(in), parity, dagger,
51  &static_cast<const cudaColorSpinorField&>(x), k, commDim, profile);
52  } else {
53  errorQuda("Not supported");
54  }
55 
56  flops += 1368ll*in.Volume();
57  }
58 
60  {
61  ColorSpinorField *In = &const_cast<ColorSpinorField&>(in);
62  if (in.Location() == QUDA_CPU_FIELD_LOCATION) {
65  param.fieldOrder = param.precision == QUDA_DOUBLE_PRECISION ? QUDA_FLOAT2_FIELD_ORDER :
67  param.gammaBasis = QUDA_UKQCD_GAMMA_BASIS;
69  *In = in;
70  }
71 
72  ColorSpinorField *Out = &out;
73  if (out.Location() == QUDA_CPU_FIELD_LOCATION) {
76  param.fieldOrder = param.precision == QUDA_DOUBLE_PRECISION ? QUDA_FLOAT2_FIELD_ORDER :
78  param.gammaBasis = QUDA_UKQCD_GAMMA_BASIS;
80  }
81 
82  checkFullSpinor(*Out, *In);
83  DslashXpay(Out->Odd(), In->Even(), QUDA_ODD_PARITY, In->Odd(), -kappa);
84  DslashXpay(Out->Even(), In->Odd(), QUDA_EVEN_PARITY, In->Even(), -kappa);
85 
86  if (in.Location() == QUDA_CPU_FIELD_LOCATION) delete In;
87  if (out.Location() == QUDA_CPU_FIELD_LOCATION) {
88  out = *Out;
89  delete Out;
90  }
91  }
92 
94  {
96 
97  bool reset = newTmp(&tmp1, in);
99 
100  M(*tmp1, in);
101  Mdag(out, *tmp1);
102 
103  deleteTmp(&tmp1, reset);
104  }
105 
108  const QudaSolutionType solType) const
109  {
110  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
111  errorQuda("Preconditioned solution requires a preconditioned solve_type");
112  }
113 
114  src = &b;
115  sol = &x;
116  }
117 
119  const QudaSolutionType solType) const
120  {
121  // do nothing
122  }
123 
124  /* Creates the coarse grid dirac operator
125  Takes: multigrid transfer class, which knows
126  about the coarse grid blocking, as well as
127  having prolongate and restrict member functions
128 
129  Returns: Color matrices Y[0..2*dim] corresponding
130  to the coarse grid operator. The first 2*dim
131  matrices correspond to the forward/backward
132  hopping terms on the coarse grid. Y[2*dim] is
133  the color matrix that is diagonal on the coarse
134  grid
135  */
136 
137  void DiracWilson::createCoarseOp(GaugeField &Y, GaugeField &X, GaugeField &Xinv, GaugeField &Yhat, const Transfer &T, double kappa, double mu, double mu_factor) const {
138  double a = 2.0 * kappa * mu * T.Vectors().TwistFlavor();
139  cudaCloverField *c = NULL;
141  }
142 
144  : DiracWilson(param)
145  {
146 
147  }
148 
150  : DiracWilson(dirac)
151  {
152 
153  }
154 
156  {
157 
158  }
159 
161  {
162  if (&dirac != this) {
164  }
165  return *this;
166  }
167 
169  {
170  double kappa2 = -kappa*kappa;
171 
172  bool reset = newTmp(&tmp1, in);
173 
176  DslashXpay(out, *tmp1, QUDA_EVEN_PARITY, in, kappa2);
177  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
179  DslashXpay(out, *tmp1, QUDA_ODD_PARITY, in, kappa2);
180  } else {
181  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
182  }
183 
184  deleteTmp(&tmp1, reset);
185  }
186 
188  {
189  bool reset = newTmp(&tmp2, in);
190  M(*tmp2, in);
191  Mdag(out, *tmp2);
192  deleteTmp(&tmp2, reset);
193  }
194 
197  const QudaSolutionType solType) const
198  {
199  // we desire solution to preconditioned system
200  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
201  src = &b;
202  sol = &x;
203  } else {
204  // we desire solution to full system
206  // src = b_e + k D_eo b_o
207  DslashXpay(x.Odd(), b.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
208  src = &(x.Odd());
209  sol = &(x.Even());
210  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
211  // src = b_o + k D_oe b_e
212  DslashXpay(x.Even(), b.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
213  src = &(x.Even());
214  sol = &(x.Odd());
215  } else {
216  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
217  }
218  // here we use final solution to store parity solution and parity source
219  // b is now up for grabs if we want
220  }
221 
222  }
223 
225  const QudaSolutionType solType) const
226  {
227  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
228  return;
229  }
230 
231  // create full solution
232 
233  checkFullSpinor(x, b);
235  // x_o = b_o + k D_oe x_e
236  DslashXpay(x.Odd(), x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
237  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
238  // x_e = b_e + k D_eo x_o
239  DslashXpay(x.Even(), x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
240  } else {
241  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
242  }
243  }
244 
245 } // namespace quda
unsigned long long flops
Definition: dirac_quda.h:100
double mu
Definition: test_util.cpp:1643
DiracWilson(const DiracParam &param)
Definition: dirac_wilson.cpp:8
DiracWilsonPC & operator=(const DiracWilsonPC &dirac)
const void * src
DiracWilsonPC(const DiracParam &param)
#define errorQuda(...)
Definition: util_quda.h:90
cudaGaugeField * gauge
Definition: dirac_quda.h:95
double mu_factor[QUDA_MAX_MG_LEVEL]
Definition: test_util.cpp:1659
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 wilsonDslashCuda(cudaColorSpinorField *out, const cudaGaugeField &gauge, const cudaColorSpinorField *in, const int oddBit, const int daggerBit, const cudaColorSpinorField *x, const double &k, const int *commDim, TimeProfile &profile)
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const
const ColorSpinorField & Even() const
void deleteTmp(ColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:64
const ColorSpinorField & Odd() const
static ColorSpinorField * Create(const ColorSpinorParam &param)
TimeProfile profile
Definition: dirac_quda.h:112
DiracWilson & operator=(const DiracWilson &dirac)
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
virtual void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, 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 M(ColorSpinorField &out, const ColorSpinorField &in) const
const ColorSpinorField & Vectors(QudaFieldLocation location=QUDA_CPU_FIELD_LOCATION) const
Definition: transfer.h:195
VOLATILE spinorFloat kappa
void checkSpinorAlias(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:137
cpuColorSpinorField * in
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
#define checkLocation(...)
enum QudaSolutionType_s QudaSolutionType
virtual void createCoarseOp(GaugeField &Y, GaugeField &X, GaugeField &Xinv, GaugeField &Yhat, const Transfer &T, double kappa, double mu=0., double mu_factor=0.) const
Create the coarse Wilson operator.
QudaDagType dagger
Definition: dirac_quda.h:99
enum QudaParity_s QudaParity
double kappa
Definition: dirac_quda.h:96
QudaMatPCType matpcType
Definition: dirac_quda.h:98
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const
Definition: dirac.cpp:73
Dirac & operator=(const Dirac &dirac)
Definition: dirac.cpp:32
QudaFieldLocation location
Definition: quda.h:27
GaugeCovDev * dirac
Definition: covdev_test.cpp:75
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
cpuColorSpinorField * out
QudaTwistFlavorType TwistFlavor() const
const void * c
void CoarseOp(GaugeField &Y, GaugeField &X, GaugeField &Xinv, GaugeField &Yhat, const Transfer &T, const cudaGaugeField &gauge, const cudaCloverField *clover, double kappa, double mu, double mu_factor, QudaDiracType dirac, QudaMatPCType matpc)
Coarse operator construction from a fine-grid operator (Wilson / Clover)
Definition: coarse_op.cu:170
virtual void Dslash(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
virtual void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:89
virtual ~DiracWilson()
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
QudaParity parity
Definition: covdev_test.cpp:53
ColorSpinorField * tmp2
Definition: dirac_quda.h:102
#define a
ColorSpinorField * tmp1
Definition: dirac_quda.h:101