QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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) {
20  Dirac::operator=(dirac);
21  }
22  return *this;
23  }
24 
26  const QudaParity parity) const
27  {
28  checkParitySpinor(in, out);
29  checkSpinorAlias(in, out);
30 
31  ApplyWilson(out, in, *gauge, 0.0, in, parity, dagger, commDim, profile);
32  flops += 1320ll*in.Volume();
33  }
34 
36  const QudaParity parity, const ColorSpinorField &x,
37  const double &k) const
38  {
39  checkParitySpinor(in, out);
40  checkSpinorAlias(in, out);
41 
42  ApplyWilson(out, in, *gauge, k, x, parity, dagger, commDim, profile);
43  flops += 1368ll*in.Volume();
44  }
45 
47  {
48  checkFullSpinor(out, in);
49 
51  flops += 1368ll * in.Volume();
52  }
53 
55  {
56  checkFullSpinor(out, in);
57 
58  bool reset = newTmp(&tmp1, in);
59  checkFullSpinor(*tmp1, in);
60 
61  M(*tmp1, in);
62  Mdag(out, *tmp1);
63 
64  deleteTmp(&tmp1, reset);
65  }
66 
69  const QudaSolutionType solType) const
70  {
71  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
72  errorQuda("Preconditioned solution requires a preconditioned solve_type");
73  }
74 
75  src = &b;
76  sol = &x;
77  }
78 
80  const QudaSolutionType solType) const
81  {
82  // do nothing
83  }
84 
85  /* Creates the coarse grid dirac operator
86  Takes: multigrid transfer class, which knows
87  about the coarse grid blocking, as well as
88  having prolongate and restrict member functions
89 
90  Returns: Color matrices Y[0..2*dim] corresponding
91  to the coarse grid operator. The first 2*dim
92  matrices correspond to the forward/backward
93  hopping terms on the coarse grid. Y[2*dim] is
94  the color matrix that is diagonal on the coarse
95  grid
96  */
98  double kappa, double mass, double mu, double mu_factor) const {
99  double a = 2.0 * kappa * mu * T.Vectors().TwistFlavor();
100  cudaCloverField *c = NULL;
101  CoarseOp(Y, X, T, *gauge, c, kappa, a, mu_factor, QUDA_WILSON_DIRAC, QUDA_MATPC_INVALID);
102  }
103 
105  : DiracWilson(param)
106  {
107 
108  }
109 
111  : DiracWilson(dirac)
112  {
113 
114  }
115 
117  {
118 
119  }
120 
122  {
123  if (&dirac != this) {
124  DiracWilson::operator=(dirac);
125  }
126  return *this;
127  }
128 
130  {
131  double kappa2 = -kappa*kappa;
132 
133  bool reset = newTmp(&tmp1, in);
134 
136  Dslash(*tmp1, in, QUDA_ODD_PARITY);
137  DslashXpay(out, *tmp1, QUDA_EVEN_PARITY, in, kappa2);
138  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
140  DslashXpay(out, *tmp1, QUDA_ODD_PARITY, in, kappa2);
141  } else {
142  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
143  }
144 
145  deleteTmp(&tmp1, reset);
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  // we desire solution to preconditioned system
161  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
162  src = &b;
163  sol = &x;
164  } else {
165  // we desire solution to full system
167  // src = b_e + k D_eo b_o
168  DslashXpay(x.Odd(), b.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
169  src = &(x.Odd());
170  sol = &(x.Even());
171  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
172  // src = b_o + k D_oe b_e
173  DslashXpay(x.Even(), b.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
174  src = &(x.Even());
175  sol = &(x.Odd());
176  } else {
177  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
178  }
179  // here we use final solution to store parity solution and parity source
180  // b is now up for grabs if we want
181  }
182 
183  }
184 
186  const QudaSolutionType solType) const
187  {
188  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
189  return;
190  }
191 
192  // create full solution
193 
194  checkFullSpinor(x, b);
196  // x_o = b_o + k D_oe x_e
197  DslashXpay(x.Odd(), x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
198  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
199  // x_e = b_e + k D_eo x_o
200  DslashXpay(x.Even(), x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
201  } else {
202  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
203  }
204  }
205 
206 } // namespace quda
unsigned long long flops
Definition: dirac_quda.h:121
double mu
Definition: test_util.cpp:1648
DiracWilson(const DiracParam &param)
Definition: dirac_wilson.cpp:8
DiracWilsonPC & operator=(const DiracWilsonPC &dirac)
DiracWilsonPC(const DiracParam &param)
#define errorQuda(...)
Definition: util_quda.h:121
cudaGaugeField * gauge
Definition: dirac_quda.h:115
virtual void checkFullSpinor(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:146
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const
const ColorSpinorField & Even() const
void deleteTmp(ColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:81
void CoarseOp(GaugeField &Y, GaugeField &X, 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:201
const ColorSpinorField & Odd() const
TimeProfile profile
Definition: dirac_quda.h:132
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:70
int commDim[QUDA_MAX_DIM]
Definition: dirac_quda.h:130
void M(ColorSpinorField &out, const ColorSpinorField &in) const
virtual void createCoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, double kappa, double mass=0., double mu=0., double mu_factor=0.) const
Create the coarse Wilson operator.
void checkSpinorAlias(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:154
cpuColorSpinorField * in
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
double mass
Definition: dirac_quda.h:117
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
enum QudaSolutionType_s QudaSolutionType
QudaDagType dagger
Definition: dirac_quda.h:120
int X[4]
Definition: covdev_test.cpp:70
enum QudaParity_s QudaParity
double kappa
Definition: dirac_quda.h:116
QudaMatPCType matpcType
Definition: dirac_quda.h:119
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const
Definition: dirac.cpp:90
Dirac & operator=(const Dirac &dirac)
Definition: dirac.cpp:49
GaugeCovDev * dirac
Definition: covdev_test.cpp:73
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
cpuColorSpinorField * out
void ApplyWilson(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, double kappa, const ColorSpinorField &x, int parity, bool dagger, const int *comm_override, TimeProfile &profile)
Driver for applying the Wilson stencil.
QudaTwistFlavorType TwistFlavor() const
double mu_factor[QUDA_MAX_MG_LEVEL]
Definition: test_util.cpp:1674
virtual void Dslash(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
virtual void checkParitySpinor(const ColorSpinorField &, const ColorSpinorField &) const
Definition: dirac.cpp:106
virtual ~DiracWilson()
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
QudaParity parity
Definition: covdev_test.cpp:54
ColorSpinorField * tmp2
Definition: dirac_quda.h:123
const ColorSpinorField & Vectors(QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION) const
Definition: transfer.h:205
ColorSpinorField * tmp1
Definition: dirac_quda.h:122