QUDA  v0.5.0
A library for QCD on GPUs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dirac_wilson.cpp
Go to the documentation of this file.
1 #include <dirac_quda.h>
2 #include <blas_quda.h>
3 #include <iostream>
4 
5 namespace quda {
6 
8  Dirac(param), face(param.gauge->X(), 4, 12, 1, param.gauge->Precision()) { }
9 
11  Dirac(dirac), face(dirac.face) { }
12 
13  DiracWilson::DiracWilson(const DiracParam &param, const int nDims) :
14  Dirac(param), face(param.gauge->X(), nDims, 12, 1, param.gauge->Precision(), param.Ls) { }//temporal hack (for DW and TM operators)
15 
17 
19  {
20  if (&dirac != this) {
21  Dirac::operator=(dirac);
22  face = dirac.face;
23  }
24  return *this;
25  }
26 
28  const QudaParity parity) const
29  {
31  checkParitySpinor(in, out);
32  checkSpinorAlias(in, out);
33 
34  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda
35 
36  wilsonDslashCuda(&out, gauge, &in, parity, dagger, 0, 0.0, commDim);
37 
38  flops += 1320ll*in.Volume();
39  }
40 
43  const double &k) const
44  {
46  checkParitySpinor(in, out);
47  checkSpinorAlias(in, out);
48 
49  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda
50 
51  wilsonDslashCuda(&out, gauge, &in, parity, dagger, &x, k, commDim);
52 
53  flops += 1368ll*in.Volume();
54  }
55 
57  {
58  checkFullSpinor(out, in);
59  DslashXpay(out.Odd(), in.Even(), QUDA_ODD_PARITY, in.Odd(), -kappa);
60  DslashXpay(out.Even(), in.Odd(), QUDA_EVEN_PARITY, in.Even(), -kappa);
61  }
62 
64  {
65  checkFullSpinor(out, in);
66 
67  bool reset = newTmp(&tmp1, in);
68  checkFullSpinor(*tmp1, in);
69 
70  M(*tmp1, in);
71  Mdag(out, *tmp1);
72 
73  deleteTmp(&tmp1, reset);
74  }
75 
78  const QudaSolutionType solType) const
79  {
80  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
81  errorQuda("Preconditioned solution requires a preconditioned solve_type");
82  }
83 
84  src = &b;
85  sol = &x;
86  }
87 
89  const QudaSolutionType solType) const
90  {
91  // do nothing
92  }
93 
95  : DiracWilson(param)
96  {
97 
98  }
99 
101  : DiracWilson(dirac)
102  {
103 
104  }
105 
107  {
108 
109  }
110 
112  {
113  if (&dirac != this) {
114  DiracWilson::operator=(dirac);
115  }
116  return *this;
117  }
118 
120  {
121  double kappa2 = -kappa*kappa;
122 
123  bool reset = newTmp(&tmp1, in);
124 
126  Dslash(*tmp1, in, QUDA_ODD_PARITY);
127  DslashXpay(out, *tmp1, QUDA_EVEN_PARITY, in, kappa2);
128  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
130  DslashXpay(out, *tmp1, QUDA_ODD_PARITY, in, kappa2);
131  } else {
132  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
133  }
134 
135  deleteTmp(&tmp1, reset);
136  }
137 
139  {
140 #ifdef MULTI_GPU
141  bool reset = newTmp(&tmp2, in);
142  M(*tmp2, in);
143  Mdag(out, *tmp2);
144  deleteTmp(&tmp2, reset);
145 #else
146  M(out, in);
147  Mdag(out, out);
148 #endif
149  }
150 
153  const QudaSolutionType solType) const
154  {
155  // we desire solution to preconditioned system
156  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
157  src = &b;
158  sol = &x;
159  } else {
160  // we desire solution to full system
162  // src = b_e + k D_eo b_o
163  DslashXpay(x.Odd(), b.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
164  src = &(x.Odd());
165  sol = &(x.Even());
166  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
167  // src = b_o + k D_oe b_e
168  DslashXpay(x.Even(), b.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
169  src = &(x.Even());
170  sol = &(x.Odd());
171  } else {
172  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
173  }
174  // here we use final solution to store parity solution and parity source
175  // b is now up for grabs if we want
176  }
177 
178  }
179 
181  const QudaSolutionType solType) const
182  {
183  if (solType == QUDA_MATPC_SOLUTION || solType == QUDA_MATPCDAG_MATPC_SOLUTION) {
184  return;
185  }
186 
187  // create full solution
188 
189  checkFullSpinor(x, b);
191  // x_o = b_o + k D_oe x_e
192  DslashXpay(x.Odd(), x.Even(), QUDA_ODD_PARITY, b.Odd(), kappa);
193  } else if (matpcType == QUDA_MATPC_ODD_ODD) {
194  // x_e = b_e + k D_eo x_o
195  DslashXpay(x.Even(), x.Odd(), QUDA_EVEN_PARITY, b.Even(), kappa);
196  } else {
197  errorQuda("MatPCType %d not valid for DiracWilsonPC", matpcType);
198  }
199  }
200 
201 } // namespace quda