1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

View location & access mode

This commit is contained in:
Peter Boyle 2020-05-21 16:13:59 -04:00
parent 7860a50f70
commit a7abda89e2
8 changed files with 47 additions and 47 deletions

View File

@ -252,9 +252,9 @@ public:
double start=usecond(); double start=usecond();
for(int i=0;i<Nloop;i++){ for(int i=0;i<Nloop;i++){
z=a*x-y; z=a*x-y;
auto x_v = x.View(); auto x_v = x.View(CpuWrite);
auto y_v = y.View(); auto y_v = y.View(CpuWrite);
auto z_v = z.View(); auto z_v = z.View(CpuRead);
x_v[0]=z_v[0]; // force serial dependency to prevent optimise away x_v[0]=z_v[0]; // force serial dependency to prevent optimise away
y_v[4]=z_v[4]; y_v[4]=z_v[4];
} }
@ -534,8 +534,8 @@ public:
{ {
LatticeGaugeField Umu5d(FGrid); LatticeGaugeField Umu5d(FGrid);
std::vector<LatticeColourMatrix> U(4,FGrid); std::vector<LatticeColourMatrix> U(4,FGrid);
auto Umu_v = Umu.View(); auto Umu_v = Umu.View(CpuRead);
auto Umu5d_v = Umu5d.View(); auto Umu5d_v = Umu5d.View(CpuWrite);
for(int ss=0;ss<Umu.Grid()->oSites();ss++){ for(int ss=0;ss<Umu.Grid()->oSites();ss++){
for(int s=0;s<Ls;s++){ for(int s=0;s<Ls;s++){
Umu5d_v[Ls*ss+s] = Umu_v[ss]; Umu5d_v[Ls*ss+s] = Umu_v[ss];

View File

@ -129,8 +129,8 @@ int main (int argc, char ** argv)
LatticeGaugeField Umu5d(FGrid); LatticeGaugeField Umu5d(FGrid);
std::vector<LatticeColourMatrix> U(4,FGrid); std::vector<LatticeColourMatrix> U(4,FGrid);
{ {
auto Umu5d_v = Umu5d.View(); auto Umu5d_v = Umu5d.View(CpuWrite);
auto Umu_v = Umu.View(); auto Umu_v = Umu.View(CpuRead);
for(int ss=0;ss<Umu.Grid()->oSites();ss++){ for(int ss=0;ss<Umu.Grid()->oSites();ss++){
for(int s=0;s<Ls;s++){ for(int s=0;s<Ls;s++){
Umu5d_v[Ls*ss+s] = Umu_v[ss]; Umu5d_v[Ls*ss+s] = Umu_v[ss];
@ -258,8 +258,8 @@ int main (int argc, char ** argv)
// ref = src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x // ref = src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x
tmp = U[mu]*Cshift(src,mu+1,1); tmp = U[mu]*Cshift(src,mu+1,1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuRead);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ;
} }
@ -268,8 +268,8 @@ int main (int argc, char ** argv)
tmp =adj(U[mu])*src; tmp =adj(U[mu])*src;
tmp =Cshift(tmp,mu+1,-1); tmp =Cshift(tmp,mu+1,-1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuRead);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ;
} }

View File

@ -130,8 +130,8 @@ void benchDw(std::vector<int> & latt4, int Ls, int threads,int report )
LatticeGaugeField Umu5d(FGrid); LatticeGaugeField Umu5d(FGrid);
// replicate across fifth dimension // replicate across fifth dimension
auto Umu5d_v = Umu5d.View(); auto Umu5d_v = Umu5d.View(CpuWrite);
auto Umu_v = Umu.View(); auto Umu_v = Umu.View(CpuRead);
for(int ss=0;ss<Umu.Grid()->oSites();ss++){ for(int ss=0;ss<Umu.Grid()->oSites();ss++){
for(int s=0;s<Ls;s++){ for(int s=0;s<Ls;s++){
Umu5d_v[Ls*ss+s] = Umu_v[ss]; Umu5d_v[Ls*ss+s] = Umu_v[ss];

View File

@ -79,7 +79,7 @@ int main (int argc, char ** argv)
double start=usecond(); double start=usecond();
thread_for(t,threads,{ thread_for(t,threads,{
auto x_t = x[t].View(); auto x_t = x[t].View(CpuRead);
sum[t] = x_t[0]; sum[t] = x_t[0];
for(int i=0;i<Nloop;i++){ for(int i=0;i<Nloop;i++){
for(auto ss=x_t.begin();ss<x_t.end();ss++){ for(auto ss=x_t.begin();ss<x_t.end();ss++){

View File

@ -177,7 +177,7 @@ int main (int argc, char ** argv)
Real nn; Real nn;
double start=usecond(); double start=usecond();
for(int i=0;i<Nloop;i++){ for(int i=0;i<Nloop;i++){
auto x_v = x.View(); auto x_v = x.View(CpuWrite);
nn=norm2(x); nn=norm2(x);
vsplat(x_v[0]._internal[0],nn); vsplat(x_v[0]._internal[0],nn);
} }

View File

@ -85,11 +85,11 @@ void sliceInnerProductMesonField(std::vector< std::vector<ComplexD> > &mat,
for(int b=0;b<e2;b++){ for(int b=0;b<e2;b++){
int ss= so+n*stride+b; int ss= so+n*stride+b;
for(int i=0;i<Lblock;i++){ for(int i=0;i<Lblock;i++){
auto lhs_v = lhs[i].View(); auto lhs_v = lhs[i].View(CpuRead);
auto left = conjugate(lhs_v[ss]); auto left = conjugate(lhs_v[ss]);
for(int j=0;j<Rblock;j++){ for(int j=0;j<Rblock;j++){
int idx = i+Lblock*j+Lblock*Rblock*r; int idx = i+Lblock*j+Lblock*Rblock*r;
auto rhs_v = rhs[j].View(); auto rhs_v = rhs[j].View(CpuRead);
auto right = rhs_v[ss]; auto right = rhs_v[ss];
vector_type vv = left()(0)(0) * right()(0)(0) vector_type vv = left()(0)(0) * right()(0)(0)
+ left()(0)(1) * right()(0)(1) + left()(0)(1) * right()(0)(1)
@ -221,12 +221,12 @@ void sliceInnerProductMesonFieldGamma(std::vector< std::vector<ComplexD> > &mat,
for(int b=0;b<e2;b++){ for(int b=0;b<e2;b++){
int ss= so+n*stride+b; int ss= so+n*stride+b;
for(int i=0;i<Lblock;i++){ for(int i=0;i<Lblock;i++){
auto lhs_v=lhs[i].View(); auto lhs_v=lhs[i].View(CpuRead);
auto left = conjugate(lhs_v[ss]); auto left = conjugate(lhs_v[ss]);
for(int j=0;j<Rblock;j++){ for(int j=0;j<Rblock;j++){
for(int mu=0;mu<Ngamma;mu++){ for(int mu=0;mu<Ngamma;mu++){
auto rhs_v = rhs[j].View(); auto rhs_v = rhs[j].View(CpuRead);
auto right = Gamma(gammas[mu])*rhs_v[ss]; auto right = Gamma(gammas[mu])*rhs_v[ss];
vector_type vv = left()(0)(0) * right()(0)(0) vector_type vv = left()(0)(0) * right()(0)(0)
@ -370,12 +370,12 @@ void sliceInnerProductMesonFieldGamma1(std::vector< std::vector<ComplexD> > &mat
int ss= so+n*stride+b; int ss= so+n*stride+b;
for(int i=0;i<Lblock;i++){ for(int i=0;i<Lblock;i++){
auto lhs_v=lhs[i].View(); auto lhs_v=lhs[i].View(CpuRead);
auto left = conjugate(lhs_v[ss]); auto left = conjugate(lhs_v[ss]);
for(int j=0;j<Rblock;j++){ for(int j=0;j<Rblock;j++){
SpinMatrix_v vv; SpinMatrix_v vv;
auto rhs_v = rhs[j].View(); auto rhs_v = rhs[j].View(CpuRead);
auto right = rhs_v[ss]; auto right = rhs_v[ss];
for(int s1=0;s1<Ns;s1++){ for(int s1=0;s1<Ns;s1++){
for(int s2=0;s2<Ns;s2++){ for(int s2=0;s2<Ns;s2++){
@ -518,12 +518,12 @@ void sliceInnerProductMesonFieldGammaMom(std::vector< std::vector<ComplexD> > &m
for(int i=0;i<Lblock;i++){ for(int i=0;i<Lblock;i++){
auto lhs_v = lhs[i].View(); auto lhs_v = lhs[i].View(CpuRead);
auto left = conjugate(lhs_v[ss]); auto left = conjugate(lhs_v[ss]);
for(int j=0;j<Rblock;j++){ for(int j=0;j<Rblock;j++){
SpinMatrix_v vv; SpinMatrix_v vv;
auto rhs_v = rhs[j].View(); auto rhs_v = rhs[j].View(CpuRead);
auto right = rhs_v[ss]; auto right = rhs_v[ss];
for(int s1=0;s1<Ns;s1++){ for(int s1=0;s1<Ns;s1++){
for(int s2=0;s2<Ns;s2++){ for(int s2=0;s2<Ns;s2++){
@ -537,7 +537,7 @@ void sliceInnerProductMesonFieldGammaMom(std::vector< std::vector<ComplexD> > &m
// Trigger unroll // Trigger unroll
for ( int m=0;m<Nmom;m++){ for ( int m=0;m<Nmom;m++){
int idx = m+base; int idx = m+base;
auto mom_v = mom[m].View(); auto mom_v = mom[m].View(CpuRead);
auto phase = mom_v[ss]; auto phase = mom_v[ss];
mac(&lvSum[idx],&vv,&phase); mac(&lvSum[idx],&vv,&phase);
} }

View File

@ -66,9 +66,9 @@ int main (int argc, char ** argv)
LatticeColourMatrix x(&Grid);// random(pRNG,x); LatticeColourMatrix x(&Grid);// random(pRNG,x);
LatticeColourMatrix y(&Grid);// random(pRNG,y); LatticeColourMatrix y(&Grid);// random(pRNG,y);
auto x_v = x.View(); auto x_v = x.View(AcceleratorRead);
auto y_v = y.View(); auto y_v = y.View(AcceleratorRead);
auto z_v = z.View(); auto z_v = z.View(AcceleratorWrite);
const uint64_t Nsite = x_v.size(); const uint64_t Nsite = x_v.size();
const uint64_t nsimd = vComplex::Nsimd(); const uint64_t nsimd = vComplex::Nsimd();
for(int64_t i=0;i<Nwarm;i++){ for(int64_t i=0;i<Nwarm;i++){
@ -116,9 +116,9 @@ int main (int argc, char ** argv)
LatticeColourMatrix x(&Grid);// random(pRNG,x); LatticeColourMatrix x(&Grid);// random(pRNG,x);
LatticeColourMatrix y(&Grid);// random(pRNG,y); LatticeColourMatrix y(&Grid);// random(pRNG,y);
auto x_v = x.View(); auto x_v = x.View(AcceleratorWrite);
auto y_v = y.View(); auto y_v = y.View(AcceleratorRead);
auto z_v = z.View(); auto z_v = z.View(AcceleratorRead);
const uint64_t Nsite = x_v.size(); const uint64_t Nsite = x_v.size();
const uint64_t nsimd = vComplex::Nsimd(); const uint64_t nsimd = vComplex::Nsimd();
for(int64_t i=0;i<Nwarm;i++){ for(int64_t i=0;i<Nwarm;i++){
@ -167,9 +167,9 @@ int main (int argc, char ** argv)
LatticeColourMatrix x(&Grid);// random(pRNG,x); LatticeColourMatrix x(&Grid);// random(pRNG,x);
LatticeColourMatrix y(&Grid);// random(pRNG,y); LatticeColourMatrix y(&Grid);// random(pRNG,y);
auto x_v = x.View(); auto x_v = x.View(AcceleratorRead);
auto y_v = y.View(); auto y_v = y.View(AcceleratorRead);
auto z_v = z.View(); auto z_v = z.View(AcceleratorWrite);
const uint64_t Nsite = x_v.size(); const uint64_t Nsite = x_v.size();
const uint64_t nsimd = vComplex::Nsimd(); const uint64_t nsimd = vComplex::Nsimd();
for(int64_t i=0;i<Nwarm;i++){ for(int64_t i=0;i<Nwarm;i++){
@ -220,10 +220,10 @@ int main (int argc, char ** argv)
LatticeColourMatrix y(&Grid);// random(pRNG,y); LatticeColourMatrix y(&Grid);// random(pRNG,y);
LatticeColourMatrix w(&Grid);// random(pRNG,y); LatticeColourMatrix w(&Grid);// random(pRNG,y);
auto x_v = x.View(); auto x_v = x.View(AcceleratorRead);
auto y_v = y.View(); auto y_v = y.View(AcceleratorRead);
auto z_v = z.View(); auto z_v = z.View(AcceleratorRead);
auto w_v = z.View(); auto w_v = w.View(AcceleratorWrite);
const uint64_t Nsite = x_v.size(); const uint64_t Nsite = x_v.size();
const uint64_t nsimd = vComplex::Nsimd(); const uint64_t nsimd = vComplex::Nsimd();
for(int64_t i=0;i<Nwarm;i++){ for(int64_t i=0;i<Nwarm;i++){

View File

@ -125,8 +125,8 @@ int main (int argc, char ** argv)
// ref = src + Gamma(Gamma::Algebra::GammaX)* src ; // 1-gamma_x // ref = src + Gamma(Gamma::Algebra::GammaX)* src ; // 1-gamma_x
tmp = U[mu]*Cshift(src,mu,1); tmp = U[mu]*Cshift(src,mu,1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuWrite);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ;
} }
@ -135,8 +135,8 @@ int main (int argc, char ** argv)
tmp =adj(U[mu])*src; tmp =adj(U[mu])*src;
tmp =Cshift(tmp,mu,-1); tmp =Cshift(tmp,mu,-1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuWrite);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ;
} }
@ -187,8 +187,8 @@ int main (int argc, char ** argv)
for(int ss=0;ss<0;ss++ ){ for(int ss=0;ss<0;ss++ ){
for(int i=0;i<Ns;i++){ for(int i=0;i<Ns;i++){
for(int j=0;j<Nc;j++){ for(int j=0;j<Nc;j++){
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto result_v = result.View(); auto result_v = result.View(CpuWrite);
ComplexF * ref_p = (ComplexF *)&ref_v[ss]()(i)(j); ComplexF * ref_p = (ComplexF *)&ref_v[ss]()(i)(j);
ComplexF * res_p = (ComplexF *)&result_v[ss]()(i)(j); ComplexF * res_p = (ComplexF *)&result_v[ss]()(i)(j);
std::cout<<GridLogMessage << ss<< " "<<i<<" "<<j<<" "<< (*ref_p)<<" " <<(*res_p)<<std::endl; std::cout<<GridLogMessage << ss<< " "<<i<<" "<<j<<" "<< (*ref_p)<<" " <<(*res_p)<<std::endl;
@ -204,8 +204,8 @@ int main (int argc, char ** argv)
// ref = src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x // ref = src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x
tmp = U[mu]*Cshift(src,mu,1); tmp = U[mu]*Cshift(src,mu,1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuWrite);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] + Gamma(Gmu[mu])*tmp_v[i]; ;
} }
@ -214,8 +214,8 @@ int main (int argc, char ** argv)
tmp =adj(U[mu])*src; tmp =adj(U[mu])*src;
tmp =Cshift(tmp,mu,-1); tmp =Cshift(tmp,mu,-1);
{ {
auto ref_v = ref.View(); auto ref_v = ref.View(CpuWrite);
auto tmp_v = tmp.View(); auto tmp_v = tmp.View(CpuWrite);
for(int i=0;i<ref_v.size();i++){ for(int i=0;i<ref_v.size();i++){
ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ; ref_v[i]+= tmp_v[i] - Gamma(Gmu[mu])*tmp_v[i]; ;
} }