Grid 0.7.0
DomainWallVec5dImpl.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/fermion/FermionOperatorImpl.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#pragma once
30
32
33template<class S,class Representation = FundamentalRepresentation, class Options=CoeffReal>
34class DomainWallVec5dImpl : public PeriodicGaugeImpl< GaugeImplTypes< S,Representation::Dimension> > {
35public:
36
39
40 static const int Dimension = Representation::Dimension;
41 static const bool isFundamental = Representation::isFundamental;
42 static const bool LsVectorised=true;
43 static const int Nhcs = Options::Nhcs;
44
45 typedef typename Options::_Coeff_t Coeff_t;
46 typedef typename Options::template PrecisionMapper<Simd>::LowerPrecVector SimdL;
47
48 template <typename vtype> using iImplSpinor = iScalar<iVector<iVector<vtype, Dimension>, Ns> >;
49 template <typename vtype> using iImplPropagator = iScalar<iMatrix<iMatrix<vtype, Dimension>, Ns> >;
50 template <typename vtype> using iImplHalfSpinor = iScalar<iVector<iVector<vtype, Dimension>, Nhs> >;
53 template <typename vtype> using iImplGaugeField = iVector<iScalar<iMatrix<vtype, Dimension> >, Nd>;
54 template <typename vtype> using iImplGaugeLink = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
55
62
64 // Make the doubled gauge field a *scalar*
70
75
77
79
80 template <class ref>
81 static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
82 {
83 vsplat(reg, memory);
84 }
85
86 template<class _Spinor>
87 static accelerator_inline void multLink(_Spinor &phi, const SiteDoubledGaugeField &U,
88 const _Spinor &chi, int mu, StencilEntry *SE,
89 StencilView &St)
90 {
91#ifdef GPU_VEC
92 // Gauge link is scalarised
93 mult(&phi(), &U(mu), &chi());
94#else
95 SiteGaugeLink UU;
96 for (int i = 0; i < Dimension; i++) {
97 for (int j = 0; j < Dimension; j++) {
98 vsplat(UU()()(i, j), U(mu)()(i, j));
99 }
100 }
101 mult(&phi(), &UU(), &chi());
102#endif
103 }
104
105 inline void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &Uds,const GaugeField &Umu)
106 {
107 SiteScalarGaugeField ScalarUmu;
108 SiteDoubledGaugeField ScalarUds;
109
110 GaugeLinkField U(Umu.Grid());
111 GaugeField Uadj(Umu.Grid());
112 for (int mu = 0; mu < Nd; mu++) {
113 U = PeekIndex<LorentzIndex>(Umu, mu);
114 U = adj(Cshift(U, mu, -1));
115 PokeIndex<LorentzIndex>(Uadj, U, mu);
116 }
117
118 autoView(Umu_v,Umu,CpuRead);
119 autoView(Uadj_v,Uadj,CpuRead);
120 autoView(Uds_v,Uds,CpuWrite);
121 thread_for( lidx, GaugeGrid->lSites(), {
122 Coordinate lcoor;
123 GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor);
124
125 peekLocalSite(ScalarUmu, Umu_v, lcoor);
126 for (int mu = 0; mu < 4; mu++) ScalarUds(mu) = ScalarUmu(mu);
127
128 peekLocalSite(ScalarUmu, Uadj_v, lcoor);
129 for (int mu = 0; mu < 4; mu++) ScalarUds(mu + 4) = ScalarUmu(mu);
130
131 pokeLocalSite(ScalarUds, Uds_v, lcoor);
132 });
133 }
134
135 inline void InsertForce4D(GaugeField &mat, FermionField &Btilde,FermionField &A, int mu)
136 {
137 assert(0);
138 }
139
140 inline void outerProductImpl(PropagatorField &mat, const FermionField &Btilde, const FermionField &A){
141 assert(0);
142 }
143
144 inline void TraceSpinImpl(GaugeLinkField &mat, PropagatorField&P) {
145 assert(0);
146 }
147
148 inline void extractLinkField(std::vector<GaugeLinkField> &mat, DoubledGaugeField &Uds){
149 assert(0);
150 }
151
152
153 inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde, int mu) {
154
155 assert(0);
156 // Following lines to be revised after Peter's addition of half prec
157 // missing put lane...
158 /*
159 typedef decltype(traceIndex<SpinIndex>(outerProduct(Btilde[0], Atilde[0]))) result_type;
160 unsigned int LLs = Btilde.Grid()->_rdimensions[0];
161 conformable(Atilde.Grid(),Btilde.Grid());
162 GridBase* grid = mat.Grid();
163 GridBase* Bgrid = Btilde.Grid();
164 unsigned int dimU = grid->Nd();
165 unsigned int dimF = Bgrid->Nd();
166 GaugeLinkField tmp(grid);
167 tmp = Zero();
168
169 // FIXME
170 // Current implementation works, thread safe, probably suboptimal
171 // Passing through the local coordinate for grid transformation
172 // the force grid is in general very different from the Ls vectorized grid
173
174 for (int so = 0; so < grid->oSites(); so++) {
175 std::vector<typename result_type::scalar_object> vres(Bgrid->Nsimd());
176 std::vector<int> ocoor; grid->oCoorFromOindex(ocoor,so);
177 for (int si = 0; si < tmp.Grid()->iSites(); si++){
178 typename result_type::scalar_object scalar_object; scalar_object = Zero();
179 std::vector<int> local_coor;
180 std::vector<int> icoor; grid->iCoorFromIindex(icoor,si);
181 grid->InOutCoorToLocalCoor(ocoor, icoor, local_coor);
182 for (int s = 0; s < LLs; s++) {
183 std::vector<int> slocal_coor(dimF);
184 slocal_coor[0] = s;
185 for (int s4d = 1; s4d< dimF; s4d++) slocal_coor[s4d] = local_coor[s4d-1];
186 int sF = Bgrid->oIndexReduced(slocal_coor);
187 assert(sF < Bgrid->oSites());
188
189 extract(traceIndex<SpinIndex>(outerProduct(Btilde[sF], Atilde[sF])), vres);
190 // sum across the 5d dimension
191 for (auto v : vres) scalar_object += v;
192 }
193 tmp[so].putlane(scalar_object, si);
194 }
195 }
196 PokeIndex<LorentzIndex>(mat, tmp, mu);
197 */
198 }
199};
203
207
211
215
#define accelerator_inline
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
DomainWallVec5dImpl< vComplexD, FundamentalRepresentation, CoeffComplexHalfComms > ZDomainWallVec5dImplDF
DomainWallVec5dImpl< vComplex,FundamentalRepresentation, CoeffComplex > ZDomainWallVec5dImplR
DomainWallVec5dImpl< vComplexD, FundamentalRepresentation, CoeffComplex > ZDomainWallVec5dImplD
DomainWallVec5dImpl< vComplexD, FundamentalRepresentation, CoeffRealHalfComms > DomainWallVec5dImplDF
DomainWallVec5dImpl< vComplexD, FundamentalRepresentation, CoeffReal > DomainWallVec5dImplD
DomainWallVec5dImpl< vComplexF, FundamentalRepresentation, CoeffRealHalfComms > DomainWallVec5dImplFH
DomainWallVec5dImpl< vComplex,FundamentalRepresentation, CoeffReal > DomainWallVec5dImplR
DomainWallVec5dImpl< vComplex,FundamentalRepresentation, CoeffRealHalfComms > DomainWallVec5dImplRL
DomainWallVec5dImpl< vComplex,FundamentalRepresentation, CoeffComplexHalfComms > ZDomainWallVec5dImplRL
DomainWallVec5dImpl< vComplexF, FundamentalRepresentation, CoeffReal > DomainWallVec5dImplF
DomainWallVec5dImpl< vComplexF, FundamentalRepresentation, CoeffComplexHalfComms > ZDomainWallVec5dImplFH
DomainWallVec5dImpl< vComplexF, FundamentalRepresentation, CoeffComplex > ZDomainWallVec5dImplF
accelerator_inline void vsplat(Grid_simd2< S, V > &ret, ABtype a, ABtype b)
void mult(Lattice< obj1 > &ret, const Lattice< obj2 > &lhs, const Lattice< obj3 > &rhs)
void PokeIndex(Lattice< vobj > &lhs, const Lattice< decltype(peekIndex< Index >(vobj(), 0))> &rhs, int i)
auto PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< vobj > adj(const Lattice< vobj > &lhs)
#define autoView(l_v, l, mode)
@ CpuRead
@ CpuWrite
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nhs
Definition QCD.h:53
static constexpr int Ns
Definition QCD.h:51
static constexpr int Nd
Definition QCD.h:52
static constexpr int Nds
Definition QCD.h:54
#define thread_for(i, num,...)
Definition Threads.h:60
WilsonCompressorTemplate< HCS, HS, S, WilsonProjector > WilsonCompressor
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
WilsonImplParams ImplParams
iScalar< iVector< iVector< vtype, Dimension >, Nhcs > > iImplHalfCommSpinor
iImplGaugeField< typename Simd::scalar_type > SiteScalarGaugeField
PeriodicGaugeImpl< GaugeImplTypes< S, Representation::Dimension > > Gimpl
void TraceSpinImpl(GaugeLinkField &mat, PropagatorField &P)
Options::template PrecisionMapper< Simd >::LowerPrecVector SimdL
Options::_Coeff_t Coeff_t
DomainWallVec5dImpl(const ImplParams &p=ImplParams())
iImplHalfSpinor< Simd > SiteHalfSpinor
static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A, int mu)
static accelerator_inline void multLink(_Spinor &phi, const SiteDoubledGaugeField &U, const _Spinor &chi, int mu, StencilEntry *SE, StencilView &St)
iImplPropagator< Simd > SitePropagator
void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &Uds, const GaugeField &Umu)
iImplGaugeLink< typename Simd::scalar_type > SiteScalarGaugeLink
iImplSpinor< Simd > SiteSpinor
Lattice< SiteDoubledGaugeField > DoubledGaugeField
iImplDoubledGaugeField< typename Simd::scalar_type > SiteDoubledGaugeField
StencilImpl::View_type StencilView
void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde, int mu)
WilsonCompressor< SiteHalfCommSpinor, SiteHalfSpinor, SiteSpinor > Compressor
iScalar< iVector< iVector< vtype, Dimension >, Ns > > iImplSpinor
iScalar< iVector< iVector< vtype, Dimension >, Nhs > > iImplHalfSpinor
iImplHalfCommSpinor< SimdL > SiteHalfCommSpinor
iVector< iScalar< iMatrix< vtype, Dimension > >, Nds > iImplDoubledGaugeField
Lattice< SiteSpinor > FermionField
Lattice< SitePropagator > PropagatorField
WilsonStencil< SiteSpinor, SiteHalfSpinor, ImplParams > StencilImpl
iScalar< iMatrix< iMatrix< vtype, Dimension >, Ns > > iImplPropagator
iVector< iScalar< iMatrix< vtype, Dimension > >, Nd > iImplGaugeField
void extractLinkField(std::vector< GaugeLinkField > &mat, DoubledGaugeField &Uds)
iScalar< iScalar< iMatrix< vtype, Dimension > > > iImplGaugeLink
void outerProductImpl(PropagatorField &mat, const FermionField &Btilde, const FermionField &A)
int lSites(void) const