7 #if defined(CHROMA_USE_CG_DWF_LOWMEM)
10 #ifndef __prec_dwf_qprop_array_cg_dwf_lowmem_w_h__
11 #define __prec_dwf_qprop_array_cg_dwf_lowmem_w_h__
27 template<
typename SinglePrecSolver,
typename DoublePrecSolver >
28 class CGDWFQpropT :
public SystemSolverArray<LatticeFermion>
32 typedef LatticeFermion
T;
33 typedef multi1d<LatticeColorMatrix>
P;
34 typedef multi1d<LatticeColorMatrix>
Q;
41 CGDWFQpropT(Handle< EvenOddPrecConstDetLinearOperatorArray<T,P,Q> > A_,
42 Handle< LinOpSystemSolverArray<T> > invA_,
43 Handle< FermState<T,P,Q> > state_,
44 const Real& OverMass_,
46 const AnisoParam_t& anisoParam_,
47 const GroupXML_t& invParam_) :
50 {
init(state_, invParam_);}
56 int size()
const {
return N5;}
59 const Subset&
subset()
const {
return all;}
67 SystemSolverResults_t
operator() (multi1d<LatticeFermion>&
psi,
const multi1d<LatticeFermion>&
chi)
const
70 QDPIO::cout <<
"entering CGDWFQpropT::operator()" << std::endl;
74 SystemSolverResults_t res;
83 double m_f = toDouble(
Mass);
89 StopWatch swatch, swatch_total, swatch_solver;
91 #ifdef SINGLE_PREC_SOLVER
96 swatch_total.reset(); swatch_solver.reset();
102 QDPIO::cout <<
"CGDWFQpropT: Initializing Single Precision Solver " << std::endl;
103 swatch.reset(); swatch.start();
104 int stat = single_prec_solver.init(lattice_size.slice(), NULL, NULL);
107 QDPIO::cerr << __func__ <<
": error in SP solver init: " << dwf_error_str <<
" error code is " << stat << std::endl;
111 QDPIO::cout <<
"CGDWFQpropT: Single Prec Solver init took: " << swatch.getTimeInSeconds() <<
" seconds " << std::endl;
114 swatch.reset(); swatch.start();
115 single_prec_solver.loadGauge(&
u, &v);
117 QDPIO::cout <<
"CGDWFQpropT: Single Precision Gauge Field Import took: " << swatch.getTimeInSeconds() <<
" seconds " << std::endl;
121 QDPIO::cout <<
"CGDWFQpropT: Beginning Single Precision Solve" << std::endl;
122 swatch_solver.start();
123 single_prec_solver.cgSolver(
psi, M5, m_f,
125 swatch_solver.stop();
127 QDPIO::cout <<
"CGDWFQpropT: Deleting Single Precision Solver Gauge Field " << std::endl;
128 single_prec_solver.deleteGauge();
130 QDPIO::cout <<
"CGDWFQPropT: Finalizing Single Precision Solver " << std::endl;
132 single_prec_solver.fini();
134 double tot_time = swatch_total.getTimeInSeconds();
135 double sol_time = swatch_solver.getTimeInSeconds();
137 QDPIO::cout <<
"CGDWFQPropT: Total solution time: " << tot_time <<
" Time in Single Prec Solver: " << sol_time <<
" Single Prec Overhead: " << 100.0*(tot_time-sol_time)/sol_time <<
"%" << std::endl;
139 res.n_count += single_count;
142 #ifdef DOUBLE_PREC_SOLVER
146 double rsd_sq = rsd * rsd;
149 swatch_total.reset(); swatch_solver.reset();
150 swatch_total.start();
155 QDPIO::cout <<
"CGDWFQpropT: Initializing Double Precision Solver " << std::endl;
156 swatch.reset(); swatch.start();
157 int stat2 = double_prec_solver.init(lattice_size.slice(), NULL, NULL);
159 QDPIO::cerr << __func__ <<
": error in DP solver init: " << dwf_error_str2 <<
" error code is " << stat2 << std::endl;
163 QDPIO::cout <<
"CGDWFQpropT: Double Prec Solver init took: " << swatch.getTimeInSeconds() <<
" seconds " << std::endl;
166 swatch.reset(); swatch.start();
167 double_prec_solver.loadGauge(&
u, &v);
169 QDPIO::cout <<
"Double Precision Gauge Field Import took: " << swatch.getTimeInSeconds() <<
" seconds " << std::endl;
172 QDPIO::cout <<
"CGDWFQpropT: Beginning Double Precision Solve" << std::endl;
173 swatch_solver.start();
174 double_prec_solver.cgSolver(
psi, M5, m_f,
176 swatch_solver.stop();
179 double_prec_solver.deleteGauge();
182 double_prec_solver.fini();
184 double tot_time = swatch_total.getTimeInSeconds();
185 double sol_time = swatch_solver.getTimeInSeconds();
187 QDPIO::cout <<
"CGDWFQPropT: Total solution time: " << tot_time <<
" Time in Double Prec Solver: " << sol_time <<
" Double Prec Overhead: " << 100.0*(tot_time-sol_time)/sol_time <<
"%" << std::endl;
190 res.n_count += double_count;
193 QDPIO::cout <<
"CGDWFQpropT: Single Prec. Iters = " << single_count <<
" Double Prec. Iters = " << double_count <<
" Total Iters = " << res.n_count << std::endl;
196 multi1d<LatticeFermion>
r(
N5);
199 res.resid = sqrt(norm2(
r));
202 QDPIO::cout <<
"exiting CGDWFQpropT::operator()" << std::endl;
211 void init(Handle< FermState<T,P,Q> >
state,
const GroupXML_t& inv)
213 QDPIO::cout <<
"entering CGDWFQpropT::init" << std::endl;
215 if (
Nd != 4 || Nc != 3) {
217 QDPIO::cerr <<
"CGDWFQpropT: only supports Nd=4 and Nc=3" << std::endl;
225 std::istringstream is(inv.xml);
226 XMLReader paramtop(is);
232 QDPIO::cerr <<
"CGDWFQpropT: only support a CG inverter" << std::endl;
236 lattice_size.resize(
Nd+1);
237 lattice_size[
Nd] =
N5;
239 for(
int i=0;
i <
Nd; ++
i)
240 lattice_size[
i] = Layout::lattSize()[
i];
244 QDPIO::cerr <<
"SSE qpropT only N5 that is multiple of 2" << std::endl;
256 for(
int mu=0;
mu <
u.size(); ++
mu) {
265 for (
int i = 0;
i <
Nd;
i++)
266 v[
i] = shift(
u[
i], -1,
i);
268 QDPIO::cout <<
"exiting CGDWFQpropT::init" << std::endl;
273 QDPIO::cout <<
"CGDWFQpropT: calling destructor" << std::endl;
277 #ifdef SINGLE_PREC_SOLVER
278 mutable SinglePrecSolver single_prec_solver;
281 #ifdef DOUBLE_PREC_SOLVER
282 mutable DoublePrecSolver double_prec_solver;
285 Handle< EvenOddPrecConstDetLinearOperatorArray<T,P,Q> >
A;
291 multi1d<int> lattice_size;
292 multi1d<LatticeColorMatrix>
u;
293 multi1d<LatticeColorMatrix> v;
multi1d< LatticeColorMatrix > P
SystemSolverResults_t operator()(multi1d< LatticeFermion > &psi, const multi1d< LatticeFermion > &chi) const
Solver the linear system.
multi1d< LatticeColorMatrix > Q
SysSolverCGParams invParam
void fini()
Private internal destructor.
int size() const
Expected length of array index.
const Subset & subset() const
Return the subset on which the operator acts.
CGDWFQpropT(Handle< EvenOddPrecConstDetLinearOperatorArray< T, P, Q > > A_, Handle< LinOpSystemSolverArray< T > > invA_, Handle< FermState< T, P, Q > > state_, const Real &OverMass_, const Real &Mass_, const AnisoParam_t &anisoParam_, const GroupXML_t &invParam_)
Alternative constructor for compatibility.
~CGDWFQpropT()
Need a real destructor.
void init(Handle< FermState< T, P, Q > > state, const GroupXML_t &inv)
Private internal initializer.
Handle< EvenOddPrecConstDetLinearOperatorArray< T, P, Q > > A
Even-odd const determinant Wilson-like fermact.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams ¶m)
Read parameters.
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
multi1d< LatticeFermion > chi(Ncb)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state