1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 17:25:37 +01:00

Code cleaning for conserved current contractions. Will now be easier to implement mobius conserved current.

This commit is contained in:
Lanny91 2017-06-16 16:38:59 +01:00
parent 5633a2db20
commit 41af8c12d7
4 changed files with 64 additions and 96 deletions

View File

@ -361,23 +361,23 @@ void WilsonFermion<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
conformable(_grid, q_in_1._grid);
conformable(_grid, q_in_2._grid);
conformable(_grid, q_out._grid);
PropagatorField tmp(_grid);
PropagatorField tmp1(_grid), tmp2(_grid);
q_out = zero;
// Forward, need q1(x + mu), q2(x)
tmp = Cshift(q_in_1, mu, 1);
// Forward, need q1(x + mu), q2(x). Backward, need q1(x), q2(x + mu).
// Inefficient comms method but not performance critical.
tmp1 = Cshift(q_in_1, mu, 1);
tmp2 = Cshift(q_in_2, mu, 1);
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{
Kernels::ContractConservedCurrentSiteFwd(tmp, q_in_2, q_out, Umu,
mu, sU, sU, sU, sU);
}
// Backward, need q1(x), q2(x + mu)
tmp = Cshift(q_in_2, mu, 1);
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{
Kernels::ContractConservedCurrentSiteBwd(q_in_1, tmp, q_out, Umu,
mu, sU, sU, sU, sU);
Kernels::ContractConservedCurrentSiteFwd(tmp1._odata[sU],
q_in_2._odata[sU],
q_out._odata[sU],
Umu, sU, mu);
Kernels::ContractConservedCurrentSiteBwd(q_in_1._odata[sU],
tmp2._odata[sU],
q_out._odata[sU],
Umu, sU, mu);
}
}

View File

