2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
#include <Grid.h>
|
|
|
|
|
|
|
|
namespace Grid {
|
|
|
|
namespace QCD {
|
|
|
|
|
|
|
|
const std::vector<int> WilsonMatrix::directions ({0,1,2,3, 0, 1, 2, 3,0});
|
|
|
|
const std::vector<int> WilsonMatrix::displacements({1,1,1,1,-1,-1,-1,-1,0});
|
|
|
|
|
|
|
|
// Should be in header?
|
2015-04-26 15:51:09 +01:00
|
|
|
const int WilsonMatrix::Xp = 0;
|
|
|
|
const int WilsonMatrix::Yp = 1;
|
|
|
|
const int WilsonMatrix::Zp = 2;
|
|
|
|
const int WilsonMatrix::Tp = 3;
|
|
|
|
const int WilsonMatrix::Xm = 4;
|
|
|
|
const int WilsonMatrix::Ym = 5;
|
|
|
|
const int WilsonMatrix::Zm = 6;
|
|
|
|
const int WilsonMatrix::Tm = 7;
|
|
|
|
//const int WilsonMatrix::X0 = 8;
|
|
|
|
|
|
|
|
class WilsonCompressor {
|
|
|
|
public:
|
|
|
|
int mu;
|
|
|
|
|
2015-04-27 13:45:07 +01:00
|
|
|
void Point(int p) {
|
|
|
|
mu=p;
|
|
|
|
};
|
|
|
|
|
|
|
|
vHalfSpinColourVector operator () (const vSpinColourVector &in)
|
2015-04-26 15:51:09 +01:00
|
|
|
{
|
|
|
|
vHalfSpinColourVector ret;
|
|
|
|
switch(mu) {
|
|
|
|
case WilsonMatrix::Xp:
|
|
|
|
spProjXp(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Yp:
|
|
|
|
spProjYp(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Zp:
|
|
|
|
spProjZp(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Tp:
|
|
|
|
spProjTp(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Xm:
|
|
|
|
spProjXm(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Ym:
|
|
|
|
spProjYm(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Zm:
|
|
|
|
spProjZm(ret,in);
|
|
|
|
break;
|
|
|
|
case WilsonMatrix::Tm:
|
|
|
|
spProjTm(ret,in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
WilsonMatrix::WilsonMatrix(LatticeGaugeField &_Umu,double _mass)
|
|
|
|
: Stencil(Umu._grid,npoint,0,directions,displacements),
|
2015-04-25 14:33:02 +01:00
|
|
|
mass(_mass),
|
2015-04-26 15:51:09 +01:00
|
|
|
Umu(_Umu._grid)
|
2015-04-25 14:33:02 +01:00
|
|
|
{
|
|
|
|
// Allocate the required comms buffer
|
|
|
|
grid = _Umu._grid;
|
|
|
|
comm_buf.resize(Stencil._unified_buffer_size);
|
2015-04-26 15:51:09 +01:00
|
|
|
DoubleStore(Umu,_Umu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WilsonMatrix::DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu)
|
|
|
|
{
|
|
|
|
LatticeColourMatrix U(grid);
|
|
|
|
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
U = peekIndex<LorentzIndex>(Umu,mu);
|
|
|
|
pokeIndex<LorentzIndex>(Uds,U,mu);
|
|
|
|
U = adj(Cshift(U,mu,-1));
|
|
|
|
pokeIndex<LorentzIndex>(Uds,U,mu+4);
|
|
|
|
}
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
2015-04-26 15:51:09 +01:00
|
|
|
|
2015-04-25 14:33:02 +01:00
|
|
|
void WilsonMatrix::multiply(const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
Dhop(in,out);
|
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
2015-04-26 15:51:09 +01:00
|
|
|
|
2015-04-25 14:33:02 +01:00
|
|
|
void WilsonMatrix::Dhop(const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-27 13:45:07 +01:00
|
|
|
WilsonCompressor compressor;
|
|
|
|
Stencil.HaloExchange<vSpinColourVector,vHalfSpinColourVector,WilsonCompressor>(in,comm_buf,compressor);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
vHalfSpinColourVector tmp;
|
|
|
|
vHalfSpinColourVector chi;
|
|
|
|
vSpinColourVector result;
|
|
|
|
vHalfSpinColourVector Uchi;
|
|
|
|
int offset,local,perm, ptype;
|
2015-04-25 14:33:02 +01:00
|
|
|
|
2015-05-12 07:51:41 +01:00
|
|
|
PARALLEL_FOR_LOOP
|
2015-04-30 16:39:06 +01:00
|
|
|
for(int sss=0;sss<grid->oSites();sss++){
|
2015-04-25 14:33:02 +01:00
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
int ss = sss;
|
2015-05-13 00:31:00 +01:00
|
|
|
int ssu= ss;
|
|
|
|
// int ss = Stencil._LebesgueReorder[sss];
|
2015-04-27 13:45:07 +01:00
|
|
|
|
2015-04-25 14:33:02 +01:00
|
|
|
// Xp
|
|
|
|
offset = Stencil._offsets [Xp][ss];
|
|
|
|
local = Stencil._is_local[Xp][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Xp][ss];
|
|
|
|
ptype = Stencil._permute_type[Xp];
|
2015-05-13 00:31:00 +01:00
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjXp(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjXp(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Xp),&chi());
|
2015-05-10 23:29:21 +01:00
|
|
|
//prefetch(Umu._odata[ssu](Yp));
|
2015-04-26 15:51:09 +01:00
|
|
|
spReconXp(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Yp
|
|
|
|
offset = Stencil._offsets [Yp][ss];
|
|
|
|
local = Stencil._is_local[Yp][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Yp][ss];
|
|
|
|
ptype = Stencil._permute_type[Yp];
|
2015-04-30 16:39:06 +01:00
|
|
|
|
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjYp(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjYp(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Yp),&chi());
|
2015-05-10 23:29:21 +01:00
|
|
|
// prefetch(Umu._odata[ssu](Zp));
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconYp(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Zp
|
|
|
|
offset = Stencil._offsets [Zp][ss];
|
|
|
|
local = Stencil._is_local[Zp][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Zp][ss];
|
|
|
|
ptype = Stencil._permute_type[Zp];
|
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjZp(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjZp(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Zp),&chi());
|
2015-05-10 23:29:21 +01:00
|
|
|
// prefetch(Umu._odata[ssu](Tp));
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconZp(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Tp
|
|
|
|
offset = Stencil._offsets [Tp][ss];
|
|
|
|
local = Stencil._is_local[Tp][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Tp][ss];
|
|
|
|
ptype = Stencil._permute_type[Tp];
|
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjTp(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjTp(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Tp),&chi());
|
2015-05-10 23:29:21 +01:00
|
|
|
// prefetch(Umu._odata[ssu](Xm));
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconTp(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Xm
|
|
|
|
offset = Stencil._offsets [Xm][ss];
|
|
|
|
local = Stencil._is_local[Xm][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Xm][ss];
|
|
|
|
ptype = Stencil._permute_type[Xm];
|
2015-04-30 16:39:06 +01:00
|
|
|
|
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjXm(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjXm(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Xm),&chi());
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconXm(result,Uchi);
|
2015-04-28 08:11:59 +01:00
|
|
|
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Ym
|
|
|
|
offset = Stencil._offsets [Ym][ss];
|
|
|
|
local = Stencil._is_local[Ym][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Ym][ss];
|
|
|
|
ptype = Stencil._permute_type[Ym];
|
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjYm(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjYm(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Ym),&chi());
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconYm(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Zm
|
|
|
|
offset = Stencil._offsets [Zm][ss];
|
|
|
|
local = Stencil._is_local[Zm][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Zm][ss];
|
|
|
|
ptype = Stencil._permute_type[Zm];
|
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjZm(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjZm(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Zm),&chi());
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconZm(result,Uchi);
|
2015-04-25 14:33:02 +01:00
|
|
|
|
|
|
|
// Tm
|
|
|
|
offset = Stencil._offsets [Tm][ss];
|
|
|
|
local = Stencil._is_local[Tm][ss];
|
2015-04-28 08:11:59 +01:00
|
|
|
perm = Stencil._permute[Tm][ss];
|
|
|
|
ptype = Stencil._permute_type[Tm];
|
|
|
|
|
2015-04-30 16:39:06 +01:00
|
|
|
if ( local && perm )
|
|
|
|
{
|
|
|
|
spProjTm(tmp,in._odata[offset]);
|
|
|
|
permute(chi,tmp,ptype);
|
|
|
|
} else if ( local ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
spProjTm(chi,in._odata[offset]);
|
2015-04-30 16:39:06 +01:00
|
|
|
} else {
|
|
|
|
chi=comm_buf[offset];
|
2015-04-28 08:11:59 +01:00
|
|
|
}
|
2015-05-10 15:25:23 +01:00
|
|
|
mult(&Uchi(),&Umu._odata[ssu](Tm),&chi());
|
2015-04-26 15:51:09 +01:00
|
|
|
accumReconTm(result,Uchi);
|
2015-04-28 08:11:59 +01:00
|
|
|
|
2015-05-05 22:09:22 +01:00
|
|
|
vstream(out._odata[ss],result);
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-04-30 16:39:06 +01:00
|
|
|
|
|
|
|
|
2015-04-25 14:33:02 +01:00
|
|
|
void WilsonMatrix::Dw(const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
void WilsonMatrix::MpcDag (const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
void WilsonMatrix::Mpc (const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
void WilsonMatrix::MpcDagMpc(const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
void WilsonMatrix::MDagM (const LatticeFermion &in, LatticeFermion &out)
|
|
|
|
{
|
2015-04-26 15:51:09 +01:00
|
|
|
return;
|
2015-04-25 14:33:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
2015-04-26 15:51:09 +01:00
|
|
|
|