mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	Updating the feature/clover branch with the newest Hadron package
This commit is contained in:
		@@ -47,6 +47,7 @@ namespace Grid {
 | 
			
		||||
      INHERIT_IMPL_TYPES(Impl);
 | 
			
		||||
 | 
			
		||||
      FermionOperator(const ImplParams &p= ImplParams()) : Impl(p) {};
 | 
			
		||||
      virtual ~FermionOperator(void) = default;
 | 
			
		||||
 | 
			
		||||
      virtual FermionField &tmp(void) = 0;
 | 
			
		||||
 | 
			
		||||
@@ -112,6 +113,21 @@ namespace Grid {
 | 
			
		||||
      ///////////////////////////////////////////////
 | 
			
		||||
      virtual void ImportGauge(const GaugeField & _U)=0;
 | 
			
		||||
 | 
			
		||||
      //////////////////////////////////////////////////////////////////////
 | 
			
		||||
      // Conserved currents, either contract at sink or insert sequentially.
 | 
			
		||||
      //////////////////////////////////////////////////////////////////////
 | 
			
		||||
      virtual void ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                            PropagatorField &q_in_2,
 | 
			
		||||
                                            PropagatorField &q_out,
 | 
			
		||||
                                            Current curr_type,
 | 
			
		||||
                                            unsigned int mu)=0;
 | 
			
		||||
      virtual void SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
                                       PropagatorField &q_out,
 | 
			
		||||
                                       Current curr_type,
 | 
			
		||||
                                       unsigned int mu,
 | 
			
		||||
                                       std::vector<Real> mom,
 | 
			
		||||
                                       unsigned int tmin, 
 | 
			
		||||
                                       unsigned int tmax)=0;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -212,6 +212,13 @@ namespace QCD {
 | 
			
		||||
                         StencilImpl &St) {
 | 
			
		||||
      mult(&phi(), &U(mu), &chi());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    inline void multLinkProp(SitePropagator &phi,
 | 
			
		||||
                             const SiteDoubledGaugeField &U,
 | 
			
		||||
                             const SitePropagator &chi,
 | 
			
		||||
                             int mu) {
 | 
			
		||||
       mult(&phi(), &U(mu), &chi());
 | 
			
		||||
    }
 | 
			
		||||
      
 | 
			
		||||
    template <class ref>
 | 
			
		||||
    inline void loadLinkElement(Simd ®, ref &memory) {
 | 
			
		||||
@@ -354,7 +361,20 @@ class DomainWallVec5dImpl :  public PeriodicGaugeImpl< GaugeImplTypes< S,Nrepres
 | 
			
		||||
    }
 | 
			
		||||
    mult(&phi(), &UU(), &chi());
 | 
			
		||||
  }
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
  inline void multLinkProp(SitePropagator &phi,
 | 
			
		||||
                           const SiteDoubledGaugeField &U,
 | 
			
		||||
                           const SitePropagator &chi,
 | 
			
		||||
                           int mu) {
 | 
			
		||||
    SiteGaugeLink UU;
 | 
			
		||||
    for (int i = 0; i < Nrepresentation; i++) {
 | 
			
		||||
      for (int j = 0; j < Nrepresentation; j++) {
 | 
			
		||||
        vsplat(UU()()(i, j), U(mu)()(i, j));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    mult(&phi(), &UU(), &chi());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  inline void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &Uds,const GaugeField &Umu) 
 | 
			
		||||
  {
 | 
			
		||||
    SiteScalarGaugeField  ScalarUmu;
 | 
			
		||||
@@ -564,7 +584,12 @@ class GparityWilsonImpl : public ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresent
 | 
			
		||||
   }
 | 
			
		||||
   
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
    // Fixme: Gparity prop * link
 | 
			
		||||
    inline void multLinkProp(SitePropagator &phi, const SiteDoubledGaugeField &U,
 | 
			
		||||
                             const SitePropagator &chi, int mu)
 | 
			
		||||
    {
 | 
			
		||||
        assert(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 template <class ref>
 | 
			
		||||
 inline void loadLinkElement(Simd ®, ref &memory) {
 | 
			
		||||
 
 | 
			
		||||
@@ -393,6 +393,31 @@ void ImprovedStaggeredFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////////// 
 | 
			
		||||
// Conserved current - not yet implemented.
 | 
			
		||||
////////////////////////////////////////////////////////
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void ImprovedStaggeredFermion<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                                        PropagatorField &q_in_2,
 | 
			
		||||
                                                        PropagatorField &q_out,
 | 
			
		||||
                                                        Current curr_type,
 | 
			
		||||
                                                        unsigned int mu)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void ImprovedStaggeredFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                                                         PropagatorField &q_out,
 | 
			
		||||
                                                         Current curr_type,
 | 
			
		||||
                                                         unsigned int mu, 
 | 
			
		||||
                                                         std::vector<Real> mom,
 | 
			
		||||
                                                         unsigned int tmin,
 | 
			
		||||
                                                         unsigned int tmax)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FermOpStaggeredTemplateInstantiate(ImprovedStaggeredFermion);
 | 
			
		||||
 | 
			
		||||
  //AdjointFermOpTemplateInstantiate(ImprovedStaggeredFermion);
 | 
			
		||||
 
 | 
			
		||||
@@ -157,6 +157,22 @@ class ImprovedStaggeredFermion : public StaggeredKernels<Impl>, public ImprovedS
 | 
			
		||||
 | 
			
		||||
  LebesgueOrder Lebesgue;
 | 
			
		||||
  LebesgueOrder LebesgueEvenOdd;
 | 
			
		||||
  
 | 
			
		||||
  ///////////////////////////////////////////////////////////////
 | 
			
		||||
  // Conserved current utilities
 | 
			
		||||
  ///////////////////////////////////////////////////////////////
 | 
			
		||||
  void ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                PropagatorField &q_in_2,
 | 
			
		||||
                                PropagatorField &q_out,
 | 
			
		||||
                                Current curr_type,
 | 
			
		||||
                                unsigned int mu);
 | 
			
		||||
  void SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                           PropagatorField &q_out,
 | 
			
		||||
                           Current curr_type,
 | 
			
		||||
                           unsigned int mu, 
 | 
			
		||||
                           std::vector<Real> mom,
 | 
			
		||||
                           unsigned int tmin,
 | 
			
		||||
                           unsigned int tmax);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef ImprovedStaggeredFermion<StaggeredImplF> ImprovedStaggeredFermionF;
 | 
			
		||||
 
 | 
			
		||||
@@ -405,6 +405,30 @@ void ImprovedStaggeredFermion5D<Impl>::MooeeInvDag(const FermionField &in,
 | 
			
		||||
  MooeeInv(in, out);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////////// 
 | 
			
		||||
// Conserved current - not yet implemented.
 | 
			
		||||
////////////////////////////////////////////////////////
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void ImprovedStaggeredFermion5D<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                                         PropagatorField &q_in_2,
 | 
			
		||||
                                                         PropagatorField &q_out,
 | 
			
		||||
                                                         Current curr_type,
 | 
			
		||||
                                                         unsigned int mu)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void ImprovedStaggeredFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                                                          PropagatorField &q_out,
 | 
			
		||||
                                                          Current curr_type,
 | 
			
		||||
                                                          unsigned int mu, 
 | 
			
		||||
                                                          std::vector<Real> mom,
 | 
			
		||||
                                                          unsigned int tmin,
 | 
			
		||||
                                                          unsigned int tmax)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FermOpStaggeredTemplateInstantiate(ImprovedStaggeredFermion5D);
 | 
			
		||||
