CHROMA
syssolver_linop_cg_timing.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a M*psi=chi linear system by CG2
4  */
5 
6 #ifndef __syssolver_linop_cg_timing_h__
7 #define __syssolver_linop_cg_timing_h__
8 #include "chroma_config.h"
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
15 
16 
17 namespace Chroma
18 {
19 
20  //! CG system solver namespace
21  namespace LinOpSysSolverCGTimingEnv
22  {
23  //! Register the syssolver
24  bool registerAll();
25  }
26 
27 
28  //! Solve a M*psi=chi linear system by CG2
29  /*! \ingroup invert
30  */
31  template<typename T>
33  {
34  public:
35  //! Constructor
36  /*!
37  * \param M_ Linear operator ( Read )
38  * \param invParam inverter parameters ( Read )
39  */
41  const SysSolverCGParams& invParam_) :
42  A(A_), invParam(invParam_)
43  {}
44 
45  //! Destructor is automatic
47 
48  //! Return the subset on which the operator acts
49  const Subset& subset() const {return A->subset();}
50 
51  //! Solver the linear system
52  /*!
53  * \param psi solution ( Modify )
54  * \param chi source ( Read )
55  * \return syssolver results
56  */
58  {
59  START_CODE();
60 
61  T chi_tmp;
62  (*A)(chi_tmp, chi, MINUS);
63 
64  SystemSolverResults_t res; // initialized by a constructor
65  {
66 
67  res = InvCG2_timings(*A, chi_tmp, psi, invParam.MaxCG);
68 
69 #ifdef CHROMA_DO_ONE_CG_RESTART
70  // Save existing n_count
71  int n_count = res.n_count;
72 
73  // One automatic restart (if enabled)
74  res = InvCG2_timings(*A, chi_tmp, psi, invParam.MaxCGRestart);
75  res.n_count += n_count;
76 #endif
77  }
78 
79  END_CODE();
80 
81  return res;
82  }
83 
84 
85  private:
86  // Hide default constructor
88 
91  };
92 
93 } // End namespace
94 
95 #endif
96 
Class for counted reference semantics.
Definition: handle.h:33
Solve a M*psi=chi linear system by CG2.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
const Subset & subset() const
Return the subset on which the operator acts.
~LinOpSysSolverCGTiming()
Destructor is automatic.
Handle< LinearOperator< T > > A
LinOpSysSolverCGTiming(Handle< LinearOperator< T > > A_, const SysSolverCGParams &invParam_)
Constructor.
SystemSolver disambiguator.
Linear Operator.
Definition: linearop.h:27
SystemSolverResults_t InvCG2_timings(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, LatticeFermion &psi, int MaxCG)
Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Class for counted reference semantics.
Conjugate-Gradient algorithm for a generic Linear Operator.
Linear Operators.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int n_count
Definition: invbicg.cc:78
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Params for CG inverter.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.
Solve a CG1 system.
Disambiguator for LinOp system solvers.