1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-25 13:15:55 +01:00

restructure SeqConservedCurrent for DWF to need less memory

This commit is contained in:
Vera Guelpers 2018-02-14 10:45:18 +00:00
parent c6e1f64573
commit d55212c998

View File

@ -883,8 +883,7 @@ void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
{ {
conformable(q_in._grid, FermionGrid()); conformable(q_in._grid, FermionGrid());
conformable(q_in._grid, q_out._grid); conformable(q_in._grid, q_out._grid);
PropagatorField tmpFwd(FermionGrid()), tmpBwd(FermionGrid()), PropagatorField tmp(GaugeGrid()),tmp2(GaugeGrid());
tmp(FermionGrid());
Complex i(0.0, 1.0); Complex i(0.0, 1.0);
unsigned int tshift = (mu == Tp) ? 1 : 0; unsigned int tshift = (mu == Tp) ? 1 : 0;
unsigned int LLs = q_in._grid->_rdimensions[0]; unsigned int LLs = q_in._grid->_rdimensions[0];
@ -895,22 +894,17 @@ void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
LatticeCoordinate(coords, Tp); LatticeCoordinate(coords, Tp);
//QED: photon field is 4dim, but need a 5dim object to multiply to
// DWF PropagatorField
Lattice<iSinglet<Simd>> lattice_cmplx_5d(FermionGrid());
for (unsigned int s = 0; s < LLs; ++s) for (unsigned int s = 0; s < LLs; ++s)
{ {
InsertSlice(lattice_cmplx,lattice_cmplx_5d, s, 0); bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
} bool tadpole_sign = (curr_type == Current::Tadpole);
bool switch_sgn = tadpole_sign || axial_sign;
//forward direction: Need q(x + mu, s)*A(x)
// Need q(x + mu, s) and q(x - mu, s). 5D lattice so shift 4D coordinate mu ExtractSlice(tmp2, q_in, s, 0); //q(x,s)
// by one. tmp = Cshift(tmp2, mu, 1); //q(x+mu,s)
tmp = Cshift(q_in, mu + 1, 1); tmp2 = tmp*lattice_cmplx; //q(x+mu,s)*A(x)
tmpFwd = tmp*lattice_cmplx_5d;
tmp = lattice_cmplx_5d*q_in;
tmpBwd = Cshift(tmp, mu + 1, -1);
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU) parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{ {
@ -922,40 +916,36 @@ void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
if (timeSlices > 0) if (timeSlices > 0)
{ {
unsigned int sF = sU * LLs; unsigned int sF = sU * LLs + s;
for (unsigned int s = 0; s < LLs; ++s) Kernels::SeqConservedCurrentSiteFwd(tmp2._odata[sU],
{
bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
bool tadpole_sign = (curr_type == Current::Tadpole);
bool switch_sgn = tadpole_sign || axial_sign;
Kernels::SeqConservedCurrentSiteFwd(tmpFwd._odata[sF],
q_out._odata[sF], Umu, sU, q_out._odata[sF], Umu, sU,
mu, t_mask, switch_sgn); mu, t_mask, switch_sgn);
++sF;
}
} }
// Repeat for backward direction. }
t_mask = ((coords._odata[sU] >= (tmin + tshift)) &&
//backward direction: Need q(x - mu, s)*A(x-mu)
ExtractSlice(tmp2, q_in, s, 0); //q(x,s)
tmp = lattice_cmplx*tmp2; //q(x,s)*A(x)
tmp2 = Cshift(tmp, mu, -1); //q(x-mu,s)*A(x-mu,s)
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{
vInteger t_mask = ((coords._odata[sU] >= (tmin + tshift)) &&
(coords._odata[sU] <= (tmax + tshift))); (coords._odata[sU] <= (tmax + tshift)));
//if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3) //if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3)
unsigned int t0 = 0; unsigned int t0 = 0;
if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 )); if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 ));
timeSlices = Reduce(t_mask); Integer timeSlices = Reduce(t_mask);
if (timeSlices > 0) if (timeSlices > 0)
{ {
unsigned int sF = sU * LLs; unsigned int sF = sU * LLs + s;
for (unsigned int s = 0; s < LLs; ++s) Kernels::SeqConservedCurrentSiteBwd(tmp2._odata[sU],
{
bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
Kernels::SeqConservedCurrentSiteBwd(tmpBwd._odata[sF],
q_out._odata[sF], Umu, sU, q_out._odata[sF], Umu, sU,
mu, t_mask, axial_sign); mu, t_mask, axial_sign);
++sF;
} }
} }
} }