FermOpStaggeredVec5dTemplateInstantiate(ImprovedStaggeredFermion5D);
 | 
			
		||||
 
 | 
			
		||||
@@ -170,6 +170,21 @@ namespace QCD {
 | 
			
		||||
    // Comms buffer
 | 
			
		||||
    std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> >  comm_buf;
 | 
			
		||||
    
 | 
			
		||||
    ///////////////////////////////////////////////////////////////
 | 
			
		||||
    // Conserved current utilities
 | 
			
		||||
    ///////////////////////////////////////////////////////////////
 | 
			
		||||
    void ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                  PropagatorField &q_in_2,
 | 
			
		||||
                                  PropagatorField &q_out,
 | 
			
		||||
                                  Current curr_type,
 | 
			
		||||
                                  unsigned int mu);
 | 
			
		||||
    void SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                             PropagatorField &q_out,
 | 
			
		||||
                             Current curr_type,
 | 
			
		||||
                             unsigned int mu, 
 | 
			
		||||
                             std::vector<Real> mom,
 | 
			
		||||
                             unsigned int tmin,
 | 
			
		||||
                             unsigned int tmax);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
 
 | 
			
		||||
@@ -265,7 +265,6 @@ public:
 | 
			
		||||
    if ( timer3 ) std::cout << GridLogMessage << " timer3 (commsMergeShm) " <<timer3/calls <<std::endl;
 | 
			
		||||
    if ( timer4 ) std::cout << GridLogMessage << " timer4 " <<timer4 <<std::endl;
 | 
			
		||||
  }
 | 
			
		||||
  typedef CartesianCommunicator::CommsRequest_t CommsRequest_t;
 | 
			
		||||
 | 
			
		||||
  std::vector<int> same_node;
 | 
			
		||||
  std::vector<int> surface_list;
 | 
			
		||||
 
 | 
			
		||||
