QUDA  v1.1.0
A library for QCD on GPUs
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  {
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 
46  void DiracWilson::M(ColorSpinorField &out, const ColorSpinorField &in) const
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 
86  double kappa, double mass, double mu, double mu_factor) const {
88  errorQuda("Wilson-type operators only support aggregation coarsening");
89 
90  double a = 2.0 * kappa * mu * T.Vectors().TwistFlavor();
91  cudaCloverField *c = NULL;
93  }
94 
97  {
98 
99  }
100 
102  : DiracWilson(dirac)
103  {
104 
105  }
106 
108  {
109 
110  }
111 
113  {
114  if (&dirac != this) {
116  }
117  return *this;
118  }
119 
121  {
122  double kappa2 = -kappa*kappa;
123 
124  bool reset = newTmp(&tmp1, in);
125 
127  Dslash(*tmp1, in, QUDA_ODD_PARITY);
128  DslashXpay(out, *tmp1, QUDA_EVEN_PARITY, in, kappa2);
129  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
131  DslashXpay(out, *tmp1, QUDA_ODD_PARITY, in, kappa2);
132  } else {
133  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
134  }
135 
136  deleteTmp(&tmp1, reset);
137  }
138 
140  {
141  bool reset = newTmp(&tmp2, in);
142  M(*tmp2, in);
143  Mdag(out, *tmp2);
144  deleteTmp(&tmp2, reset);
145  }
146 
149  const QudaSolutionType solType) const
150  {
151  // we desire solution to preconditioned system
152  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
153  src = &b;
154  sol = &x;
155  } else {
156  // we desire solution to full system
158  // src = b_e + k D_eo b_o
159  DslashXpay(x.Odd(), b.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
160  src = &(x.Odd());
161  sol = &(x.Even());
162  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
163  // src = b_o + k D_oe b_e
164  DslashXpay(x.Even(), b.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
165  src = &(x.Even());
166  sol = &(x.Odd());
167  } else {
168  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
169  }
170  // here we use final solution to store parity solution and parity source
171  // b is now up for grabs if we want
172  }
173 
174  }
175 
177  const QudaSolutionType solType) const
178  {
179  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
180  return;
181  }
182 
183  // create full solution
184 
185  checkFullSpinor(x, b);
187  // x_o = b_o + k D_oe x_e
188  DslashXpay(x.Odd(), x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
189  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
190  // x_e = b_e + k D_eo x_o
191  DslashXpay(x.Even(), x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
192  } else {
193  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
194  }
195  }
196 
197 } // namespace quda
const ColorSpinorField & Odd() const
QudaTwistFlavorType TwistFlavor() const
const ColorSpinorField & Even() const
unsigned long long flops
Definition: dirac_quda.h:150
bool newTmp(ColorSpinorField **, const ColorSpinorField &) const
Definition: dirac.cpp:72
double kappa
Definition: dirac_quda.h:145
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
Dirac & operator=(const Dirac &dirac)
Definition: dirac.cpp:51
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
DiracWilson(const DiracParam &param)
Definition: dirac_wilson.cpp:8
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
DiracWilson & operator=(const DiracWilson &dirac)
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.
virtual ~DiracWilson()
virtual void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
Apply MdagM operator which may be optimized.
virtual void DslashXpay(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity, const ColorSpinorField &x, const double &k) const
Xpay version of Dslash.
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
virtual void Dslash(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
apply 'dslash' operator for the DiracOp. This may be e.g. AD
virtual void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
void MdagM(ColorSpinorField &out, const ColorSpinorField &in) const
Apply MdagM operator which may be optimized.
DiracWilsonPC(const DiracParam &param)
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
DiracWilsonPC & operator=(const DiracWilsonPC &dirac)
void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
QudaTransferType getTransferType() const
Definition: transfer.h:240
const ColorSpinorField & Vectors(QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION) const
Definition: transfer.h:209
double kappa
double mass
double mu
quda::mgarray< double > mu_factor
GaugeCovDev * dirac
Definition: covdev_test.cpp:42
QudaParity parity
Definition: covdev_test.cpp:40
@ QUDA_WILSON_DIRAC
Definition: enum_quda.h:291
@ QUDA_EVEN_PARITY
Definition: enum_quda.h:284
@ QUDA_ODD_PARITY
Definition: enum_quda.h:284
@ QUDA_INVALID_PARITY
Definition: enum_quda.h:284
@ QUDA_TRANSFER_AGGREGATE
Definition: enum_quda.h:453
enum QudaSolutionType_s QudaSolutionType
@ QUDA_MATPC_ODD_ODD
Definition: enum_quda.h:217
@ QUDA_MATPC_EVEN_EVEN
Definition: enum_quda.h:216
@ QUDA_MATPC_INVALID
Definition: enum_quda.h:220
@ QUDA_MATPC_SOLUTION
Definition: enum_quda.h:159
@ QUDA_MATPCDAG_MATPC_SOLUTION
Definition: enum_quda.h:161
enum QudaParity_s QudaParity
void CoarseOp(GaugeField &Y, GaugeField &X, const Transfer &T, const cudaGaugeField &gauge, const cudaCloverField *clover, double kappa, double mass, double mu, double mu_factor, QudaDiracType dirac, QudaMatPCType matpc)
Coarse operator construction from a fine-grid operator (Wilson / Clover)
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.
QudaGaugeParam param
Definition: pack_test.cpp:18
#define errorQuda(...)
Definition: util_quda.h:120