CHROMA
eoprec_clover_linop_ssecombined_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Even-odd preconditioned clover linear operator
3  */
4 
6 #include "sse_dslash.h"
7 
8 using namespace QDP::Hints;
9 
10 namespace Chroma
11 {
12 
13  //! Creation routine with Anisotropy
14  /*!
15  * \param u_ gauge field (Read)
16  * \param param_ fermion kappa (Read)
17  */
18  void EvenOddPrecCloverLinOp::create(Handle< FermState<T,P,Q> > fs,
19  const CloverFermActParams& param_)
20  {
21  START_CODE();
22 
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
98  EvenOddPrecCloverLinOp::evenOddLinOp(LatticeFermion& chi,
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  // Prepost receives for Dslash
153  sse_su3dslash_prepost_receives();
154 
155  // chi_o = A_oo psi_o - tmp1_o
156  clov.apply(chi, psi, isign, 1);
157 
158  // tmp1_o = D_oe A^(-1)_ee D_eo psi_o
159  D.apply(tmp1, psi, isign, 0);
160 
161  // Prepost receives for Dslash
162  sse_su3dslash_prepost_receives();
163  invclov.apply(tmp2, tmp1, isign, 0);
164  D.apply(tmp1, tmp2, isign, 1);
165 
166  // chi_o = A_oo psi_o - tmp1_o
167  chi[rb[1]] += mquarter*tmp1;
168 
169  END_CODE();
170  }
171 
172 
173  //! Apply the even-even block onto a source std::vector
174  void
175  EvenOddPrecCloverLinOp::derivEvenEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
176  const LatticeFermion& chi, const LatticeFermion& psi,
177  enum PlusMinus isign) const
178  {
179  START_CODE();
180 
181  swatch.reset(); swatch.start();
182  clov.deriv(ds_u, chi, psi, isign, 0);
183  swatch.stop();
184  clov_deriv_time += swatch.getTimeInSeconds();
185 
186  END_CODE();
187  }
188 
189  //! Apply the even-even block onto a source std::vector
190  void
191  EvenOddPrecCloverLinOp::derivLogDetEvenEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
192  enum PlusMinus isign) const
193  {
194  START_CODE();
195 
196  // Testing Odd Odd Term - get nothing from even even term
197  invclov.derivTrLn(ds_u, isign, 0);
198 
199  END_CODE();
200  }
201 
202  //! Apply the the even-odd block onto a source std::vector
203  void
204  EvenOddPrecCloverLinOp::derivEvenOddLinOp(multi1d<LatticeColorMatrix>& ds_u,
205  const LatticeFermion& chi, const LatticeFermion& psi,
206  enum PlusMinus isign) const
207  {
208  START_CODE();
209  ds_u.resize(Nd);
210  D.deriv(ds_u, chi, psi, isign, 0);
211  for(int mu=0; mu < Nd; mu++) {
212  ds_u[mu] *= Real(-0.5);
213  }
214  END_CODE();
215  }
216 
217  //! Apply the the odd-even block onto a source std::vector
218  void
219  EvenOddPrecCloverLinOp::derivOddEvenLinOp(multi1d<LatticeColorMatrix>& ds_u,
220  const LatticeFermion& chi, const LatticeFermion& psi,
221  enum PlusMinus isign) const
222  {
223  START_CODE();
224  ds_u.resize(Nd);
225 
226  D.deriv(ds_u, chi, psi, isign, 1);
227  for(int mu=0; mu < Nd; mu++) {
228  ds_u[mu] *= Real(-0.5);
229  }
230  END_CODE();
231  }
232 
233  // Inherit this
234  //! Apply the the odd-odd block onto a source std::vector
235  void
236  EvenOddPrecCloverLinOp::derivOddOddLinOp(multi1d<LatticeColorMatrix>& ds_u,
237  const LatticeFermion& chi, const LatticeFermion& psi,
238  enum PlusMinus isign) const
239  {
240  START_CODE();
241 
242  swatch.reset(); swatch.start();
243  clov.deriv(ds_u, chi, psi, isign, 1);
244  swatch.stop();
245  clov_deriv_time += swatch.getTimeInSeconds();
246 
247  END_CODE();
248  }
249 
250 
251  //! Return flops performed by the operator()
252  unsigned long EvenOddPrecCloverLinOp::nFlops() const
253  {
254  unsigned long cbsite_flops = 2*D.nFlops()+2*clov.nFlops()+4*Nc*Ns;
255  return cbsite_flops*(Layout::sitesOnNode()/2);
256  }
257 
258  //! Get the log det of the even even part
259  // BUt for now, return zero for testing.
260  Double EvenOddPrecCloverLinOp::logDetEvenEvenLinOp(void) const {
261  return invclov.cholesDet(0);
262  }
263 } // End Namespace Chroma
#define END_CODE()
Definition: chromabase.h:65
#define START_CODE()
Definition: chromabase.h:64
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
int mu
Definition: cool.cc:24
Even-odd preconditioned Clover fermion linear operator.
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
FloatingPoint< double > Double
Definition: gtest.h:7351
chi
Definition: pade_trln_w.cc:24
psi
Definition: pade_trln_w.cc:191
Params for clover ferm acts.