1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-24 12:45:56 +01:00

Implement Dirichlet Comms option

This commit is contained in:
Peter Boyle 2021-05-06 23:44:45 +02:00
parent f776a7fe4a
commit 4fca66a7c6
5 changed files with 85 additions and 8 deletions

View File

@ -146,6 +146,9 @@ public:
void DhopInternalSerial(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, void DhopInternalSerial(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
const FermionField &in, FermionField &out, int dag); const FermionField &in, FermionField &out, int dag);
void DhopInternalDirichlet(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
const FermionField &in, FermionField &out, int dag);
void DhopInternalOverlappedComms(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U, void DhopInternalOverlappedComms(StencilImpl &st, LebesgueOrder &lo, DoubledGaugeField &U,
const FermionField &in, FermionField &out, int dag); const FermionField &in, FermionField &out, int dag);

View File

@ -165,7 +165,14 @@ public:
const FermionField &in, const FermionField &in,
FermionField &out, FermionField &out,
int dag); int dag);
void DhopInternalDirichletComms(StencilImpl & st,
LebesgueOrder &lo,
DoubledGaugeField &U,
const FermionField &in,
FermionField &out,
int dag);
// Constructors // Constructors
WilsonFermion5D(GaugeField &_Umu, WilsonFermion5D(GaugeField &_Umu,
GridCartesian &FiveDimGrid, GridCartesian &FiveDimGrid,

View File

@ -39,7 +39,7 @@ NAMESPACE_BEGIN(Grid);
class WilsonKernelsStatic { class WilsonKernelsStatic {
public: public:
enum { OptGeneric, OptHandUnroll, OptInlineAsm }; enum { OptGeneric, OptHandUnroll, OptInlineAsm };
enum { CommsAndCompute, CommsThenCompute }; enum { CommsAndCompute, CommsThenCompute, CommsDirichlet };
static int Opt; static int Opt;
static int Comms; static int Comms;
}; };

View File

@ -361,10 +361,21 @@ void WilsonFermion5D<Impl>::DhopInternal(StencilImpl & st, LebesgueOrder &lo,
const FermionField &in, FermionField &out,int dag) const FermionField &in, FermionField &out,int dag)
{ {
DhopTotalTime-=usecond(); DhopTotalTime-=usecond();
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute )
assert( (WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute)
||(WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute)
||(WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsDirichlet) );
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) {
DhopInternalOverlappedComms(st,lo,U,in,out,dag); DhopInternalOverlappedComms(st,lo,U,in,out,dag);
else }
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute ) {
DhopInternalSerialComms(st,lo,U,in,out,dag); DhopInternalSerialComms(st,lo,U,in,out,dag);
}
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsDirichlet ) {
DhopInternalDirichletComms(st,lo,U,in,out,dag);
}
DhopTotalTime+=usecond(); DhopTotalTime+=usecond();
} }
@ -431,6 +442,30 @@ void WilsonFermion5D<Impl>::DhopInternalOverlappedComms(StencilImpl & st, Lebesg
DhopComputeTime2+=usecond(); DhopComputeTime2+=usecond();
} }
template<class Impl>
void WilsonFermion5D<Impl>::DhopInternalDirichletComms(StencilImpl & st, LebesgueOrder &lo,
DoubledGaugeField & U,
const FermionField &in, FermionField &out,int dag)
{
Compressor compressor(dag);
int LLs = in.Grid()->_rdimensions[0];
int len = U.Grid()->oSites();
/////////////////////////////
// do the compute interior
/////////////////////////////
int Opt = WilsonKernelsStatic::Opt; // Why pass this. Kernels should know
DhopComputeTime-=usecond();
if (dag == DaggerYes) {
Kernels::DhopDagKernel(Opt,st,U,st.CommBuf(),LLs,U.oSites(),in,out,1,0);
} else {
Kernels::DhopKernel (Opt,st,U,st.CommBuf(),LLs,U.oSites(),in,out,1,0);
}
DhopComputeTime+=usecond();
}
template<class Impl> template<class Impl>
void WilsonFermion5D<Impl>::DhopInternalSerialComms(StencilImpl & st, LebesgueOrder &lo, void WilsonFermion5D<Impl>::DhopInternalSerialComms(StencilImpl & st, LebesgueOrder &lo,

View File

@ -488,12 +488,21 @@ void WilsonFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder &lo,
FermionField &out, int dag) FermionField &out, int dag)
{ {
DhopTotalTime-=usecond(); DhopTotalTime-=usecond();
#ifdef GRID_OMP
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) assert( (WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute)
||(WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute)
||(WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsDirichlet) );
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) {
DhopInternalOverlappedComms(st,lo,U,in,out,dag); DhopInternalOverlappedComms(st,lo,U,in,out,dag);
else }
#endif if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute ) {
DhopInternalSerial(st,lo,U,in,out,dag); DhopInternalSerial(st,lo,U,in,out,dag);
}
if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsDirichlet ) {
DhopInternalDirichletComms(st,lo,U,in,out,dag);
}
DhopTotalTime+=usecond(); DhopTotalTime+=usecond();
} }
@ -562,6 +571,29 @@ void WilsonFermion<Impl>::DhopInternalOverlappedComms(StencilImpl &st, LebesgueO
DhopComputeTime2+=usecond(); DhopComputeTime2+=usecond();
}; };
template <class Impl>
void WilsonFermion<Impl>::DhopDirichletComms(StencilImpl &st, LebesgueOrder &lo,
DoubledGaugeField &U,
const FermionField &in,
FermionField &out, int dag)
{
assert((dag == DaggerNo) || (dag == DaggerYes));
Compressor compressor(dag);
int len = U.Grid()->oSites();
/////////////////////////////
// do the compute interior
/////////////////////////////
int Opt = WilsonKernelsStatic::Opt;
DhopComputeTime-=usecond();
if (dag == DaggerYes) {
Kernels::DhopDagKernel(Opt,st,U,st.CommBuf(),1,U.oSites(),in,out,1,0);
} else {
Kernels::DhopKernel(Opt,st,U,st.CommBuf(),1,U.oSites(),in,out,1,0);
}
DhopComputeTime+=usecond();
};
template <class Impl> template <class Impl>
void WilsonFermion<Impl>::DhopInternalSerial(StencilImpl &st, LebesgueOrder &lo, void WilsonFermion<Impl>::DhopInternalSerial(StencilImpl &st, LebesgueOrder &lo,