@ -686,13 +686,13 @@ void WilsonFermion5D<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
conformable(q_in_1._grid, FermionGrid());
conformable(q_in_1._grid, q_in_2._grid);
conformable(_FourDimGrid, q_out._grid);
PropagatorField tmp(FermionGrid());
PropagatorField tmp1(FermionGrid()), tmp2(FermionGrid());
q_out = zero;
// Forward, need q1(x + mu, s), q2(x, Ls - 1 - s). 5D lattice so shift
// 4D coordinate mu by one.
tmp = Cshift(q_in_1, mu + 1, 1);
// Forward, need q1(x + mu, s), q2(x, Ls - 1 - s). Backward, need q1(x, s),
// q2(x + mu, Ls - 1 - s). 5D lattice so shift 4D coordinate mu by one.
tmp1 = Cshift(q_in_1, mu + 1, 1);
tmp2 = Cshift(q_in_2, mu + 1, 1);
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{
unsigned int sF1 = sU * Ls;
@ -701,28 +701,14 @@ void WilsonFermion5D<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
{
bool axial_sign = ((curr_type == Current::Axial) && (s < (Ls / 2))) ? \
true : false;
Kernels::ContractConservedCurrentSiteFwd(tmp, q_in_2, q_out, Umu,
mu, sF1, sF2, sU, sU,
axial_sign);
sF1++;
sF2--;
}
}
// Backward, need q1(x, s), q2(x + mu, Ls - 1 - s). 5D lattice so shift
// 4D coordinate mu by one.
tmp = Cshift(q_in_2, mu + 1, 1);
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{
unsigned int sF1 = sU * Ls;
unsigned int sF2 = (sU + 1) * Ls - 1;
for (int s = 0; s < Ls; ++s)
{
bool axial_sign = ((curr_type == Current::Axial) && (s < (Ls / 2))) ? \
true : false;
Kernels::ContractConservedCurrentSiteBwd(q_in_1, tmp, q_out, Umu,
mu, sF1, sF2, sU, sU,
axial_sign);
Kernels::ContractConservedCurrentSiteFwd(tmp1._odata[sF1],
q_in_2._odata[sF2],
q_out._odata[sU],
Umu, sU, mu, axial_sign);
Kernels::ContractConservedCurrentSiteBwd(q_in_1._odata[sF1],
tmp2._odata[sF2],
q_out._odata[sU],
Umu, sU, mu, axial_sign);
sF1++;
sF2--;
}

View File

@ -298,28 +298,25 @@ void WilsonKernels<Impl>::DhopDir( StencilImpl &st, DoubledGaugeField &U,SiteHal
******************************************************************************/
template<class Impl>
void WilsonKernels<Impl>::ContractConservedCurrentSiteFwd(
const PropagatorField &q_in_1,
const PropagatorField &q_in_2,
PropagatorField &q_out,
const SitePropagator &q_in_1,
const SitePropagator &q_in_2,
SitePropagator &q_out,
DoubledGaugeField &U,
unsigned int mu,
unsigned int sF_in_1,
unsigned int sF_in_2,
unsigned int sF_out,
unsigned int sU,
unsigned int mu,
bool switch_sign)
{
SitePropagator result, tmp;
Gamma g5(Gamma::Algebra::Gamma5);
multLinkProp(tmp, U._odata[sU], q_in_1._odata[sF_in_1], mu);
result = g5 * adj(q_in_2._odata[sF_in_2]) * g5 * WilsonCurrentFwd(tmp, mu);
Impl::multLinkProp(tmp, U._odata[sU], q_in_1, mu);
result = g5 * adj(q_in_2) * g5 * WilsonCurrentFwd(tmp, mu);
if (switch_sign)
{
q_out._odata[sF_out] -= result;
q_out -= result;
}
else
{
q_out._odata[sF_out] += result;
q_out += result;
}
}
@ -331,28 +328,25 @@ void WilsonKernels<Impl>::ContractConservedCurrentSiteFwd(
******************************************************************************/
template<class Impl>
void WilsonKernels<Impl>::ContractConservedCurrentSiteBwd(
const PropagatorField &q_in_1,
const PropagatorField &q_in_2,
PropagatorField &q_out,
const SitePropagator &q_in_1,
const SitePropagator &q_in_2,
SitePropagator &q_out,
DoubledGaugeField &U,
unsigned int mu,
unsigned int sF_in_1,
unsigned int sF_in_2,
unsigned int sF_out,
unsigned int sU,
unsigned int mu,
bool switch_sign)
{
SitePropagator result, tmp;
Gamma g5(Gamma::Algebra::Gamma5);
multLinkProp(tmp, U._odata[sU], q_in_1._odata[sF_in_1], mu + Nd);
result = g5 * adj(q_in_2._odata[sF_in_2]) * g5 * WilsonCurrentBwd(tmp, mu);
Impl::multLinkProp(tmp, U._odata[sU], q_in_1, mu + Nd);
result = g5 * adj(q_in_2) * g5 * WilsonCurrentBwd(tmp, mu);
if (switch_sign)
{
q_out._odata[sF_out] += result;
q_out += result;
}
else
{
q_out._odata[sF_out] -= result;
q_out -= result;
}
}
@ -360,31 +354,25 @@ void WilsonKernels<Impl>::ContractConservedCurrentSiteBwd(
#define NO_CURR_SITE(Impl) \
template <> \
void WilsonKernels<Impl>::ContractConservedCurrentSiteFwd( \
const PropagatorField &q_in_1, \
const PropagatorField &q_in_2, \
PropagatorField &q_out, \
DoubledGaugeField &U, \
unsigned int mu, \
unsigned int sF_in_1, \
unsigned int sF_in_2, \
unsigned int sF_out, \
unsigned int sU, \
bool switch_sign) \
const SitePropagator &q_in_1, \
const SitePropagator &q_in_2, \
SitePropagator &q_out, \
DoubledGaugeField &U, \
unsigned int sU, \
unsigned int mu, \
bool switch_sign) \
{ \
assert(0); \
} \
template <> \
void WilsonKernels<Impl>::ContractConservedCurrentSiteBwd( \
const PropagatorField &q_in_1, \
const PropagatorField &q_in_2, \
PropagatorField &q_out, \
DoubledGaugeField &U, \
unsigned int mu, \
unsigned int sF_in_1, \
unsigned int sF_in_2, \
unsigned int sF_out, \
unsigned int sU, \
bool switch_sign) \
const SitePropagator &q_in_1, \
const SitePropagator &q_in_2, \
SitePropagator &q_out, \
DoubledGaugeField &U, \
unsigned int mu, \
unsigned int sU, \
bool switch_sign) \
{ \
assert(0); \
}

View File

@ -183,25 +183,19 @@ public:
//////////////////////////////////////////////////////////////////////////////
// Utilities for inserting Wilson conserved current.
//////////////////////////////////////////////////////////////////////////////
void ContractConservedCurrentSiteFwd(const PropagatorField &q_in_1,
const PropagatorField &q_in_2,
PropagatorField &q_out,
void ContractConservedCurrentSiteFwd(const SitePropagator &q_in_1,
const SitePropagator &q_in_2,
SitePropagator &q_out,
DoubledGaugeField &U,
unsigned int mu,
unsigned int sF_in_1,
unsigned int sF_in_2,
unsigned int sF_out,
unsigned int sU,
unsigned int mu,
bool switch_sign = false);
void ContractConservedCurrentSiteBwd(const PropagatorField &q_in_1,
const PropagatorField &q_in_2,
PropagatorField &q_out,
void ContractConservedCurrentSiteBwd(const SitePropagator &q_in_1,
const SitePropagator &q_in_2,
SitePropagator &q_out,
DoubledGaugeField &U,
unsigned int mu,
unsigned int sF_in_1,
unsigned int sF_in_2,
unsigned int sF_out,
unsigned int sU,
unsigned int mu,
bool switch_sign = false);
void SeqConservedCurrentInternal(const PropagatorField &q_in,
PropagatorField &q_out,