1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 15:55:37 +00: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_1._grid);
conformable(_grid, q_in_2._grid); conformable(_grid, q_in_2._grid);
conformable(_grid, q_out._grid); conformable(_grid, q_out._grid);
PropagatorField tmp(_grid); PropagatorField tmp1(_grid), tmp2(_grid);
q_out = zero; q_out = zero;
// Forward, need q1(x + mu), q2(x) // Forward, need q1(x + mu), q2(x). Backward, need q1(x), q2(x + mu).
tmp = Cshift(q_in_1, mu, 1); // 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) parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
{ {
Kernels::ContractConservedCurrentSiteFwd(tmp, q_in_2, q_out, Umu, Kernels::ContractConservedCurrentSiteFwd(tmp1._odata[sU],
mu, sU, sU, sU, sU); q_in_2._odata[sU],
} q_out._odata[sU],
Umu, sU, mu);
// Backward, need q1(x), q2(x + mu) Kernels::ContractConservedCurrentSiteBwd(q_in_1._odata[sU],
tmp = Cshift(q_in_2, mu, 1); tmp2._odata[sU],
parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU) q_out._odata[sU],
{ Umu, sU, mu);
Kernels::ContractConservedCurrentSiteBwd(q_in_1, tmp, q_out, Umu,
mu, sU, sU, sU, sU);
} }
} }

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

View File

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

View File

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