Grid 0.7.0
GeneralEvenOddRationalRatioMixedPrec.h
Go to the documentation of this file.
1 /*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/qcd/action/pseudofermion/GeneralEvenOddRationalRatioMixedPrec.h
6
7 Copyright (C) 2015
8
9 Author: Christopher Kelly <ckelly@bnl.gov>
10 Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 See the full license in the file "LICENSE" in the top level distribution directory
27 *************************************************************************************/
28 /* END LEGAL */
29#ifndef QCD_PSEUDOFERMION_GENERAL_EVEN_ODD_RATIONAL_RATIO_MIXED_PREC_H
30#define QCD_PSEUDOFERMION_GENERAL_EVEN_ODD_RATIONAL_RATIO_MIXED_PREC_H
31
33
35
37 // Generic rational approximation for ratios of operators utilizing the mixed precision multishift algorithm
38 // cf. GeneralEvenOddRational.h for details
40
41 template<class ImplD, class ImplF>
43 private:
44 typedef typename ImplD::FermionField FermionFieldD;
45 typedef typename ImplF::FermionField FermionFieldF;
46
49
52
54 protected:
55
56 //Action evaluation
57 //Allow derived classes to override the multishift CG
58 virtual void multiShiftInverse(bool numerator, const MultiShiftFunction &approx, const Integer MaxIter, const FermionFieldD &in, FermionFieldD &out){
59#if 1
62 msCG(schurOp,in, out);
63#else
64 SchurDifferentiableOperator<ImplD> schurOpD(numerator ? NumOpD : DenOpD);
65 SchurDifferentiableOperator<ImplF> schurOpF(numerator ? NumOpF : DenOpF);
66 FermionFieldD inD(NumOpD.FermionRedBlackGrid());
67 FermionFieldD outD(NumOpD.FermionRedBlackGrid());
68
69 // Action better with higher precision?
70 ConjugateGradientMultiShiftMixedPrec<FermionFieldD, FermionFieldF> msCG(MaxIter, approx, NumOpF.FermionRedBlackGrid(), schurOpF, ReliableUpdateFreq);
71 msCG(schurOpD, in, out);
72#endif
73 }
74 //Force evaluation
75 virtual void multiShiftInverse(bool numerator, const MultiShiftFunction &approx, const Integer MaxIter, const FermionFieldD &in, std::vector<FermionFieldD> &out_elems, FermionFieldD &out){
76 SchurDifferentiableOperator<ImplD> schurOpD(numerator ? NumOpD : DenOpD);
77 SchurDifferentiableOperator<ImplF> schurOpF(numerator ? NumOpF : DenOpF);
78
79 FermionFieldD inD(NumOpD.FermionRedBlackGrid());
80 FermionFieldD outD(NumOpD.FermionRedBlackGrid());
81 std::vector<FermionFieldD> out_elemsD(out_elems.size(),NumOpD.FermionRedBlackGrid());
83 msCG(schurOpD, in, out_elems, out);
84 }
85 //Allow derived classes to override the gauge import
86 virtual void ImportGauge(const typename ImplD::GaugeField &Ud){
87
88 typename ImplF::GaugeField Uf(NumOpF.GaugeGrid());
89 precisionChange(Uf, Ud);
90
91 std::cout << "Importing "<<norm2(Ud)<<" "<< norm2(Uf)<<" " <<std::endl;
92
93 NumOpD.ImportGauge(Ud);
94 DenOpD.ImportGauge(Ud);
95
96 NumOpF.ImportGauge(Uf);
97 DenOpF.ImportGauge(Uf);
98 }
99
100 public:
103 const RationalActionParams & p, Integer _ReliableUpdateFreq
104 ) : GeneralEvenOddRatioRationalPseudoFermionAction<ImplD>(_NumOpD, _DenOpD, p),
105 ReliableUpdateFreq(_ReliableUpdateFreq),
106 NumOpD(_NumOpD), DenOpD(_DenOpD),
107 NumOpF(_NumOpF), DenOpF(_DenOpF)
108 {}
109
110 virtual std::string action_name(){return "GeneralEvenOddRatioRationalMixedPrecPseudoFermionAction";}
111 };
112
114
115#endif
RealD norm2(const Lattice< vobj > &arg)
void precisionChange(Lattice< VobjOut > &out, const Lattice< VobjIn > &in, const precisionChangeWorkspace &workspace)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
uint32_t Integer
Definition Simd.h:58
virtual std::string action_name()
Report the name of the action.
virtual void multiShiftInverse(bool numerator, const MultiShiftFunction &approx, const Integer MaxIter, const FermionFieldD &in, FermionFieldD &out)
GeneralEvenOddRatioRationalMixedPrecPseudoFermionAction(FermionOperator< ImplD > &_NumOpD, FermionOperator< ImplD > &_DenOpD, FermionOperator< ImplF > &_NumOpF, FermionOperator< ImplF > &_DenOpF, const RationalActionParams &p, Integer _ReliableUpdateFreq)
virtual void multiShiftInverse(bool numerator, const MultiShiftFunction &approx, const Integer MaxIter, const FermionFieldD &in, std::vector< FermionFieldD > &out_elems, FermionFieldD &out)
virtual void ImportGauge(const typename ImplD::GaugeField &Ud)
GeneralEvenOddRatioRationalPseudoFermionAction(FermionOperator< ImplD > &_NumOp, FermionOperator< ImplD > &_DenOp, const Params &p)