1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-13 01:05:36 +00:00

Modified the Dirac Kernel class to compile with different number of colours

Added the general push_back functionality to accomodate for all defined representations

Compiles, not tested
This commit is contained in:
Guido Cossu 2016-07-18 16:36:28 +01:00
parent 9c77bb69a5
commit b93e18ed50
12 changed files with 579 additions and 425 deletions

View File

@ -66,6 +66,20 @@ Phi(&_Grid), pRNG(_pRNG) {
}; };
*/ */
// Indexing of tuple types
template <class T, class Tuple>
struct Index;
template <class T, class... Types>
struct Index<T, std::tuple<T, Types...>> {
static const std::size_t value = 0;
};
template <class T, class U, class... Types>
struct Index<T, std::tuple<U, Types...>> {
static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
};
template <class GaugeField> template <class GaugeField>
struct ActionLevel { struct ActionLevel {
public: public:
@ -99,38 +113,39 @@ struct ActionLevelHirep {
// representation fields // representation fields
typedef typename AccessTypes<Action, Repr>::VectorCollection action_collection; typedef typename AccessTypes<Action, Repr>::VectorCollection action_collection;
action_collection actions_hirep; action_collection actions_hirep;
typedef typename AccessTypes<Action, Repr>::ClassCollection actions_hirep_ptrs_type; typedef typename AccessTypes<Action, Repr>::FieldTypeCollection action_hirep_types;
std::vector<ActPtr>& actions; std::vector<ActPtr>& actions;
// Temporary conversion between ActionLevel and ActionLevelHirep // Temporary conversion between ActionLevel and ActionLevelHirep
ActionLevelHirep(ActionLevel<GaugeField>& AL ):actions(AL.actions), multiplier(AL.multiplier){} ActionLevelHirep(ActionLevel<GaugeField>& AL ):actions(AL.actions), multiplier(AL.multiplier){}
ActionLevelHirep(unsigned int mul = 1) : actions(std::get<0>(actions_hirep)), multiplier(mul) { ActionLevelHirep(unsigned int mul = 1) : actions(std::get<0>(actions_hirep)), multiplier(mul) {
// initialize the hirep vectors to zero. // initialize the hirep vectors to zero.
//apply(this->resize, actions_hirep, 0); //need a working resize //apply(this->resize, actions_hirep, 0); //need a working resize
assert(mul >= 1); assert(mul >= 1);
}; };
void push_back(ActPtr ptr) { actions.push_back(ptr); } //void push_back(ActPtr ptr) { actions.push_back(ptr); }
// SFINAE construct, check
template <class actionpointer, size_t N>
void push_back(actionpointer ptr, decltype(std::tuple_element<N, actions_hirep_ptrs_type>::value)* = 0) { template < class Field >
//insert only in the correct vector void push_back(Action<Field>* ptr) {
std::get<N>(actions_hirep).push_back(ptr); // insert only in the correct vector
std::get< Index < Field, action_hirep_types>::value >(actions_hirep).push_back(ptr);
}; };
template < class ActPtr> template < class ActPtr>
static void resize(ActPtr ap, unsigned int n){ static void resize(ActPtr ap, unsigned int n){
ap->resize(n); ap->resize(n);
} }
template <std::size_t I> //template <std::size_t I>
auto getRepresentation(Repr& R)->decltype(std::get<I>(R).U) {return std::get<I>(R).U;} //auto getRepresentation(Repr& R)->decltype(std::get<I>(R).U) {return std::get<I>(R).U;}
// Loop on tuple for a callable function // Loop on tuple for a callable function
template <std::size_t I = 1, typename Callable, typename ...Args> template <std::size_t I = 1, typename Callable, typename ...Args>

View File

@ -113,6 +113,10 @@ typedef SymanzikGaugeAction<ConjugateGimplD> ConjugateSymanzikGaugeAction
template class A<GparityWilsonImplF>; \ template class A<GparityWilsonImplF>; \
template class A<GparityWilsonImplD>; template class A<GparityWilsonImplD>;
#define AdjointFermOpTemplateInstantiate(A) \
template class A<WilsonAdjImplF>; \
template class A<WilsonAdjImplD>;
#define GparityFermOpTemplateInstantiate(A) #define GparityFermOpTemplateInstantiate(A)
//////////////////////////////////////////// ////////////////////////////////////////////
@ -157,6 +161,10 @@ typedef WilsonFermion<WilsonImplR> WilsonFermionR;
typedef WilsonFermion<WilsonImplF> WilsonFermionF; typedef WilsonFermion<WilsonImplF> WilsonFermionF;
typedef WilsonFermion<WilsonImplD> WilsonFermionD; typedef WilsonFermion<WilsonImplD> WilsonFermionD;
typedef WilsonFermion<WilsonAdjImplR> WilsonAdjFermionR;
typedef WilsonFermion<WilsonAdjImplF> WilsonAdjFermionF;
typedef WilsonFermion<WilsonAdjImplD> WilsonAdjFermionD;
typedef WilsonTMFermion<WilsonImplR> WilsonTMFermionR; typedef WilsonTMFermion<WilsonImplR> WilsonTMFermionR;
typedef WilsonTMFermion<WilsonImplF> WilsonTMFermionF; typedef WilsonTMFermion<WilsonImplF> WilsonTMFermionF;
typedef WilsonTMFermion<WilsonImplD> WilsonTMFermionD; typedef WilsonTMFermion<WilsonImplD> WilsonTMFermionD;

View File

@ -115,22 +115,23 @@ template <class S, class Representation = FundamentalRepresentation >
class WilsonImpl class WilsonImpl
: public PeriodicGaugeImpl<GaugeImplTypes<S, Representation::Dimension > > { : public PeriodicGaugeImpl<GaugeImplTypes<S, Representation::Dimension > > {
public: public:
static const int Nrepresentation = Representation::Dimension; static const int Dimension = Representation::Dimension;
typedef PeriodicGaugeImpl<GaugeImplTypes<S, Representation::Dimension > > Gimpl; // static const int Nrepresentation = Representation::Dimension;
typedef PeriodicGaugeImpl<GaugeImplTypes<S, Dimension > > Gimpl;
//Necessary? //Necessary?
constexpr bool is_fundamental() const{return Representation::Dimension == Nc ? 1 : 0;} constexpr bool is_fundamental() const{return Dimension == Nc ? 1 : 0;}
INHERIT_GIMPL_TYPES(Gimpl); INHERIT_GIMPL_TYPES(Gimpl);
template <typename vtype> template <typename vtype>
using iImplSpinor = iScalar<iVector<iVector<vtype, Nrepresentation>, Ns> >; using iImplSpinor = iScalar<iVector<iVector<vtype, Dimension>, Ns> >;
template <typename vtype> template <typename vtype>
using iImplHalfSpinor = using iImplHalfSpinor =
iScalar<iVector<iVector<vtype, Nrepresentation>, Nhs> >; iScalar<iVector<iVector<vtype, Dimension>, Nhs> >;
template <typename vtype> template <typename vtype>
using iImplDoubledGaugeField = using iImplDoubledGaugeField =
iVector<iScalar<iMatrix<vtype, Nrepresentation> >, Nds>; iVector<iScalar<iMatrix<vtype, Dimension> >, Nds>;
typedef iImplSpinor<Simd> SiteSpinor; typedef iImplSpinor<Simd> SiteSpinor;
typedef iImplHalfSpinor<Simd> SiteHalfSpinor; typedef iImplHalfSpinor<Simd> SiteHalfSpinor;
@ -214,6 +215,8 @@ template <class S, int Nrepresentation = Nc>
class DomainWallRedBlack5dImpl class DomainWallRedBlack5dImpl
: public PeriodicGaugeImpl<GaugeImplTypes<S, Nrepresentation> > { : public PeriodicGaugeImpl<GaugeImplTypes<S, Nrepresentation> > {
public: public:
static const int Dimension = Nrepresentation;
typedef PeriodicGaugeImpl<GaugeImplTypes<S, Nrepresentation> > Gimpl; typedef PeriodicGaugeImpl<GaugeImplTypes<S, Nrepresentation> > Gimpl;
INHERIT_GIMPL_TYPES(Gimpl); INHERIT_GIMPL_TYPES(Gimpl);
@ -318,6 +321,7 @@ template <class S, int Nrepresentation>
class GparityWilsonImpl class GparityWilsonImpl
: public ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresentation> > { : public ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresentation> > {
public: public:
static const int Dimension = Nrepresentation;
typedef ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresentation> > Gimpl; typedef ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresentation> > Gimpl;
INHERIT_GIMPL_TYPES(Gimpl); INHERIT_GIMPL_TYPES(Gimpl);

View File

@ -308,6 +308,7 @@ void WilsonFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder &lo,
}; };
FermOpTemplateInstantiate(WilsonFermion); FermOpTemplateInstantiate(WilsonFermion);
AdjointFermOpTemplateInstantiate(WilsonFermion);
GparityFermOpTemplateInstantiate(WilsonFermion); GparityFermOpTemplateInstantiate(WilsonFermion);
} }
} }

View File

@ -148,6 +148,8 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
typedef WilsonFermion<WilsonImplF> WilsonFermionF; typedef WilsonFermion<WilsonImplF> WilsonFermionF;
typedef WilsonFermion<WilsonImplD> WilsonFermionD; typedef WilsonFermion<WilsonImplD> WilsonFermionD;
} }
} }
#endif #endif

