30#ifndef GRID_BICGSTAB_MIXED_PREC_H
31#define GRID_BICGSTAB_MIXED_PREC_H
36template<class FieldD, class FieldF, typename std::enable_if< getPrecision<FieldD>::value == 2,
int>
::type = 0,
typename std::enable_if< getPrecision<FieldF>::value == 1,
int>
::type = 0>
73 int cb = src_d_in.Checkerboard();
74 sol_d.Checkerboard() = cb;
79 GridBase* DoublePrecGrid = src_d_in.Grid();
80 FieldD tmp_d(DoublePrecGrid);
81 tmp_d.Checkerboard() = cb;
83 FieldD tmp2_d(DoublePrecGrid);
84 tmp2_d.Checkerboard() = cb;
86 FieldD src_d(DoublePrecGrid);
92 src_f.Checkerboard() = cb;
95 sol_f.Checkerboard() = cb;
112 std::cout <<
GridLogMessage <<
"MixedPrecisionBiCGSTAB: Outer iteration " << outer_iter <<
" residual " << norm <<
" target " << stop << std::endl;
115 std::cout <<
GridLogMessage <<
"MixedPrecisionBiCGSTAB: Outer iteration converged on iteration " << outer_iter << std::endl;
118 while(norm * inner_tol * inner_tol < stop){ inner_tol *= 2; }
120 PrecChangeTimer.
Start();
122 PrecChangeTimer.
Stop();
127 if(
guesser != NULL){ (*guesser)(src_f, sol_f); }
131 InnerCGtimer.
Start();
137 PrecChangeTimer.
Start();
139 PrecChangeTimer.
Stop();
141 axpy(sol_d, 1.0, tmp_d, sol_d);
145 std::cout <<
GridLogMessage <<
"MixedPrecisionBiCGSTAB: Starting final patch-up double-precision solve" << std::endl;
148 CG_d(
Linop_d, src_d_in, sol_d);
153 std::cout <<
GridLogMessage <<
"MixedPrecisionBiCGSTAB: Total time " << TotalTimer.
Elapsed() <<
" Precision change " << PrecChangeTimer.
Elapsed() <<
" Inner CG total " << InnerCGtimer.
Elapsed() << std::endl;
RealD axpy_norm(Lattice< vobj > &ret, sobj a, const Lattice< vobj > &x, const Lattice< vobj > &y)
void axpy(Lattice< vobj > &ret, sobj a, const Lattice< vobj > &x, const Lattice< vobj > &y)
RealD norm2(const Lattice< vobj > &arg)
void precisionChange(Lattice< VobjOut > &out, const Lattice< VobjIn > &in, const precisionChangeWorkspace &workspace)
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Integer IterationsToComplete
GridTime Elapsed(void) const
GridBase * SinglePrecGrid
LinearFunction< FieldF > * guesser
Integer TotalFinalStepIterations
Integer TotalOuterIterations
Integer TotalInnerIterations
void operator()(const FieldD &src_d_in, FieldD &sol_d)
Integer MaxInnerIterations
LinearOperatorBase< FieldD > & Linop_d
LinearOperatorBase< FieldF > & Linop_f
Integer MaxOuterIterations
void useGuesser(LinearFunction< FieldF > &g)
MixedPrecisionBiCGSTAB(RealD tol, Integer maxinnerit, Integer maxouterit, GridBase *_sp_grid, LinearOperatorBase< FieldF > &_Linop_f, LinearOperatorBase< FieldD > &_Linop_d)