CHROMA
syssolver_linop_wilson_quda_multigrid_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \QUDA MULTIGRID Wilson solver.
3  */
4 // comment
9 #include "io/aniso_io.h"
10 
11 
12 #include "handle.h"
15 #include "meas/glue/mesplq.h"
16 // QUDA Headers
17 #include <quda.h>
18 // #include <util_quda.h>
19 
20 namespace Chroma
21 {
22  namespace LinOpSysSolverQUDAMULTIGRIDWilsonEnv
23  {
24 
25  //! Anonymous namespace
26  namespace
27  {
28  //! Name to be used
29  const std::string name("QUDA_MULTIGRID_WILSON_INVERTER");
30 
31  //! Local registration flag
32  bool registered = false;
33  }
34 
35 
36 
38  const std::string& path,
39  Handle< FermState< LatticeFermion, multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > > state,
40 
42  {
43  return new LinOpSysSolverQUDAMULTIGRIDWilson(A, state,SysSolverQUDAMULTIGRIDWilsonParams(xml_in, path));
44  }
45 
46  //! Register all the factories
47  bool registerAll()
48  {
49  bool success = true;
50  if (! registered)
51  {
53  registered = true;
54  }
55  return success;
56  }
57  }
58 
59  SystemSolverResults_t
60  LinOpSysSolverQUDAMULTIGRIDWilson::qudaInvert(const T& chi_s,
61  T& psi_s) const{
62 
63  SystemSolverResults_t ret;
64 
65 
66  T mod_chi;
67 
68  // Off parity part may contain junk.
69  // Not a problem with BiCGStab etc, where we use an operator defined only on
70  // one parity, but in MG we will use an operator defined on both parities.
71  // So I will explicitly zero the off parity, into a mod_chi to use as a source.
72 
73  mod_chi[rb[0]] = zero; // Zero odd parity
74  mod_chi[rb[1]] = chi_s;
75 
76  if( invParam.asymmetricP ) {
77 
78  // In this case Chroma and QUDA operators disagree by A_oo = (Mass Term)
79  // (or clover term in the case of clover). SO I need to rescale mod_chi
80 
81  Real diag_mass;
82  {
83  // auto is C++11 so I don't have to remember all the silly typenames
84  auto wlparams = invParam.WilsonParams;
85 
86  auto aniso = wlparams.anisoParam;
87 
88  Real ff = where(aniso.anisoP, Real(1) / aniso.xi_0, Real(1));
89  diag_mass = 1 + (Nd-1)*ff + wlparams.Mass;
90  }
91 
92  mod_chi[rb[1]] /= diag_mass;
93  }
94 
95  // Set pointers for QUDA
96 #ifndef BUILD_QUDA_DEVIFACE_SPINOR
97  void *spinorIn =(void *)&(mod_chi.elem(rb[1].start()).elem(0).elem(0).real());
98  void* spinorOut =(void *)&(psi_s.elem(rb[1].start()).elem(0).elem(0).real());
99 #else
100  // void* spinorIn = GetMemoryPtr( mod_chi.getId() );
101  // QDPIO::cout << "QUDA_MULTIGRID_QDPJIT spinor in = " << spinorIn << "\n";
102  // void* spinorOut = GetMemoryPtr( psi_s.getId() );
103  // QDPIO::cout << "QUDA_MULTIGRID_QDPJIT spinor out = " << spinorOut << "\n";
104  void* spinorIn;
105  void* spinorOut;
106  GetMemoryPtr2(spinorIn,spinorOut,mod_chi.getId(),psi_s.getId());
107 #endif
108 
109  // Do the solve here
110  StopWatch swatch1;
111  swatch1.reset();
112  swatch1.start();
113  invertQuda(spinorOut, spinorIn, (QudaInvertParam*)&quda_inv_param);
114  swatch1.stop();
115 
116 
117  QDPIO::cout << "QUDA_MULTIGRID_"<<solver_string<<"_WILSON_SOLVER: time="<< quda_inv_param.secs <<" s" ;
118  QDPIO::cout << "\tPerformance="<< quda_inv_param.gflops/quda_inv_param.secs<<" GFLOPS" ;
119  QDPIO::cout << "\tTotal Time (incl. load gauge)=" << swatch1.getTimeInSeconds() <<" s"<<std::endl;
120 
121  ret.n_count =quda_inv_param.iter;
122 
123  return ret;
124 
125  }
126 
127 
128 }
129 
Anisotropy parameters.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
static T & Instance()
Definition: singleton.h:432
Class for counted reference semantics.
Wilson Dslash linear operator.
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
const std::string name
Name to be used.
LinOpSystemSolver< LatticeFermion > * createFerm(XMLReader &xml_in, const std::string &path, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, Handle< LinearOperator< LatticeFermion > > A)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
A(A, psi, r, Ncb, PLUS)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
Periodic ferm state and a creator.
Register linop system solvers that solve M*psi=chi.
Factory for solving M*psi=chi where M is not hermitian or pos. def.
LatticeFermion T
Definition: t_clover.cc:11