View File

@ -1,72 +1,94 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/qcd/action/fermion/WilsonKernels.cc Source file: ./lib/qcd/action/fermion/WilsonKernels.cc
Copyright (C) 2015 Copyright (C) 2015
Author: Peter Boyle <paboyle@ph.ed.ac.uk> Author: Peter Boyle <paboyle@ph.ed.ac.uk>
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local> Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
Author: paboyle <paboyle@ph.ed.ac.uk> Author: paboyle <paboyle@ph.ed.ac.uk>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution
*************************************************************************************/ directory
/* END LEGAL */ *************************************************************************************/
/* END LEGAL */
#include <Grid.h> #include <Grid.h>
namespace Grid { namespace Grid {
namespace QCD { namespace QCD {
int WilsonKernelsStatic::HandOpt; int WilsonKernelsStatic::HandOpt;
int WilsonKernelsStatic::AsmOpt; int WilsonKernelsStatic::AsmOpt;
template<class Impl> template <class Impl>
WilsonKernels<Impl>::WilsonKernels(const ImplParams &p): Base(p) {}; WilsonKernels<Impl>::WilsonKernels(const ImplParams &p) : Base(p){};
template<class Impl> /*
void WilsonKernels<Impl>::DiracOptDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, template <class Impl>
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, typename std::enable_if<Impl::Dimension == 3>::type WilsonKernels<Impl>::DiracOptDhopSite(
int sF,int sU,int Ls, int Ns, const FermionField &in, FermionField &out) StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
{ std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
int sU, int Ls, int Ns, const FermionField &in, FermionField &out) {
#ifdef AVX512 #ifdef AVX512
if ( AsmOpt ) { if (AsmOpt) {
WilsonKernels<Impl>::DiracOptAsmDhopSite(st, lo, U, buf, sF, sU, Ls, Ns, in,
WilsonKernels<Impl>::DiracOptAsmDhopSite(st,lo,U,buf,sF,sU,Ls,Ns,in,out); out);
} else { } else {
#else #else
{ {
#endif #endif
for(int site=0;site<Ns;site++) { for (int site = 0; site < Ns; site++) {
for(int s=0;s<Ls;s++) { for (int s = 0; s < Ls; s++) {
if (HandOpt) WilsonKernels<Impl>::DiracOptHandDhopSite(st,lo,U,buf,sF,sU,in,out); if (HandOpt)
else WilsonKernels<Impl>::DiracOptGenericDhopSite(st,lo,U,buf,sF,sU,in,out); WilsonKernels<Impl>::DiracOptHandDhopSite(st, lo, U, buf, sF, sU, in,
sF++; out);
else
WilsonKernels<Impl>::DiracOptGenericDhopSite(st, lo, U, buf, sF, sU,
in, out);
sF++;
} }
sU++; sU++;
} }
} }
} }
template <class Impl>
typename std::enable_if<Impl::Dimension != 3>::type WilsonKernels<Impl>::DiracOptDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
int sU, int Ls, int Ns, const FermionField &in, FermionField &out) {
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
WilsonKernels<Impl>::DiracOptGenericDhopSite(st, lo, U, buf, sF, sU, in,
out);
sF++;
}
sU++;
}
}
template<class Impl> template<class Impl>
void WilsonKernels<Impl>::DiracOptDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, void WilsonKernels<Impl>::DiracOptDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,int Ls, int Ns, const FermionField &in, FermionField &out) int sF,int sU,int Ls, int Ns, const FermionField &in, FermionField &out,
typename std::enable_if<Impl::Dimension == 3, int>::type = 0)
{ {
// No asm implementation yet. // No asm implementation yet.
// if ( AsmOpt ) WilsonKernels<Impl>::DiracOptAsmDhopSiteDag(st,lo,U,buf,sF,sU,in,out); // if ( AsmOpt ) WilsonKernels<Impl>::DiracOptAsmDhopSiteDag(st,lo,U,buf,sF,sU,in,out);
@ -82,17 +104,35 @@ void WilsonKernels<Impl>::DiracOptDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,
} }
////////////////////////////////////////////
// Generic implementation; move to different file?
////////////////////////////////////////////
template<class Impl>
void WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, template <class Impl>
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, void WilsonKernels<Impl>::DiracOptDhopSiteDag(
int sF,int sU,const FermionField &in, FermionField &out) StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
{ std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
SiteHalfSpinor tmp; int sU, int Ls, int Ns, const FermionField &in, FermionField &out,
SiteHalfSpinor chi; typename std::enable_if<Impl::Dimension != 3, int>::type = 0) {
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(st, lo, U, buf, sF, sU,
in, out);
sF++;
}
sU++;
}
}
*/
////////////////////////////////////////////
// Generic implementation; move to different file?
////////////////////////////////////////////
template <class Impl>
void WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
int sU, const FermionField &in, FermionField &out) {
SiteHalfSpinor tmp;
SiteHalfSpinor chi;
SiteHalfSpinor *chi_p; SiteHalfSpinor *chi_p;
SiteHalfSpinor Uchi; SiteHalfSpinor Uchi;
SiteSpinor result; SiteSpinor result;
@ -102,176 +142,175 @@ void WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(StencilImpl &st,LebesgueOrd
/////////////////////////// ///////////////////////////
// Xp // Xp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Xp,sF); SE = st.GetEntry(ptype, Xp, sF);
if (SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjXp(tmp,in._odata[SE->_offset]); spProjXp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjXp(chi,in._odata[SE->_offset]); spProjXp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Xp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Xp, SE, st);
spReconXp(result,Uchi); spReconXp(result, Uchi);
/////////////////////////// ///////////////////////////
// Yp // Yp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Yp,sF); SE = st.GetEntry(ptype, Yp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjYp(tmp,in._odata[SE->_offset]); spProjYp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjYp(chi,in._odata[SE->_offset]); spProjYp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Yp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Yp, SE, st);
accumReconYp(result,Uchi); accumReconYp(result, Uchi);
/////////////////////////// ///////////////////////////
// Zp // Zp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Zp,sF); SE = st.GetEntry(ptype, Zp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjZp(tmp,in._odata[SE->_offset]); spProjZp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjZp(chi,in._odata[SE->_offset]); spProjZp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Zp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Zp, SE, st);
accumReconZp(result,Uchi); accumReconZp(result, Uchi);
/////////////////////////// ///////////////////////////
// Tp // Tp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Tp,sF); SE = st.GetEntry(ptype, Tp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjTp(tmp,in._odata[SE->_offset]); spProjTp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjTp(chi,in._odata[SE->_offset]); spProjTp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Tp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Tp, SE, st);
accumReconTp(result,Uchi); accumReconTp(result, Uchi);
/////////////////////////// ///////////////////////////
// Xm // Xm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Xm,sF); SE = st.GetEntry(ptype, Xm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjXm(tmp,in._odata[SE->_offset]); spProjXm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjXm(chi,in._odata[SE->_offset]); spProjXm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Xm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Xm, SE, st);
accumReconXm(result,Uchi); accumReconXm(result, Uchi);
/////////////////////////// ///////////////////////////
// Ym // Ym
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Ym,sF); SE = st.GetEntry(ptype, Ym, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjYm(tmp,in._odata[SE->_offset]); spProjYm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjYm(chi,in._odata[SE->_offset]); spProjYm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Ym,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Ym, SE, st);
accumReconYm(result,Uchi); accumReconYm(result, Uchi);
/////////////////////////// ///////////////////////////
// Zm // Zm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Zm,sF); SE = st.GetEntry(ptype, Zm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjZm(tmp,in._odata[SE->_offset]); spProjZm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjZm(chi,in._odata[SE->_offset]); spProjZm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Zm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Zm, SE, st);
accumReconZm(result,Uchi); accumReconZm(result, Uchi);
/////////////////////////// ///////////////////////////
// Tm // Tm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Tm,sF); SE = st.GetEntry(ptype, Tm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjTm(tmp,in._odata[SE->_offset]); spProjTm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjTm(chi,in._odata[SE->_offset]); spProjTm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Tm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Tm, SE, st);
accumReconTm(result,Uchi); accumReconTm(result, Uchi);
vstream(out._odata[sF],result); vstream(out._odata[sF], result);
}; };
// Need controls to do interior, exterior, or both
// Need controls to do interior, exterior, or both template <class Impl>
template<class Impl> void WilsonKernels<Impl>::DiracOptGenericDhopSite(
void WilsonKernels<Impl>::DiracOptGenericDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
int sF,int sU,const FermionField &in, FermionField &out) int sU, const FermionField &in, FermionField &out) {
{ SiteHalfSpinor tmp;
SiteHalfSpinor tmp; SiteHalfSpinor chi;
SiteHalfSpinor chi; SiteHalfSpinor *chi_p;
SiteHalfSpinor *chi_p;
SiteHalfSpinor Uchi; SiteHalfSpinor Uchi;
SiteSpinor result; SiteSpinor result;
StencilEntry *SE; StencilEntry *SE;
@ -280,299 +319,299 @@ void WilsonKernels<Impl>::DiracOptGenericDhopSite(StencilImpl &st,LebesgueOrder
/////////////////////////// ///////////////////////////
// Xp // Xp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Xm,sF); SE = st.GetEntry(ptype, Xm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjXp(tmp,in._odata[SE->_offset]); spProjXp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjXp(chi,in._odata[SE->_offset]); spProjXp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Xm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Xm, SE, st);
spReconXp(result,Uchi); spReconXp(result, Uchi);
/////////////////////////// ///////////////////////////
// Yp // Yp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Ym,sF); SE = st.GetEntry(ptype, Ym, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjYp(tmp,in._odata[SE->_offset]); spProjYp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjYp(chi,in._odata[SE->_offset]); spProjYp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Ym,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Ym, SE, st);
accumReconYp(result,Uchi); accumReconYp(result, Uchi);
/////////////////////////// ///////////////////////////
// Zp // Zp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Zm,sF); SE = st.GetEntry(ptype, Zm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjZp(tmp,in._odata[SE->_offset]); spProjZp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjZp(chi,in._odata[SE->_offset]); spProjZp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Zm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Zm, SE, st);
accumReconZp(result,Uchi); accumReconZp(result, Uchi);
/////////////////////////// ///////////////////////////
// Tp // Tp
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Tm,sF); SE = st.GetEntry(ptype, Tm, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjTp(tmp,in._odata[SE->_offset]); spProjTp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjTp(chi,in._odata[SE->_offset]); spProjTp(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Tm,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Tm, SE, st);
accumReconTp(result,Uchi); accumReconTp(result, Uchi);
/////////////////////////// ///////////////////////////
// Xm // Xm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Xp,sF); SE = st.GetEntry(ptype, Xp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjXm(tmp,in._odata[SE->_offset]); spProjXm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjXm(chi,in._odata[SE->_offset]); spProjXm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Xp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Xp, SE, st);
accumReconXm(result,Uchi); accumReconXm(result, Uchi);
/////////////////////////// ///////////////////////////
// Ym // Ym
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Yp,sF); SE = st.GetEntry(ptype, Yp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjYm(tmp,in._odata[SE->_offset]); spProjYm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjYm(chi,in._odata[SE->_offset]); spProjYm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Yp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Yp, SE, st);
accumReconYm(result,Uchi); accumReconYm(result, Uchi);
/////////////////////////// ///////////////////////////
// Zm // Zm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Zp,sF); SE = st.GetEntry(ptype, Zp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjZm(tmp,in._odata[SE->_offset]); spProjZm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjZm(chi,in._odata[SE->_offset]); spProjZm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Zp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Zp, SE, st);
accumReconZm(result,Uchi); accumReconZm(result, Uchi);
/////////////////////////// ///////////////////////////
// Tm // Tm
/////////////////////////// ///////////////////////////
SE=st.GetEntry(ptype,Tp,sF); SE = st.GetEntry(ptype, Tp, sF);
if ( SE->_is_local ) { if (SE->_is_local) {
chi_p = &chi; chi_p = &chi;
if ( SE->_permute ) { if (SE->_permute) {
spProjTm(tmp,in._odata[SE->_offset]); spProjTm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else { } else {
spProjTm(chi,in._odata[SE->_offset]); spProjTm(chi, in._odata[SE->_offset]);
} }
} else { } else {
chi_p=&buf[SE->_offset]; chi_p = &buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],*chi_p,Tp,SE,st); Impl::multLink(Uchi, U._odata[sU], *chi_p, Tp, SE, st);
accumReconTm(result,Uchi); accumReconTm(result, Uchi);
vstream(out._odata[sF],result); vstream(out._odata[sF], result);
}; };
template<class Impl> template <class Impl>
void WilsonKernels<Impl>::DiracOptDhopDir(StencilImpl &st,DoubledGaugeField &U, void WilsonKernels<Impl>::DiracOptDhopDir(
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, StencilImpl &st, DoubledGaugeField &U,
int sF,int sU,const FermionField &in, FermionField &out,int dir,int gamma) std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf, int sF,
{ int sU, const FermionField &in, FermionField &out, int dir, int gamma) {
SiteHalfSpinor tmp; SiteHalfSpinor tmp;
SiteHalfSpinor chi; SiteHalfSpinor chi;
SiteSpinor result; SiteSpinor result;
SiteHalfSpinor Uchi; SiteHalfSpinor Uchi;
StencilEntry *SE; StencilEntry *SE;
int ptype; int ptype;
SE=st.GetEntry(ptype,dir,sF); SE = st.GetEntry(ptype, dir, sF);
// Xp // Xp
if(gamma==Xp){ if (gamma == Xp) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjXp(tmp,in._odata[SE->_offset]); spProjXp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjXp(chi,in._odata[SE->_offset]); spProjXp(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconXp(result,Uchi); spReconXp(result, Uchi);
} }
// Yp // Yp
if ( gamma==Yp ){ if (gamma == Yp) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjYp(tmp,in._odata[SE->_offset]); spProjYp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjYp(chi,in._odata[SE->_offset]); spProjYp(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconYp(result,Uchi); spReconYp(result, Uchi);
} }
// Zp // Zp
if ( gamma ==Zp ){ if (gamma == Zp) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjZp(tmp,in._odata[SE->_offset]); spProjZp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjZp(chi,in._odata[SE->_offset]); spProjZp(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconZp(result,Uchi); spReconZp(result, Uchi);
} }
// Tp // Tp
if ( gamma ==Tp ){ if (gamma == Tp) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjTp(tmp,in._odata[SE->_offset]); spProjTp(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjTp(chi,in._odata[SE->_offset]); spProjTp(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconTp(result,Uchi); spReconTp(result, Uchi);
} }
// Xm // Xm
if ( gamma==Xm ){ if (gamma == Xm) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjXm(tmp,in._odata[SE->_offset]); spProjXm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjXm(chi,in._odata[SE->_offset]); spProjXm(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconXm(result,Uchi); spReconXm(result, Uchi);
} }
// Ym // Ym
if ( gamma == Ym ){ if (gamma == Ym) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjYm(tmp,in._odata[SE->_offset]); spProjYm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjYm(chi,in._odata[SE->_offset]); spProjYm(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconYm(result,Uchi); spReconYm(result, Uchi);
} }
// Zm // Zm
if ( gamma == Zm ){ if (gamma == Zm) {
if ( SE->_is_local && SE->_permute ) { if (SE->_is_local && SE->_permute) {
spProjZm(tmp,in._odata[SE->_offset]); spProjZm(tmp, in._odata[SE->_offset]);
permute(chi,tmp,ptype); permute(chi, tmp, ptype);
} else if ( SE->_is_local ) { } else if (SE->_is_local) {
spProjZm(chi,in._odata[SE->_offset]); spProjZm(chi, in._odata[SE->_offset]);
} else { } else {
chi=buf[SE->_offset]; chi = buf[SE->_offset];
} }
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st); Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconZm(result,Uchi); spReconZm(result, Uchi);
}
// Tm
if ( gamma==Tm ) {
if ( SE->_is_local && SE->_permute ) {
spProjTm(tmp,in._odata[SE->_offset]);
permute(chi,tmp,ptype);
} else if ( SE->_is_local ) {
spProjTm(chi,in._odata[SE->_offset]);
} else {
chi=buf[SE->_offset];
}
Impl::multLink(Uchi,U._odata[sU],chi,dir,SE,st);
spReconTm(result,Uchi);
} }
vstream(out._odata[sF],result); // Tm
if (gamma == Tm) {
if (SE->_is_local && SE->_permute) {
spProjTm(tmp, in._odata[SE->_offset]);
permute(chi, tmp, ptype);
} else if (SE->_is_local) {
spProjTm(chi, in._odata[SE->_offset]);
} else {
chi = buf[SE->_offset];
}
Impl::multLink(Uchi, U._odata[sU], chi, dir, SE, st);
spReconTm(result, Uchi);
}
vstream(out._odata[sF], result);
} }
FermOpTemplateInstantiate(WilsonKernels);
AdjointFermOpTemplateInstantiate(WilsonKernels);
FermOpTemplateInstantiate(WilsonKernels); template class WilsonKernels<DomainWallRedBlack5dImplF>;
template class WilsonKernels<DomainWallRedBlack5dImplF>;
template class WilsonKernels<DomainWallRedBlack5dImplD>; template class WilsonKernels<DomainWallRedBlack5dImplD>;
}
}} }

