CHROMA
eoprec_clover_linop_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Even-odd preconditioned clover linear operator
3  */
4 
6 
7 
8 
9 namespace Chroma
10 {
11 
12  using namespace QDP::Hints;
13 
14  //! Creation routine with Anisotropy
15  /*!
16  * \param u_ gauge field (Read)
17  * \param param_ fermion kappa (Read)
18  */
19  void EvenOddPrecCloverLinOp::create(Handle< FermState<T,P,Q> > fs,
20  const CloverFermActParams& param_)
21  {
22  START_CODE();
23  // QDPIO::cout << __PRETTY_FUNCTION__ << ": enter" << std::endl;
24 
25  param = param_;
26 
27  clov.create(fs, param);
28 
29  invclov.create(fs,param,clov); // make a copy
30  invclov.choles(0); // invert the cb=0 part
31 
32  D.create(fs, param.anisoParam);
33 
34  clov_deriv_time = 0;
35  clov_apply_time = 0;
36 
37  // QDPIO::cout << __PRETTY_FUNCTION__ << ": exit" << std::endl;
38  END_CODE();
39  }
40 
41  //! Apply the the odd-odd block onto a source std::vector
42  void
43  EvenOddPrecCloverLinOp::oddOddLinOp(LatticeFermion& chi, const LatticeFermion& psi,
44  enum PlusMinus isign) const
45  {
46  START_CODE();
47 
48  swatch.reset(); swatch.start();
49  clov.apply(chi, psi, isign, 1);
50  swatch.stop();
51  clov_apply_time += swatch.getTimeInSeconds();
52 
53  END_CODE();
54  }
55 
56 
57  //! Apply the the even-even block onto a source std::vector
58  void
59  EvenOddPrecCloverLinOp::evenEvenLinOp(LatticeFermion& chi, const LatticeFermion& psi,
60  enum PlusMinus isign) const
61  {
62  START_CODE();
63 
64  // Nuke for testing
65  swatch.reset(); swatch.start();
66  clov.apply(chi, psi, isign, 0);
67  swatch.stop();
68  clov_apply_time += swatch.getTimeInSeconds();
69 
70  END_CODE();
71  }
72 
73  //! Apply the inverse of the even-even block onto a source std::vector
74  void
75  EvenOddPrecCloverLinOp::evenEvenInvLinOp(LatticeFermion& chi, const LatticeFermion& psi,
76  enum PlusMinus isign) const
77  {
78  START_CODE();
79 
80  swatch.reset(); swatch.start();
81  invclov.apply(chi, psi, isign, 0);
82  swatch.stop();
83  clov_apply_time += swatch.getTimeInSeconds();
84 
85  END_CODE();
86  }
87 
88 
89  //! Apply even-odd linop component
90  /*!
91  * The operator acts on the entire even sublattice
92  *
93  * \param chi Pseudofermion field (Write)
94  * \param psi Pseudofermion field (Read)
95  * \param isign Flag ( PLUS | MINUS ) (Read)
96  */
97  void
99  const LatticeFermion& psi,
100  enum PlusMinus isign) const
101  {
102  START_CODE();
103 
104  Real mhalf = -0.5;
105 
106  D.apply(chi, psi, isign, 0);
107  chi[rb[0]] *= mhalf;
108 
109  END_CODE();
110  }
111 
112  //! Apply odd-even linop component
113  /*!
114  * The operator acts on the entire odd sublattice
115  *
116  * \param chi Pseudofermion field (Write)
117  * \param psi Pseudofermion field (Read)
118  * \param isign Flag ( PLUS | MINUS ) (Read)
119  */
120  void
121  EvenOddPrecCloverLinOp::oddEvenLinOp(LatticeFermion& chi,
122  const LatticeFermion& psi,
123  enum PlusMinus isign) const
124  {
125  START_CODE();
126 
127  Real mhalf = -0.5;
128 
129  D.apply(chi, psi, isign, 1);
130  chi[rb[1]] *= mhalf;
131 
132  END_CODE();
133  }
134 
135 
136  //! Apply even-odd preconditioned Clover fermion linear operator
137  /*!
138  * \param chi Pseudofermion field (Write)
139  * \param psi Pseudofermion field (Read)
140  * \param isign Flag ( PLUS | MINUS ) (Read)
141  */
142  void EvenOddPrecCloverLinOp::operator()(LatticeFermion & chi,
143  const LatticeFermion& psi,
144  enum PlusMinus isign) const
145  {
146  START_CODE();
147 
148  LatticeFermion tmp1; moveToFastMemoryHint(tmp1);
149  LatticeFermion tmp2; moveToFastMemoryHint(tmp2);
150  Real mquarter = -0.25;
151 
152 
153 
154 
155  // tmp1_o = D_oe A^(-1)_ee D_eo psi_o
156  D.apply(tmp1, psi, isign, 0);
157 
158  swatch.reset(); swatch.start();
159  invclov.apply(tmp2, tmp1, isign, 0);
160  swatch.stop();
161  clov_apply_time += swatch.getTimeInSeconds();
162 
163  D.apply(tmp1, tmp2, isign, 1);
164 
165  // chi_o = A_oo psi_o - tmp1_o
166  swatch.reset(); swatch.start();
167  clov.apply(chi, psi, isign, 1);
168  swatch.stop();
169  clov_apply_time += swatch.getTimeInSeconds();
170 
171  chi[rb[1]] += mquarter*tmp1;
172 
173  // Twisted Term?
174  if( param.twisted_m_usedP ){
175  // tmp1 = i mu gamma_5 tmp1
176  tmp1[rb[1]] = (GammaConst<Ns,Ns*Ns-1>() * timesI(psi));
177 
178  if( isign == PLUS ) {
179  chi[rb[1]] += param.twisted_m * tmp1;
180  }
181  else {
182  chi[rb[1]] -= param.twisted_m * tmp1;
183  }
184  }
185 
186  END_CODE();
187  }
188 
189 
190  //! Apply the even-even block onto a source std::vector
191  void
192  EvenOddPrecCloverLinOp::derivEvenEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
193  const LatticeFermion& chi, const LatticeFermion& psi,
194  enum PlusMinus isign) const
195  {
196  START_CODE();
197 
198  swatch.reset(); swatch.start();
199  clov.deriv(ds_u, chi, psi, isign, 0);
200  swatch.stop();
201  clov_deriv_time += swatch.getTimeInSeconds();
202 
203  END_CODE();
204  }
205 
206  //! Apply the even-even block onto a source std::vector
207  void
208  EvenOddPrecCloverLinOp::derivEvenEvenLinOpMP(multi1d<LatticeColorMatrix>& ds_u,
209  const multi1d<LatticeFermion>& chi, const multi1d<LatticeFermion>& psi,
210  enum PlusMinus isign) const
211  {
212  START_CODE();
213 
214  swatch.reset(); swatch.start();
215  clov.derivMultipole(ds_u, chi, psi, isign, 0);
216  swatch.stop();
217  clov_deriv_time += swatch.getTimeInSeconds();
218 
219  END_CODE();
220  }
221 
222  //! Apply the even-even block onto a source std::vector
223  void
224  EvenOddPrecCloverLinOp::derivLogDetEvenEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
225  enum PlusMinus isign) const
226  {
227  START_CODE();
228 
229  // Testing Odd Odd Term - get nothing from even even term
230  invclov.derivTrLn(ds_u, isign, 0);
231 
232  END_CODE();
233  }
234 
235  //! Apply the the even-odd block onto a source std::vector
236  void
237  EvenOddPrecCloverLinOp::derivEvenOddLinOp(multi1d<LatticeColorMatrix>& ds_u,
238  const LatticeFermion& chi, const LatticeFermion& psi,
239  enum PlusMinus isign) const
240  {
241  START_CODE();
242  ds_u.resize(Nd);
243  D.deriv(ds_u, chi, psi, isign, 0);
244  for(int mu=0; mu < Nd; mu++) {
245  ds_u[mu] *= Real(-0.5);
246  }
247  END_CODE();
248  }
249 
250  //! Apply the the odd-even block onto a source std::vector
251  void
252  EvenOddPrecCloverLinOp::derivOddEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
253  const LatticeFermion& chi, const LatticeFermion& psi,
254  enum PlusMinus isign) const
255  {
256  START_CODE();
257  ds_u.resize(Nd);
258 
259  D.deriv(ds_u, chi, psi, isign, 1);
260  for(int mu=0; mu < Nd; mu++) {
261  ds_u[mu] *= Real(-0.5);
262  }
263  END_CODE();
264  }
265 
266  // Inherit this
267  //! Apply the the odd-odd block onto a source std::vector
268  void
269  EvenOddPrecCloverLinOp::derivOddOddLinOp(multi1d<LatticeColorMatrix>& ds_u,
270  const LatticeFermion& chi, const LatticeFermion& psi,
271  enum PlusMinus isign) const
272  {
273  START_CODE();
274 
275  swatch.reset(); swatch.start();
276  clov.deriv(ds_u, chi, psi, isign, 1);
277  swatch.stop();
278  clov_deriv_time += swatch.getTimeInSeconds();
279 
280  END_CODE();
281  }
282 
283  void
284  EvenOddPrecCloverLinOp::derivOddOddLinOpMP(multi1d<LatticeColorMatrix>& ds_u,
285  const multi1d<LatticeFermion>& chi, const multi1d<LatticeFermion>& psi,
286  enum PlusMinus isign) const
287  {
288  START_CODE();
289 
290  swatch.reset(); swatch.start();
291  clov.derivMultipole(ds_u, chi, psi, isign, 1);
292  swatch.stop();
293  clov_deriv_time += swatch.getTimeInSeconds();
294 
295  END_CODE();
296  }
297 
298  //! Return flops performed by the operator()
299  unsigned long EvenOddPrecCloverLinOp::nFlops() const
300  {
301  unsigned long cbsite_flops = 2*D.nFlops()+2*clov.nFlops()+4*Nc*Ns;
302  if( param.twisted_m_usedP ) {
303  cbsite_flops += 4*Nc*Ns; // a + mu*b : a = chi, b = g_5 I psi
304  }
305  return cbsite_flops*(Layout::sitesOnNode()/2);
306  }
307 
308  //! Get the log det of the even even part
309  // BUt for now, return zero for testing.
311  return invclov.cholesDet(0);
312  }
313 } // End Namespace Chroma
void derivLogDetEvenEvenLinOp(multi1d< LatticeColorMatrix > &ds_u, enum PlusMinus isign) const
Apply the even-even block onto a source std::vector.
unsigned long nFlops() const
Return flops performed by the operator()
void oddOddLinOp(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the odd-odd block onto a source std::vector.
void derivOddOddLinOp(multi1d< LatticeColorMatrix > &ds_u, const LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the odd-odd block onto a source std::vector.
void oddEvenLinOp(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the odd-even block onto a source std::vector.
void derivOddOddLinOpMP(multi1d< LatticeColorMatrix > &ds_u, const multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign) const
void create(Handle< FermState< T, P, Q > > fs, const CloverFermActParams &param_)
Creation routine.
void derivOddEvenLinOp(multi1d< LatticeColorMatrix > &ds_u, const LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the odd-even block onto a source std::vector.
void evenEvenLinOp(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the even-even block onto a source std::vector.
void evenOddLinOp(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the even-odd block onto a source std::vector.
void operator()(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply even-odd preconditioned Clover fermion linear operator.
void derivEvenOddLinOp(multi1d< LatticeColorMatrix > &ds_u, const LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the the even-odd block onto a source std::vector.
Double logDetEvenEvenLinOp(void) const
Get the log det of the even even part.
void derivEvenEvenLinOpMP(multi1d< LatticeColorMatrix > &ds_u, const multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign) const
Apply the even-even block onto a source std::vector.
void derivEvenEvenLinOp(multi1d< LatticeColorMatrix > &ds_u, const LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the even-even block onto a source std::vector.
void evenEvenInvLinOp(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign) const
Apply the inverse of the even-even block onto a source std::vector.
int mu
Definition: cool.cc:24
Even-odd preconditioned Clover fermion linear operator.
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
FloatingPoint< double > Double
Definition: gtest.h:7351