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

View locatoin and access mode

This commit is contained in:
Peter Boyle 2020-05-21 16:14:20 -04:00
parent a7abda89e2
commit f999408e92
22 changed files with 76 additions and 77 deletions

View File

@ -107,8 +107,8 @@ int main(int argc, char ** argv)
// Implement a stencil code that should agree with cshift! // Implement a stencil code that should agree with cshift!
for(int i=0;i<Check.Grid()->oSites();i++){ for(int i=0;i<Check.Grid()->oSites();i++){
auto SE = gStencil.GetEntry(0,i); auto SE = gStencil.GetEntry(0,i);
auto check = Check.View(); auto check = Check.View(CpuWrite);
auto foo = Foo.View(); auto foo = Foo.View(CpuRead);
// Encapsulate in a general wrapper // Encapsulate in a general wrapper
check[i] = foo[SE->_offset]; auto tmp=check[i]; check[i] = foo[SE->_offset]; auto tmp=check[i];
@ -147,8 +147,8 @@ int main(int argc, char ** argv)
}}}} }}}}
if (nrm > 1.0e-4) { if (nrm > 1.0e-4) {
auto check = Check.View(); auto check = Check.View(CpuRead);
auto bar = Bar.View(); auto bar = Bar.View(CpuRead);
for(int i=0;i<check.size();i++){ for(int i=0;i<check.size();i++){
std::cout << i<<" Check "<<check[i]<< "\n"<<i<<" Bar "<<bar[i]<<std::endl; std::cout << i<<" Check "<<check[i]<< "\n"<<i<<" Bar "<<bar[i]<<std::endl;
} }

View File

@ -109,8 +109,8 @@ int main(int argc, char ** argv) {
StencilEntry *SE; StencilEntry *SE;
SE = myStencil.GetEntry(permute_type,0,i); SE = myStencil.GetEntry(permute_type,0,i);
auto check = Check.View(); auto check = Check.View(CpuWrite);
auto foo = Foo.View(); auto foo = Foo.View(CpuRead);
if ( SE->_is_local && SE->_permute ) if ( SE->_is_local && SE->_permute )
permute(check[i],foo[SE->_offset],permute_type); permute(check[i],foo[SE->_offset],permute_type);
else if (SE->_is_local) else if (SE->_is_local)
@ -151,8 +151,8 @@ int main(int argc, char ** argv) {
}}}} }}}}
if (nrm > 1.0e-4) { if (nrm > 1.0e-4) {
auto check = Check.View(); auto check = Check.View(CpuRead);
auto bar = Bar.View(); auto bar = Bar.View(CpuRead);
for(int i=0;i<check.size();i++){ for(int i=0;i<check.size();i++){
std::cout << i<<" Check "<<check[i]<< "\n"<<i<<" Bar "<<bar[i]<<std::endl; std::cout << i<<" Check "<<check[i]<< "\n"<<i<<" Bar "<<bar[i]<<std::endl;
} }
@ -210,8 +210,8 @@ int main(int argc, char ** argv) {
SE = EStencil.GetEntry(permute_type,0,i); SE = EStencil.GetEntry(permute_type,0,i);
// std::cout << "Even source "<< i<<" -> " <<SE->_offset << " "<< SE->_is_local<<std::endl; // std::cout << "Even source "<< i<<" -> " <<SE->_offset << " "<< SE->_is_local<<std::endl;
auto ocheck = OCheck.View(); auto ocheck = OCheck.View(CpuWrite);
auto efoo = EFoo.View(); auto efoo = EFoo.View(CpuRead);
if ( SE->_is_local && SE->_permute ) if ( SE->_is_local && SE->_permute )
permute(ocheck[i],efoo[SE->_offset],permute_type); permute(ocheck[i],efoo[SE->_offset],permute_type);
else if (SE->_is_local) else if (SE->_is_local)
@ -226,8 +226,8 @@ int main(int argc, char ** argv) {
SE = OStencil.GetEntry(permute_type,0,i); SE = OStencil.GetEntry(permute_type,0,i);
// std::cout << "ODD source "<< i<<" -> " <<SE->_offset << " "<< SE->_is_local<<std::endl; // std::cout << "ODD source "<< i<<" -> " <<SE->_offset << " "<< SE->_is_local<<std::endl;
auto echeck = ECheck.View(); auto echeck = ECheck.View(CpuWrite);
auto ofoo = OFoo.View(); auto ofoo = OFoo.View(CpuRead);
if ( SE->_is_local && SE->_permute ) if ( SE->_is_local && SE->_permute )
permute(echeck[i],ofoo[SE->_offset],permute_type); permute(echeck[i],ofoo[SE->_offset],permute_type);
else if (SE->_is_local) else if (SE->_is_local)

View File

@ -88,14 +88,15 @@ int main (int argc, char ** argv)
// replicate across fifth dimension // replicate across fifth dimension
//////////////////////////////////// ////////////////////////////////////
LatticeGaugeField Umu5d(FGrid); LatticeGaugeField Umu5d(FGrid);
auto umu5d = Umu5d.View(); {
auto umu = Umu.View(); auto umu5d = Umu5d.View(CpuWrite);
for(int ss=0;ss<Umu.Grid()->oSites();ss++){ auto umu = Umu.View(CpuRead);
for(int s=0;s<Ls;s++){ for(int ss=0;ss<Umu.Grid()->oSites();ss++){
umu5d[Ls*ss+s] = umu[ss]; for(int s=0;s<Ls;s++){
umu5d[Ls*ss+s] = umu[ss];
}
} }
} }
std::vector<LatticeColourMatrix> U(4,FGrid); std::vector<LatticeColourMatrix> U(4,FGrid);
for(int mu=0;mu<Nd;mu++){ for(int mu=0;mu<Nd;mu++){

View File

@ -570,8 +570,8 @@ void TestConserved1(Action & Ddwf, Action & Ddwfrev,
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];
@ -597,8 +597,8 @@ void TestConserved1(Action & Ddwf, Action & Ddwfrev,
{ {
RealD diag = 5.0 - Ddwf.M5; RealD diag = 5.0 - Ddwf.M5;
mass = Ddwf.mass; mass = Ddwf.mass;
auto psi=result5.View(); auto psi=result5.View(CpuRead);
auto chi=tmp.View(); auto chi=tmp.View(CpuWrite);
thread_for(sss,UGrid->oSites(),{ thread_for(sss,UGrid->oSites(),{
uint64_t ss= sss*Ls; uint64_t ss= sss*Ls;
typedef vSpinColourVector spinor; typedef vSpinColourVector spinor;

View File

@ -98,9 +98,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto U_v = U.View(CpuRead);
auto U_v = U.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach( i,mom_v,{ thread_foreach( i,mom_v,{
Uprime_v[i](mu) = Uprime_v[i](mu) =
U_v[i](mu) U_v[i](mu)

View File

@ -100,9 +100,9 @@ int main (int argc, char ** argv)
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach( i,mom_v,{ thread_foreach( i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -110,9 +110,9 @@ int main (int argc, char** argv)
PokeIndex<LorentzIndex>(mom, mommu, mu); PokeIndex<LorentzIndex>(mom, mommu, mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -119,9 +119,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -114,9 +114,9 @@ int main (int argc, char** argv)
PokeIndex<LorentzIndex>(mom, mommu, mu); PokeIndex<LorentzIndex>(mom, mommu, mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -85,9 +85,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu
Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ; Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ;
}); });

View File

@ -87,9 +87,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v= Uprime.View(); auto Uprime_v= Uprime.View(CpuWrite);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu
Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ; Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ;
}); });

View File

@ -105,9 +105,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)
+ mom_v[i](mu)*U_v[i](mu)*dt + mom_v[i](mu)*U_v[i](mu)*dt

View File

@ -99,9 +99,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -101,9 +101,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)
+ mom_v[i](mu)*U_v[i](mu)*dt + mom_v[i](mu)*U_v[i](mu)*dt

View File

@ -112,9 +112,9 @@ int main (int argc, char** argv)
PokeIndex<LorentzIndex>(mom, mommu, mu); PokeIndex<LorentzIndex>(mom, mommu, mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -115,9 +115,9 @@ int main (int argc, char** argv)
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
PokeIndex<LorentzIndex>(mom, mommu, mu); PokeIndex<LorentzIndex>(mom, mommu, mu);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
// fourth order exponential approx // fourth order exponential approx
thread_foreach( i, mom_v,{ thread_foreach( i, mom_v,{
Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt + mom_v[i](mu) *mom_v[i](mu) *U_v[i](mu)*(dt*dt/2.0) Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt + mom_v[i](mu) *mom_v[i](mu) *U_v[i](mu)*(dt*dt/2.0)

View File

@ -101,9 +101,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)
+ mom_v[i](mu)*U_v[i](mu)*dt + mom_v[i](mu)*U_v[i](mu)*dt

View File

@ -87,9 +87,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu thread_foreach(i,mom_v,{ // exp(pmu dt) * Umu
Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ; Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ;
}); });

View File

@ -105,9 +105,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach( i,mom_v,{ thread_foreach( i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu); Uprime_v[i](mu) = U_v[i](mu);
Uprime_v[i](mu) += mom_v[i](mu)*U_v[i](mu)*dt ; Uprime_v[i](mu) += mom_v[i](mu)*U_v[i](mu)*dt ;

View File

@ -105,9 +105,9 @@ int main(int argc, char **argv)
Hmom -= real(sum(trace(mommu * mommu))); Hmom -= real(sum(trace(mommu * mommu)));
PokeIndex<LorentzIndex>(mom, mommu, mu); PokeIndex<LorentzIndex>(mom, mommu, mu);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
thread_foreach(ss,mom_v, thread_foreach(ss,mom_v,
{ {
Uprime_v[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom_v[ss]._internal[mu], dt, 12) * U_v[ss]._internal[mu]); Uprime_v[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom_v[ss]._internal[mu], dt, 12) * U_v[ss]._internal[mu]);

View File

@ -114,9 +114,9 @@ int main (int argc, char ** argv)
PokeIndex<LorentzIndex>(mom,mommu,mu); PokeIndex<LorentzIndex>(mom,mommu,mu);
// fourth order exponential approx // fourth order exponential approx
auto mom_v = mom.View(); auto mom_v = mom.View(CpuRead);
auto U_v = U.View(); auto U_v = U.View(CpuRead);
auto Uprime_v = Uprime.View(); auto Uprime_v = Uprime.View(CpuWrite);
thread_foreach(i,mom_v,{ thread_foreach(i,mom_v,{
Uprime_v[i](mu) = U_v[i](mu) Uprime_v[i](mu) = U_v[i](mu)

View File

@ -1,5 +1,3 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
@ -302,8 +300,8 @@ int main (int argc, char ** argv)
int nb=nbasisc/2; int nb=nbasisc/2;
CoarseAggregates.CreateSubspaceChebyshev(CRNG,PosdefLdop,nb,12.0,0.02,500,100,100,0.0); CoarseAggregates.CreateSubspaceChebyshev(CRNG,PosdefLdop,nb,12.0,0.02,500,100,100,0.0);
for(int n=0;n<nb;n++){ for(int n=0;n<nb;n++){
auto subspace = CoarseAggregates.subspace[n].View(); auto subspace = CoarseAggregates.subspace[n].View(CpuRead);
auto subspace_g5 = CoarseAggregates.subspace[n+nb].View(); auto subspace_g5 = CoarseAggregates.subspace[n+nb].View(CpuWrite);
for(int nn=0;nn<nb;nn++){ for(int nn=0;nn<nb;nn++){
for(int site=0;site<Coarse5d->oSites();site++){ for(int site=0;site<Coarse5d->oSites();site++){
subspace_g5[site](nn) = subspace[site](nn); subspace_g5[site](nn) = subspace[site](nn);