@@ -371,6 +371,112 @@ void WilsonFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder &lo,
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Conserved current utilities for Wilson fermions, for contracting propagators
 | 
			
		||||
 * to make a conserved current sink or inserting the conserved current 
 | 
			
		||||
 * sequentially.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                                   PropagatorField &q_in_2,
 | 
			
		||||
                                                   PropagatorField &q_out,
 | 
			
		||||
                                                   Current curr_type,
 | 
			
		||||
                                                   unsigned int mu)
 | 
			
		||||
{
 | 
			
		||||
    Gamma g5(Gamma::Algebra::Gamma5);
 | 
			
		||||
    conformable(_grid, q_in_1._grid);
 | 
			
		||||
    conformable(_grid, q_in_2._grid);
 | 
			
		||||
    conformable(_grid, q_out._grid);
 | 
			
		||||
    PropagatorField tmp1(_grid), tmp2(_grid);
 | 
			
		||||
    q_out = zero;
 | 
			
		||||
 | 
			
		||||
    // 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(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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
                                              PropagatorField &q_out,
 | 
			
		||||
                                              Current curr_type,
 | 
			
		||||
                                              unsigned int mu,
 | 
			
		||||
                                              std::vector<Real> mom,
 | 
			
		||||
                                              unsigned int tmin, 
 | 
			
		||||
                                              unsigned int tmax)
 | 
			
		||||
{
 | 
			
		||||
    conformable(_grid, q_in._grid);
 | 
			
		||||
    conformable(_grid, q_out._grid);
 | 
			
		||||
    Lattice<iSinglet<Simd>> ph(_grid), coor(_grid);
 | 
			
		||||
    Complex i(0.0,1.0);
 | 
			
		||||
    PropagatorField tmpFwd(_grid), tmpBwd(_grid), tmp(_grid);
 | 
			
		||||
    unsigned int tshift = (mu == Tp) ? 1 : 0;
 | 
			
		||||
    unsigned int LLt    = GridDefaultLatt()[Tp];
 | 
			
		||||
 | 
			
		||||
    // Momentum projection
 | 
			
		||||
    ph = zero;
 | 
			
		||||
    for(unsigned int mu = 0; mu < Nd - 1; mu++)
 | 
			
		||||
    {
 | 
			
		||||
        LatticeCoordinate(coor, mu);
 | 
			
		||||
        ph = ph + mom[mu]*coor*((1./(_grid->_fdimensions[mu])));
 | 
			
		||||
    }
 | 
			
		||||
    ph = exp((Real)(2*M_PI)*i*ph);
 | 
			
		||||
 | 
			
		||||
    q_out = zero;
 | 
			
		||||
    LatticeInteger coords(_grid);
 | 
			
		||||
    LatticeCoordinate(coords, Tp);
 | 
			
		||||
 | 
			
		||||
    // Need q(x + mu) and q(x - mu).
 | 
			
		||||
    tmp = Cshift(q_in, mu, 1);
 | 
			
		||||
    tmpFwd = tmp*ph;
 | 
			
		||||
    tmp = ph*q_in;
 | 
			
		||||
    tmpBwd = Cshift(tmp, mu, -1);
 | 
			
		||||
 | 
			
		||||
    parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
 | 
			
		||||
    {
 | 
			
		||||
        // Compute the sequential conserved current insertion only if our simd
 | 
			
		||||
        // object contains a timeslice we need.
 | 
			
		||||
        vInteger t_mask   = ((coords._odata[sU] >= tmin) &&
 | 
			
		||||
                             (coords._odata[sU] <= tmax));
 | 
			
		||||
        Integer timeSlices = Reduce(t_mask);
 | 
			
		||||
 | 
			
		||||
        if (timeSlices > 0)
 | 
			
		||||
        {
 | 
			
		||||
            Kernels::SeqConservedCurrentSiteFwd(tmpFwd._odata[sU], 
 | 
			
		||||
                                                q_out._odata[sU], 
 | 
			
		||||
                                                Umu, sU, mu, t_mask);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Repeat for backward direction.
 | 
			
		||||
        t_mask     = ((coords._odata[sU] >= (tmin + tshift)) && 
 | 
			
		||||
                      (coords._odata[sU] <= (tmax + tshift)));
 | 
			
		||||
 | 
			
		||||
	//if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3)	
 | 
			
		||||
	unsigned int t0 = 0;
 | 
			
		||||
	if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 ));
 | 
			
		||||
 | 
			
		||||
        timeSlices = Reduce(t_mask);
 | 
			
		||||
 | 
			
		||||
        if (timeSlices > 0)
 | 
			
		||||
        {
 | 
			
		||||
            Kernels::SeqConservedCurrentSiteBwd(tmpBwd._odata[sU], 
 | 
			
		||||
                                                q_out._odata[sU], 
 | 
			
		||||
                                                Umu, sU, mu, t_mask);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FermOpTemplateInstantiate(WilsonFermion);
 | 
			
		||||
AdjointFermOpTemplateInstantiate(WilsonFermion);
 | 
			
		||||
TwoIndexFermOpTemplateInstantiate(WilsonFermion);
 | 
			
		||||
 
 | 
			
		||||
@@ -165,6 +165,22 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
 | 
			
		||||
  LebesgueOrder LebesgueEvenOdd;
 | 
			
		||||
 | 
			
		||||
  WilsonAnisotropyCoefficients anisotropyCoeff;
 | 
			
		||||
  
 | 
			
		||||
  ///////////////////////////////////////////////////////////////
 | 
			
		||||
  // Conserved current utilities
 | 
			
		||||
  ///////////////////////////////////////////////////////////////
 | 
			
		||||
  void ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                PropagatorField &q_in_2,
 | 
			
		||||
                                PropagatorField &q_out,
 | 
			
		||||
                                Current curr_type,
 | 
			
		||||
                                unsigned int mu);
 | 
			
		||||
  void SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                           PropagatorField &q_out,
 | 
			
		||||
                           Current curr_type,
 | 
			
		||||
                           unsigned int mu, 
 | 
			
		||||
                           std::vector<Real> mom,
 | 
			
		||||
                           unsigned int tmin,
 | 
			
		||||
                           unsigned int tmax);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef WilsonFermion<WilsonImplF> WilsonFermionF;
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
 | 
			
		||||
Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
 | 
			
		||||