View File

@ -1,98 +1,183 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/qcd/action/fermion/WilsonKernels.h Source file: ./lib/qcd/action/fermion/WilsonKernels.h
Copyright (C) 2015 Copyright (C) 2015
Author: Peter Boyle <pabobyle@ph.ed.ac.uk> Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
Author: Peter Boyle <paboyle@ph.ed.ac.uk> Author: Peter Boyle <paboyle@ph.ed.ac.uk>
Author: paboyle <paboyle@ph.ed.ac.uk> Author: paboyle <paboyle@ph.ed.ac.uk>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution
*************************************************************************************/ directory
/* END LEGAL */ *************************************************************************************/
#ifndef GRID_QCD_DHOP_H /* END LEGAL */
#define GRID_QCD_DHOP_H #ifndef GRID_QCD_DHOP_H
#define GRID_QCD_DHOP_H
namespace Grid { namespace Grid {
namespace QCD { namespace QCD {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helper routines that implement Wilson stencil for a single site. // Helper routines that implement Wilson stencil for a single site.
// Common to both the WilsonFermion and WilsonFermion5D // Common to both the WilsonFermion and WilsonFermion5D
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class WilsonKernelsStatic { class WilsonKernelsStatic {
public: public:
// S-direction is INNERMOST and takes no part in the parity. // S-direction is INNERMOST and takes no part in the parity.
static int AsmOpt; // these are a temporary hack static int AsmOpt; // these are a temporary hack
static int HandOpt; // these are a temporary hack static int HandOpt; // these are a temporary hack
}; };
template<class Impl> class WilsonKernels : public FermionOperator<Impl> , public WilsonKernelsStatic { template <class Impl>
public: class WilsonKernels : public FermionOperator<Impl>, public WilsonKernelsStatic {
public:
INHERIT_IMPL_TYPES(Impl);
typedef FermionOperator<Impl> Base;
INHERIT_IMPL_TYPES(Impl); public:
typedef FermionOperator<Impl> Base; template <bool EnableBool = true>
typename std::enable_if<Impl::Dimension == 3 && EnableBool, void>::type
public: DiracOptDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
void DiracOptDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, int sF, int sU, int Ls, int Ns, const FermionField &in,
int sF, int sU,int Ls, int Ns, const FermionField &in, FermionField &out); FermionField &out) {
#ifdef AVX512
void DiracOptDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, if (AsmOpt) {
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, WilsonKernels<Impl>::DiracOptAsmDhopSite(st, lo, U, buf, sF, sU, Ls, Ns,
int sF,int sU,int Ls, int Ns, const FermionField &in,FermionField &out); in, out);
void DiracOptDhopDir(StencilImpl &st,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,const FermionField &in, FermionField &out,int dirdisp,int gamma);
private:
// Specialised variants
void DiracOptGenericDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU, const FermionField &in, FermionField &out);
void DiracOptGenericDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,const FermionField &in,FermionField &out);
void DiracOptAsmDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,int Ls, int Ns, const FermionField &in, FermionField &out);
void DiracOptHandDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,const FermionField &in, FermionField &out);
void DiracOptHandDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int sF,int sU,const FermionField &in, FermionField &out);
public:
WilsonKernels(const ImplParams &p= ImplParams());
};
} else {
#else
{
#endif
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
if (HandOpt)
WilsonKernels<Impl>::DiracOptHandDhopSite(st, lo, U, buf, sF, sU,
in, out);
else
WilsonKernels<Impl>::DiracOptGenericDhopSite(st, lo, U, buf, sF, sU,
in, out);
sF++;
}
sU++;
}
}
} }
template <bool EnableBool = true>
typename std::enable_if<Impl::Dimension != 3 && EnableBool, void>::type
DiracOptDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, int Ls, int Ns, const FermionField &in,
FermionField &out) {
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
WilsonKernels<Impl>::DiracOptGenericDhopSite(st, lo, U, buf, sF, sU, in,
out);
sF++;
}
sU++;
}
}
template <bool EnableBool = true>
typename std::enable_if<Impl::Dimension == 3 && EnableBool, void>::type
DiracOptDhopSiteDag(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, int Ls, int Ns, const FermionField &in, FermionField &out) {
// No asm implementation yet.
// if ( AsmOpt )
// WilsonKernels<Impl>::DiracOptAsmDhopSiteDag(st,lo,U,buf,sF,sU,in,out);
// else
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
if (HandOpt)
WilsonKernels<Impl>::DiracOptHandDhopSiteDag(st, lo, U, buf, sF, sU,
in, out);
else
WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(st, lo, U, buf, sF,
sU, in, out);
sF++;
}
sU++;
}
}
template <bool EnableBool = true>
typename std::enable_if<Impl::Dimension != 3 && EnableBool, void>::type
DiracOptDhopSiteDag(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, int Ls, int Ns, const FermionField &in, FermionField &out) {
for (int site = 0; site < Ns; site++) {
for (int s = 0; s < Ls; s++) {
WilsonKernels<Impl>::DiracOptGenericDhopSiteDag(st, lo, U, buf, sF, sU,
in, out);
sF++;
}
sU++;
}
}
void DiracOptDhopDir(
StencilImpl &st, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, const FermionField &in, FermionField &out, int dirdisp,
int gamma);
private:
// Specialised variants
void DiracOptGenericDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, const FermionField &in, FermionField &out);
void DiracOptGenericDhopSiteDag(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, const FermionField &in, FermionField &out);
void DiracOptAsmDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, int Ls, int Ns, const FermionField &in,
FermionField &out);
void DiracOptHandDhopSite(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, const FermionField &in, FermionField &out);
void DiracOptHandDhopSiteDag(
StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
std::vector<SiteHalfSpinor, alignedAllocator<SiteHalfSpinor> > &buf,
int sF, int sU, const FermionField &in, FermionField &out);
public:
WilsonKernels(const ImplParams &p = ImplParams());
};
}
} }
#endif #endif

