From 99e2c1e6666263a8538bff6205be92a7a0c08451 Mon Sep 17 00:00:00 2001 From: Azusa Yamaguchi Date: Mon, 12 Dec 2016 09:08:53 +0000 Subject: [PATCH] Kernels options --- lib/qcd/action/fermion/StaggeredKernels.cc | 28 ++++++++++++++++++---- lib/qcd/action/fermion/StaggeredKernels.h | 6 +++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/qcd/action/fermion/StaggeredKernels.cc b/lib/qcd/action/fermion/StaggeredKernels.cc index b437199c..6608f8de 100644 --- a/lib/qcd/action/fermion/StaggeredKernels.cc +++ b/lib/qcd/action/fermion/StaggeredKernels.cc @@ -30,6 +30,8 @@ directory namespace Grid { namespace QCD { +int StaggeredKernelsStatic::Opt; + template StaggeredKernels::StaggeredKernels(const ImplParams &p) : Base(p){}; @@ -189,8 +191,17 @@ void StaggeredKernels::DhopSiteDag(StencilImpl &st, LebesgueOrder &lo, Dou SiteSpinor naive; int oneLink =0; int threeLink=1; - DhopSiteDepth(st,lo,U,buf,sF,sU,in,naive,oneLink); - DhopSiteDepth(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + switch(Opt) { + case OptHandUnroll: + DhopSiteDepthHand(st,lo,U,buf,sF,sU,in,naive,oneLink); + DhopSiteDepthHand(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + break; + case OptGeneric: + default: + DhopSiteDepth(st,lo,U,buf,sF,sU,in,naive,oneLink); + DhopSiteDepth(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + break; + } out._odata[sF] =-naive-naik; }; template @@ -201,8 +212,17 @@ void StaggeredKernels::DhopSite(StencilImpl &st, LebesgueOrder &lo, Double SiteSpinor naive; int oneLink =0; int threeLink=1; - DhopSiteDepth(st,lo,U,buf,sF,sU,in,naive,oneLink); - DhopSiteDepth(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + switch(Opt) { + case OptHandUnroll: + DhopSiteDepthHand(st,lo,U,buf,sF,sU,in,naive,oneLink); + DhopSiteDepthHand(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + break; + case OptGeneric: + default: + DhopSiteDepth(st,lo,U,buf,sF,sU,in,naive,oneLink); + DhopSiteDepth(st,lo,UUU,buf,sF,sU,in,naik,threeLink); + break; + } out._odata[sF] =naive+naik; }; diff --git a/lib/qcd/action/fermion/StaggeredKernels.h b/lib/qcd/action/fermion/StaggeredKernels.h index f51a4b37..5a6cb45c 100644 --- a/lib/qcd/action/fermion/StaggeredKernels.h +++ b/lib/qcd/action/fermion/StaggeredKernels.h @@ -37,6 +37,9 @@ namespace QCD { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// class StaggeredKernelsStatic { public: + enum { OptGeneric, OptHandUnroll, OptInlineAsm }; + // S-direction is INNERMOST and takes no part in the parity. + static int Opt; // these are a temporary hack }; template class StaggeredKernels : public FermionOperator , public StaggeredKernelsStatic { @@ -52,6 +55,9 @@ public: void DhopSiteDepth(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, SiteSpinor * buf, int sF, int sU, const FermionField &in, SiteSpinor &out,int threeLink); + + void DhopSiteDepthHand(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, SiteSpinor * buf, + int sF, int sU, const FermionField &in, SiteSpinor &out,int threeLink); void DhopSite(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, DoubledGaugeField &UUU, SiteSpinor * buf, int sF, int sU, const FermionField &in, FermionField &out);