Author: Andrew Lawson <andrew.lawson1991@gmail.com>
 | 
			
		||||
 | 
			
		||||
    This program is free software; you can redistribute it and/or modify
 | 
			
		||||
    it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -702,6 +703,168 @@ void WilsonFermion5D<Impl>::MomentumSpacePropagatorHw(FermionField &out,const Fe
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Conserved current utilities for Wilson fermions, for contracting propagators
 | 
			
		||||
 * to make a conserved current sink or inserting the conserved current 
 | 
			
		||||
 * sequentially.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
// Helper macro to reverse Simd vector. Fixme: slow, generic implementation.
 | 
			
		||||
#define REVERSE_LS(qSite, qSiteRev, Nsimd) \
 | 
			
		||||
{ \
 | 
			
		||||
    std::vector<typename SitePropagator::scalar_object> qSiteVec(Nsimd); \
 | 
			
		||||
    extract(qSite, qSiteVec); \
 | 
			
		||||
    for (int i = 0; i < Nsimd / 2; ++i) \
 | 
			
		||||
    { \
 | 
			
		||||
        typename SitePropagator::scalar_object tmp = qSiteVec[i]; \
 | 
			
		||||
        qSiteVec[i] = qSiteVec[Nsimd - i - 1]; \
 | 
			
		||||
        qSiteVec[Nsimd - i - 1] = tmp; \
 | 
			
		||||
    } \
 | 
			
		||||
    merge(qSiteRev, qSiteVec); \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion5D<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                                     PropagatorField &q_in_2,
 | 
			
		||||
                                                     PropagatorField &q_out,
 | 
			
		||||
                                                     Current curr_type,
 | 
			
		||||
                                                     unsigned int mu)
 | 
			
		||||
{
 | 
			
		||||
    conformable(q_in_1._grid, FermionGrid());
 | 
			
		||||
    conformable(q_in_1._grid, q_in_2._grid);
 | 
			
		||||
    conformable(_FourDimGrid, q_out._grid);
 | 
			
		||||
    PropagatorField tmp1(FermionGrid()), tmp2(FermionGrid());
 | 
			
		||||
    unsigned int LLs = q_in_1._grid->_rdimensions[0];
 | 
			
		||||
    q_out = zero;
 | 
			
		||||
 | 
			
		||||
    // 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 * LLs;
 | 
			
		||||
        unsigned int sF2 = (sU + 1) * LLs - 1;
 | 
			
		||||
 | 
			
		||||
        for (unsigned int s = 0; s < LLs; ++s)
 | 
			
		||||
        {
 | 
			
		||||
            bool axial_sign = ((curr_type == Current::Axial) && \
 | 
			
		||||
                               (s < (LLs / 2)));
 | 
			
		||||
            SitePropagator qSite2, qmuSite2;
 | 
			
		||||
 | 
			
		||||
            // If vectorised in 5th dimension, reverse q2 vector to match up
 | 
			
		||||
            // sites correctly.
 | 
			
		||||
            if (Impl::LsVectorised)
 | 
			
		||||
            {
 | 
			
		||||
                REVERSE_LS(q_in_2._odata[sF2], qSite2, Ls / LLs);
 | 
			
		||||
                REVERSE_LS(tmp2._odata[sF2], qmuSite2, Ls / LLs);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                qSite2   = q_in_2._odata[sF2];
 | 
			
		||||
                qmuSite2 = tmp2._odata[sF2];
 | 
			
		||||
            }
 | 
			
		||||
            Kernels::ContractConservedCurrentSiteFwd(tmp1._odata[sF1], 
 | 
			
		||||
                                                     qSite2, 
 | 
			
		||||
                                                     q_out._odata[sU],
 | 
			
		||||
                                                     Umu, sU, mu, axial_sign);
 | 
			
		||||
            Kernels::ContractConservedCurrentSiteBwd(q_in_1._odata[sF1],
 | 
			
		||||
                                                     qmuSite2,
 | 
			
		||||
                                                     q_out._odata[sU],
 | 
			
		||||
                                                     Umu, sU, mu, axial_sign);
 | 
			
		||||
            sF1++;
 | 
			
		||||
            sF2--;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
                                                PropagatorField &q_out,
 | 
			
		||||
                                                Current curr_type, 
 | 
			
		||||
                                                unsigned int mu,
 | 
			
		||||
                                                std::vector<Real> mom,
 | 
			
		||||
                                                unsigned int tmin, 
 | 
			
		||||
                                                unsigned int tmax)
 | 
			
		||||
{
 | 
			
		||||
    conformable(q_in._grid, FermionGrid());
 | 
			
		||||
    conformable(q_in._grid, q_out._grid);
 | 
			
		||||
    Lattice<iSinglet<Simd>> ph(FermionGrid()), coor(FermionGrid());
 | 
			
		||||
    PropagatorField tmpFwd(FermionGrid()), tmpBwd(FermionGrid()),
 | 
			
		||||
                    tmp(FermionGrid());
 | 
			
		||||
    Complex i(0.0, 1.0);
 | 
			
		||||
    unsigned int tshift = (mu == Tp) ? 1 : 0;
 | 
			
		||||
    unsigned int LLs = q_in._grid->_rdimensions[0];
 | 
			
		||||
    unsigned int LLt    = GridDefaultLatt()[Tp];
 | 
			
		||||
 | 
			
		||||
    // Momentum projection.
 | 
			
		||||
    ph = zero;
 | 
			
		||||
    for(unsigned int nu = 0; nu < Nd - 1; nu++)
 | 
			
		||||
    {
 | 
			
		||||
        // Shift coordinate lattice index by 1 to account for 5th dimension.
 | 
			
		||||
        LatticeCoordinate(coor, nu + 1);
 | 
			
		||||
        ph = ph + mom[nu]*coor*((1./(_FourDimGrid->_fdimensions[nu])));
 | 
			
		||||
    }
 | 
			
		||||
    ph = exp((Real)(2*M_PI)*i*ph);
 | 
			
		||||
 | 
			
		||||
    q_out = zero;
 | 
			
		||||
    LatticeInteger coords(_FourDimGrid);
 | 
			
		||||
    LatticeCoordinate(coords, Tp);
 | 
			
		||||
 | 
			
		||||
    // Need q(x + mu, s) and q(x - mu, s). 5D lattice so shift 4D coordinate mu
 | 
			
		||||
    // by one.
 | 
			
		||||
    tmp = Cshift(q_in, mu + 1, 1);
 | 
			
		||||
    tmpFwd = tmp*ph;
 | 
			
		||||
    tmp = ph*q_in;
 | 
			
		||||
    tmpBwd = Cshift(tmp, mu + 1, -1);
 | 
			
		||||
 | 
			
		||||
    parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
 | 
			
		||||
    {
 | 
			
		||||
        // Compute the sequential conserved current insertion only if our simd
 | 
			
		||||
        // object contains a timeslice we need.
 | 
			
		||||
        vInteger t_mask   = ((coords._odata[sU] >= tmin) &&
 | 
			
		||||
                             (coords._odata[sU] <= tmax));
 | 
			
		||||
        Integer timeSlices = Reduce(t_mask);
 | 
			
		||||
 | 
			
		||||
        if (timeSlices > 0)
 | 
			
		||||
        {
 | 
			
		||||
            unsigned int sF = sU * LLs;
 | 
			
		||||
            for (unsigned int s = 0; s < LLs; ++s)
 | 
			
		||||
            {
 | 
			
		||||
                bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
 | 
			
		||||
                Kernels::SeqConservedCurrentSiteFwd(tmpFwd._odata[sF], 
 | 
			
		||||
                                                    q_out._odata[sF], Umu, sU,
 | 
			
		||||
                                                    mu, t_mask, axial_sign);
 | 
			
		||||
                ++sF;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Repeat for backward direction.
 | 
			
		||||
        t_mask     = ((coords._odata[sU] >= (tmin + tshift)) && 
 | 
			
		||||
                      (coords._odata[sU] <= (tmax + tshift)));
 | 
			
		||||
 | 
			
		||||
	//if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3)	
 | 
			
		||||
	unsigned int t0 = 0;
 | 
			
		||||
	if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 ));
 | 
			
		||||
 | 
			
		||||
        timeSlices = Reduce(t_mask);
 | 
			
		||||
 | 
			
		||||
        if (timeSlices > 0)
 | 
			
		||||
        {
 | 
			
		||||
            unsigned int sF = sU * LLs;
 | 
			
		||||
            for (unsigned int s = 0; s < LLs; ++s)
 | 
			
		||||
            {
 | 
			
		||||
                bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
 | 
			
		||||
                Kernels::SeqConservedCurrentSiteBwd(tmpBwd._odata[sF], 
 | 
			
		||||
                                                    q_out._odata[sF], Umu, sU,
 | 
			
		||||
                                                    mu, t_mask, axial_sign);
 | 
			
		||||
                ++sF;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FermOpTemplateInstantiate(WilsonFermion5D);
 | 
			
		||||
GparityFermOpTemplateInstantiate(WilsonFermion5D);
 | 
			
		||||
  
 | 
			
		||||
 
 | 
			
		||||
@@ -214,6 +214,21 @@ namespace QCD {
 | 
			
		||||
    // Comms buffer
 | 
			
		||||
    std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> >  comm_buf;
 | 
			
		||||
    
 | 
			
		||||
    ///////////////////////////////////////////////////////////////
 | 
			
		||||
    // Conserved current utilities
 | 
			
		||||
    ///////////////////////////////////////////////////////////////
 | 
			
		||||
    void ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
                                  PropagatorField &q_in_2,
 | 
			
		||||
                                  PropagatorField &q_out,
 | 
			
		||||
                                  Current curr_type, 
 | 
			
		||||
                                  unsigned int mu);
 | 
			
		||||
    void SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                             PropagatorField &q_out,
 | 
			
		||||
                             Current curr_type,
 | 
			
		||||
                             unsigned int mu,
 | 
			
		||||
                             std::vector<Real> mom,
 | 
			
		||||
                             unsigned int tmin,
 | 
			
		||||
                             unsigned int tmax);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
 
 | 
			
		||||
@@ -281,6 +281,172 @@ void WilsonKernels<Impl>::DhopDir( StencilImpl &st, DoubledGaugeField &U,SiteHal
 | 
			
		||||
  vstream(out._odata[sF], result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Conserved current utilities for Wilson fermions, for contracting propagators
 | 
			
		||||
 * to make a conserved current sink or inserting the conserved current 
 | 
			
		||||
 * sequentially. Common to both 4D and 5D.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
// N.B. Functions below assume a -1/2 factor within U.
 | 
			
		||||
#define WilsonCurrentFwd(expr, mu) ((expr - Gamma::gmu[mu]*expr))
 | 
			
		||||
#define WilsonCurrentBwd(expr, mu) ((expr + Gamma::gmu[mu]*expr))
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Name: ContractConservedCurrentSiteFwd
 | 
			
		||||
 * Operation: (1/2) * q2[x] * U(x) * (g[mu] - 1) * q1[x + mu]
 | 
			
		||||
 * Notes: - DoubledGaugeField U assumed to contain -1/2 factor.
 | 
			
		||||
 *        - Pass in q_in_1 shifted in +ve mu direction.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
template<class Impl>
 | 
			
		||||
void WilsonKernels<Impl>::ContractConservedCurrentSiteFwd(
 | 
			
		||||
                                                  const SitePropagator &q_in_1,
 | 
			
		||||
                                                  const SitePropagator &q_in_2,
 | 
			
		||||
                                                  SitePropagator &q_out,
 | 
			
		||||
                                                  DoubledGaugeField &U,
 | 
			
		||||
                                                  unsigned int sU,
 | 
			
		||||
                                                  unsigned int mu,
 | 
			
		||||
                                                  bool switch_sign)
 | 
			
		||||
{
 | 
			
		||||
    SitePropagator result, tmp;
 | 
			
		||||
    Gamma g5(Gamma::Algebra::Gamma5);
 | 
			
		||||
    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 -= result;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        q_out += result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Name: ContractConservedCurrentSiteBwd
 | 
			
		||||
 * Operation: (1/2) * q2[x + mu] * U^dag(x) * (g[mu] + 1) * q1[x]
 | 
			
		||||
 * Notes: - DoubledGaugeField U assumed to contain -1/2 factor.
 | 
			
		||||
 *        - Pass in q_in_2 shifted in +ve mu direction.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
template<class Impl>
 | 
			
		||||
void WilsonKernels<Impl>::ContractConservedCurrentSiteBwd(
 | 
			
		||||
                                                  const SitePropagator &q_in_1,
 | 
			
		||||
                                                  const SitePropagator &q_in_2,
 | 
			
		||||
                                                  SitePropagator &q_out,
 | 
			
		||||
                                                  DoubledGaugeField &U,
 | 
			
		||||
                                                  unsigned int sU,
 | 
			
		||||
                                                  unsigned int mu,
 | 
			
		||||
                                                  bool switch_sign)
 | 
			
		||||
{
 | 
			
		||||
    SitePropagator result, tmp;
 | 
			
		||||
    Gamma g5(Gamma::Algebra::Gamma5);
 | 
			
		||||
    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 += result;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        q_out -= result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// G-parity requires more specialised implementation.
 | 
			
		||||
#define NO_CURR_SITE(Impl) \
 | 
			
		||||
template <> \
 | 
			
		||||
void WilsonKernels<Impl>::ContractConservedCurrentSiteFwd( \
 | 
			
		||||
                                                  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 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); \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NO_CURR_SITE(GparityWilsonImplF);
 | 
			
		||||
NO_CURR_SITE(GparityWilsonImplD);
 | 
			
		||||
NO_CURR_SITE(GparityWilsonImplFH);
 | 
			
		||||
NO_CURR_SITE(GparityWilsonImplDF);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Name: SeqConservedCurrentSiteFwd
 | 
			
		||||
 * Operation: (1/2) * U(x) * (g[mu] - 1) * q[x + mu]
 | 
			
		||||
 * Notes: - DoubledGaugeField U assumed to contain -1/2 factor.
 | 
			
		||||
 *        - Pass in q_in shifted in +ve mu direction.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
template<class Impl>
 | 
			
		||||
void WilsonKernels<Impl>::SeqConservedCurrentSiteFwd(const SitePropagator &q_in,
 | 
			
		||||
                                                     SitePropagator &q_out,
 | 
			
		||||
                                                     DoubledGaugeField &U,
 | 
			
		||||
                                                     unsigned int sU,
 | 
			
		||||
                                                     unsigned int mu,
 | 
			
		||||
                                                     vInteger t_mask,
 | 
			
		||||
                                                     bool switch_sign)
 | 
			
		||||
{
 | 
			
		||||
    SitePropagator result;
 | 
			
		||||
    Impl::multLinkProp(result, U._odata[sU], q_in, mu);
 | 
			
		||||
    result = WilsonCurrentFwd(result, mu);
 | 
			
		||||
 | 
			
		||||
    // Zero any unwanted timeslice entries.
 | 
			
		||||
    result = predicatedWhere(t_mask, result, 0.*result);
 | 
			
		||||
 | 
			
		||||
    if (switch_sign)
 | 
			
		||||
    {
 | 
			
		||||
        q_out -= result;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        q_out += result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Name: SeqConservedCurrentSiteFwd
 | 
			
		||||
 * Operation: (1/2) * U^dag(x) * (g[mu] + 1) * q[x - mu]
 | 
			
		||||
 * Notes: - DoubledGaugeField U assumed to contain -1/2 factor.
 | 
			
		||||
 *        - Pass in q_in shifted in -ve mu direction.
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
template<class Impl>
 | 
			
		||||
void WilsonKernels<Impl>::SeqConservedCurrentSiteBwd(const SitePropagator &q_in, 
 | 
			
		||||
                                                     SitePropagator &q_out,
 | 
			
		||||
                                                     DoubledGaugeField &U,
 | 
			
		||||
                                                     unsigned int sU,
 | 
			
		||||
                                                     unsigned int mu,
 | 
			
		||||
                                                     vInteger t_mask,
 | 
			
		||||
                                                     bool switch_sign)
 | 
			
		||||
{
 | 
			
		||||
    SitePropagator result;
 | 
			
		||||
    Impl::multLinkProp(result, U._odata[sU], q_in, mu + Nd);
 | 
			
		||||
    result = WilsonCurrentBwd(result, mu);
 | 
			
		||||
 | 
			
		||||
    // Zero any unwanted timeslice entries.
 | 
			
		||||
    result = predicatedWhere(t_mask, result, 0.*result);
 | 
			
		||||
 | 
			
		||||
    if (switch_sign)
 | 
			
		||||
    {
 | 
			
		||||
        q_out += result;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        q_out -= result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FermOpTemplateInstantiate(WilsonKernels);
 | 
			
		||||
AdjointFermOpTemplateInstantiate(WilsonKernels);
 | 
			
		||||
TwoIndexFermOpTemplateInstantiate(WilsonKernels);
 | 
			
		||||
 
 | 
			
		||||
@@ -180,6 +180,38 @@ public:
 | 
			
		||||
  void DhopDir(StencilImpl &st, DoubledGaugeField &U,SiteHalfSpinor * buf,
 | 
			
		||||
		       int sF, int sU, const FermionField &in, FermionField &out, int dirdisp, int gamma);
 | 
			
		||||
      
 | 
			
		||||
  //////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  // Utilities for inserting Wilson conserved current.
 | 
			
		||||
  //////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  void ContractConservedCurrentSiteFwd(const SitePropagator &q_in_1,
 | 
			
		||||
                                       const SitePropagator &q_in_2,
 | 
			
		||||
                                       SitePropagator &q_out,
 | 
			
		||||
                                       DoubledGaugeField &U,
 | 
			
		||||
                                       unsigned int sU,
 | 
			
		||||
                                       unsigned int mu,
 | 
			
		||||
                                       bool switch_sign = false);
 | 
			
		||||
  void ContractConservedCurrentSiteBwd(const SitePropagator &q_in_1,
 | 
			
		||||
                                       const SitePropagator &q_in_2,
 | 
			
		||||
                                       SitePropagator &q_out,
 | 
			
		||||
                                       DoubledGaugeField &U,
 | 
			
		||||
                                       unsigned int sU,
 | 
			
		||||
                                       unsigned int mu,
 | 
			
		||||
                                       bool switch_sign = false);
 | 
			
		||||
  void SeqConservedCurrentSiteFwd(const SitePropagator &q_in, 
 | 
			
		||||
                                  SitePropagator &q_out,
 | 
			
		||||
                                  DoubledGaugeField &U,
 | 
			
		||||
                                  unsigned int sU,
 | 
			
		||||
                                  unsigned int mu,
 | 
			
		||||
                                  vInteger t_mask,
 | 
			
		||||
                                  bool switch_sign = false);
 | 
			
		||||
  void SeqConservedCurrentSiteBwd(const SitePropagator &q_in,
 | 
			
		||||
                                  SitePropagator &q_out,
 | 
			
		||||
                                  DoubledGaugeField &U,
 | 
			
		||||
                                  unsigned int sU,
 | 
			
		||||
                                  unsigned int mu,
 | 
			
		||||
                                  vInteger t_mask,
 | 
			
		||||
                                  bool switch_sign = false);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
     // Specialised variants
 | 
			
		||||
  void GenericDhopSite(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, SiteHalfSpinor * buf,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user