View File

@ -38,8 +38,8 @@ namespace QCD {
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Default to no assembler implementation // Default to no assembler implementation
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
template<class Impl> template<class Impl>
void WilsonKernels<Impl >::DiracOptAsmDhopSite(StencilImpl &st,LebesgueOrder & lo,DoubledGaugeField &U, void WilsonKernels<Impl>::DiracOptAsmDhopSite(StencilImpl &st,LebesgueOrder & lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int ss,int ssU,int Ls,int Ns,const FermionField &in, FermionField &out) int ss,int ssU,int Ls,int Ns,const FermionField &in, FermionField &out)
{ {

View File

@ -311,8 +311,8 @@ namespace Grid {
namespace QCD { namespace QCD {
template<class Impl> template<class Impl>
void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, void WilsonKernels<Impl>::DiracOptHandDhopSite(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int ss,int sU,const FermionField &in, FermionField &out) int ss,int sU,const FermionField &in, FermionField &out)
{ {
@ -554,8 +554,8 @@ void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,LebesgueOrder &l
} }
} }
template<class Impl> template<class Impl>
void WilsonKernels<Impl >::DiracOptHandDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U, void WilsonKernels<Impl>::DiracOptHandDhopSiteDag(StencilImpl &st,LebesgueOrder &lo,DoubledGaugeField &U,
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf, std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
int ss,int sU,const FermionField &in, FermionField &out) int ss,int sU,const FermionField &in, FermionField &out)
{ {

View File

@ -96,7 +96,7 @@ class NerscHmcRunnerTemplate {
GridSerialRNG sRNG; GridSerialRNG sRNG;
GridParallelRNG pRNG(UGrid); GridParallelRNG pRNG(UGrid);
LatticeGaugeField U(UGrid); // change this to an extended field (smearing class) LatticeGaugeField U(UGrid); // change this to an extended field (smearing class)?
std::vector<int> SerSeed({1, 2, 3, 4, 5}); std::vector<int> SerSeed({1, 2, 3, 4, 5});
std::vector<int> ParSeed({6, 7, 8, 9, 10}); std::vector<int> ParSeed({6, 7, 8, 9, 10});

View File

@ -72,7 +72,7 @@ struct AccessTypes<A, TupleClass, 0, S...> {
using elem = typename std::tuple_element<N, Rfields>::type; // fields types using elem = typename std::tuple_element<N, Rfields>::type; // fields types
typedef std::tuple<std::vector< A< elem<S> >* > ... > VectorCollection; typedef std::tuple<std::vector< A< elem<S> >* > ... > VectorCollection;
typedef std::tuple< A< elem<S> >* ... > ClassCollection; typedef std::tuple< elem<S> ... > FieldTypeCollection;
// Debug // Debug
void return_size() { void return_size() {

View File

@ -30,7 +30,6 @@ directory
*************************************************************************************/ *************************************************************************************/
/* END LEGAL */ /* END LEGAL */
#include "Grid.h" #include "Grid.h"
//#include "qcd/hmc/HmcRunner.h"
using namespace std; using namespace std;
using namespace Grid; using namespace Grid;
@ -62,6 +61,7 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); LatticeGaugeField U(UGrid);
//AdjointRepresentation::LatticeField Ua(UGrid);
// Gauge action // Gauge action
WilsonGaugeActionR Waction(5.6); WilsonGaugeActionR Waction(5.6);
@ -69,7 +69,7 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
Real mass = -0.77; Real mass = -0.77;
FermionAction FermOp(U, *FGrid, *FrbGrid, mass); FermionAction FermOp(U, *FGrid, *FrbGrid, mass);
ConjugateGradient<FermionField> CG(1.0e-8, 10000); ConjugateGradient<FermionField> CG(1.0e-6, 10000);
TwoFlavourPseudoFermionAction<ImplPolicy> Nf2(FermOp, CG, CG); TwoFlavourPseudoFermionAction<ImplPolicy> Nf2(FermOp, CG, CG);