QUDA  v1.1.0
A library for QCD on GPUs
gauge_laplace.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 #include <dslash_quda.h>
6 
7 namespace quda {
8 
10 
11  GaugeLaplace::GaugeLaplace(const GaugeLaplace &laplace) : Dirac(laplace) { }
12 
14 
16  {
17  if (&laplace != this) Dirac::operator=(laplace);
18  return *this;
19  }
20 
22  {
23  checkSpinorAlias(in, out);
24 
25  int comm_dim[4] = {};
26  // only switch on comms needed for directions with a derivative
27  for (int i = 0; i < 4; i++) {
29  if (laplace3D == i) comm_dim[i] = 0;
30  }
31  ApplyLaplace(out, in, *gauge, laplace3D, 1.0, 1.0, in, parity, dagger, comm_dim, profile);
32  flops += 1320ll*in.Volume(); // FIXME
33  }
34 
36  const QudaParity parity, const ColorSpinorField &x,
37  const double &k) const
38  {
39  checkSpinorAlias(in, out);
40 
41  int comm_dim[4] = {};
42  // only switch on comms needed for directions with a derivative
43  for (int i = 0; i < 4; i++) {
45  if (laplace3D == i) comm_dim[i] = 0;
46  }
47  ApplyLaplace(out, in, *gauge, laplace3D, k, 1.0, x, parity, dagger, comm_dim, profile);
48  flops += 1368ll*in.Volume(); // FIXME
49  }
50 
52  {
53  checkFullSpinor(out, in);
54  DslashXpay(out, in, QUDA_INVALID_PARITY, in, -kappa);
55  }
56 
58  {
59  bool reset = newTmp(&tmp1, in);
60  checkFullSpinor(*tmp1, in);
61 
62  M(*tmp1, in);
63  Mdag(out, *tmp1);
64 
65  deleteTmp(&tmp1, reset);
66  }
67 
70  const QudaSolutionType solType) const
71  {
72  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
73  errorQuda("Preconditioned solution requires a preconditioned solve_type");
74  }
75 
76  src = &b;
77  sol = &x;
78  }
79 
81  const QudaSolutionType solType) const
82  {
83  // do nothing
84  }
85 
87 
89 
91 
93  {
94  if (&laplace != this) GaugeLaplace::operator=(laplace);
95  return *this;
96  }
97 
99  {
100  double kappa2 = -kappa*kappa;
101 
102  bool reset = newTmp(&tmp1, in);
103 
105  Dslash(*tmp1, in, QUDA_ODD_PARITY);
106  DslashXpay(out, *tmp1, QUDA_EVEN_PARITY, in, kappa2);
107  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
109  DslashXpay(out, *tmp1, QUDA_ODD_PARITY, in, kappa2);
110  } else {
111  errorQuda("MatPCType %d not valid for GaugeLaplacePC", matpcType);
112  }
113 
114  deleteTmp(&tmp1, reset);
115  }
116 
118  {
119  bool reset = newTmp(&tmp2, in);
120  M(*tmp2, in);
121  Mdag(out, *tmp2);
122  deleteTmp(&tmp2, reset);
123  }
124 
127  const QudaSolutionType solType) const
128  {
129  // we desire solution to preconditioned system
130  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
131  src = &b;
132  sol = &x;
133  } else {
134  // we desire solution to full system
136  // src = b_e + k D_eo b_o
137  DslashXpay(x.Odd(), b.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
138  src = &(x.Odd());
139  sol = &(x.Even());
140  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
141  // src = b_o + k D_oe b_e
142  DslashXpay(x.Even(), b.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
143  src = &(x.Even());
144  sol = &(x.Odd());
145  } else {
146  errorQuda("MatPCType %d not valid for GaugeLaplacePC", matpcType);
147  }
148  // here we use final solution to store parity solution and parity source
149  // b is now up for grabs if we want
150  }
151 
152  }
153 
155  const QudaSolutionType solType) const
156  {
157  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
158  return;
159  }
160 
161  // create full solution
162  checkFullSpinor(x, b);
164  // x_o = b_o + k D_oe x_e
165  DslashXpay(x.Odd(), x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
166  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
167  // x_e = b_e + k D_eo x_o
168  DslashXpay(x.Even(), x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
169  } else {
170  errorQuda("MatPCType %d not valid for GaugeLaplacePC", matpcType);
171  }
172  }
173 
174 } // namespace quda
const ColorSpinorField & Odd() 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
void deleteTmp(ColorSpinorField **, const bool &reset) const
Definition: dirac.cpp:83
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
void Mdag(ColorSpinorField &out, const ColorSpinorField &in) const
Apply Mdag (daggered operator of M.
Definition: dirac.cpp:92
Full Gauge Laplace operator. Although not a Dirac operator per se, it's a linear operator so it's con...
Definition: dirac_quda.h:1805
GaugeLaplace & operator=(const GaugeLaplace &laplace)
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
virtual void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
GaugeLaplace(const DiracParam &param)
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
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.
Even-odd preconditioned Gauge Laplace operator.
Definition: dirac_quda.h:1833
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.
GaugeLaplacePC & operator=(const GaugeLaplacePC &laplace)
void prepare(ColorSpinorField *&src, ColorSpinorField *&sol, ColorSpinorField &x, ColorSpinorField &b, const QudaSolutionType) const
void reconstruct(ColorSpinorField &x, const ColorSpinorField &b, const QudaSolutionType) const
GaugeLaplacePC(const DiracParam &param)
int comm_dim_partitioned(int dim)
int comm_dim(int dim)
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
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 ApplyLaplace(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, int dir, double a, double b, const ColorSpinorField &x, int parity, bool dagger, const int *comm_override, TimeProfile &profile)
Driver for applying the Laplace stencil.
QudaGaugeParam param
Definition: pack_test.cpp:18
#define errorQuda(...)
Definition: util_quda.h:120