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

Hide internal data

This commit is contained in:
paboyle 2018-01-26 23:06:51 +00:00
parent 5642ea270f
commit 8dccffdfd5
6 changed files with 37 additions and 37 deletions

View File

@ -73,15 +73,15 @@ public:
void coarseToFine(const CoarseField& in, Field& out) {
out = zero;
out.checkerboard = _evec._v[0].checkerboard;
out.Checkerboard() = _evec._v[0].Checkerboard();
int Nbasis = sizeof(in._odata[0]._internal._internal) / sizeof(in._odata[0]._internal._internal[0]);
int Nbasis = sizeof(in[0]._internal._internal) / sizeof(in[0]._internal._internal[0]);
assert(Nbasis == _evec._Nm);
#pragma omp parallel for
for (int b=0;b<_bgrid._o_blocks;b++) {
for (int j=0;j<_evec._Nm;j++) {
_bgrid.block_caxpy(b,out,in._odata[b]._internal._internal[j],_evec._v[j],out);
_bgrid.block_caxpy(b,out,in[b]._internal._internal[j],_evec._v[j],out);
}
}
@ -92,7 +92,7 @@ public:
out = zero;
int Nbasis = sizeof(out._odata[0]._internal._internal) / sizeof(out._odata[0]._internal._internal[0]);
int Nbasis = sizeof(out[0]._internal._internal) / sizeof(out[0]._internal._internal[0]);
assert(Nbasis == _evec._Nm);
@ -105,7 +105,7 @@ public:
// |rhs> -= <j|rhs> |j>
auto c = _bgrid.block_sp(b,_evec._v[j],tmp);
_bgrid.block_caxpy(b,tmp,-c,_evec._v[j],tmp); // may make this more numerically stable
out._odata[b]._internal._internal[j] = c;
out[b]._internal._internal[j] = c;
}
}

View File

@ -113,7 +113,7 @@ public:
vCoeff_t ret = 0.0;
for (int i=0;i<_block_sites;i++) { // only odd sites
int ss = block_site_to_o_site(x0,i);
ret += TensorRemove(innerProduct(x._odata[ss],y._odata[ss]));
ret += TensorRemove(innerProduct(x[ss],y[ss]));
}
return ret;
@ -140,7 +140,7 @@ public:
for (int j=0;j<nsimd;j++) {
int t = lsize * i + l*nsimd + j;
ret[j] += conjugate(((Coeff_t*)&x._odata[ss]._internal)[l*nsimd + j]) * y[t];
ret[j] += conjugate(((Coeff_t*)&x[ss]._internal)[l*nsimd + j]) * y[t];
}
}
}
@ -175,7 +175,7 @@ public:
for (int i=0;i<_block_sites;i++) { // only odd sites
int ss = block_site_to_o_site(x0,i);
vcaxpy(ret._odata[ss],a,x._odata[ss],y._odata[ss]);
vcaxpy(ret[ss],a,x[ss],y[ss]);
}
}
@ -192,7 +192,7 @@ public:
int n = lsize / nsimd;
for (int l=0;l<n;l++) {
vCoeff_t r = a* ((vCoeff_t*)&x._odata[ss]._internal)[l];
vCoeff_t r = a* ((vCoeff_t*)&x[ss]._internal)[l];
for (int j=0;j<nsimd;j++) {
int t = lsize * i + l*nsimd + j;
@ -213,7 +213,7 @@ public:
int ss = block_site_to_o_site(x0,i);
for (int l=0;l<lsize;l++)
((Coeff_t*)&ret._odata[ss]._internal)[l] = (Coeff_t)x[lsize * i + l]; // convert precision
((Coeff_t*)&ret[ss]._internal)[l] = (Coeff_t)x[lsize * i + l]; // convert precision
}
}
@ -228,7 +228,7 @@ public:
int ss = block_site_to_o_site(x0,i);
for (int l=0;l<lsize;l++)
x[lsize * i + l] = (ComplexD)((Coeff_t*)&ret._odata[ss]._internal)[l];
x[lsize * i + l] = (ComplexD)((Coeff_t*)&ret[ss]._internal)[l];
}
}
@ -255,7 +255,7 @@ public:
for (int i=0;i<_block_sites;i++) { // only odd sites
int ss = block_site_to_o_site(x0,i);
vcscale(ret._odata[ss],a,ret._odata[ss]);
vcscale(ret[ss],a,ret[ss]);
}
}
@ -310,7 +310,7 @@ public:
for (int s=0;s<4;s++)
for (int c=0;c<3;c++) {
Coeff_t& ld = ((Coeff_t*)&v._odata[oi]._internal._internal[s]._internal[c])[ii];
Coeff_t& ld = ((Coeff_t*)&v[oi]._internal._internal[s]._internal[c])[ii];
int ti = 12*lti + 3*s + c;
ld = Coeff_t(buf[2*ti+0], buf[2*ti+1]);
}
@ -350,7 +350,7 @@ public:
for (int s=0;s<4;s++)
for (int c=0;c<3;c++) {
Coeff_t& ld = ((Coeff_t*)&v._odata[oi]._internal._internal[s]._internal[c])[ii];
Coeff_t& ld = ((Coeff_t*)&v[oi]._internal._internal[s]._internal[c])[ii];
int ti = 12*lti + 3*s + c;
buf[2*ti+0] = ld.real();
buf[2*ti+1] = ld.imag();

View File

@ -174,7 +174,7 @@ namespace Grid {
}
// loop
ret._v[nev].checkerboard = Odd;
ret._v[nev].Checkerboard() = Odd;
#pragma omp parallel
{
@ -706,13 +706,13 @@ namespace Grid {
read_floats(lptr, &buf1[0], buf1.size() );
if (mnb != -1) {
for (l=0;l<nkeep_single;l++) {
((CoeffCoarse_t*)&coef._v[j]._odata[oi]._internal._internal[l])[ii] = CoeffCoarse_t(buf1[2*l+0],buf1[2*l+1]);
((CoeffCoarse_t*)&coef._v[j][oi]._internal._internal[l])[ii] = CoeffCoarse_t(buf1[2*l+0],buf1[2*l+1]);
}
}
read_floats_fp16(lptr, &buf2[0], buf2.size(), _FP16_COEF_EXP_SHARE_FLOATS);
if (mnb != -1) {
for (l=nkeep_single;l<nkeep;l++) {
((CoeffCoarse_t*)&coef._v[j]._odata[oi]._internal._internal[l])[ii] = CoeffCoarse_t(buf2[2*(l-nkeep_single)+0],buf2[2*(l-nkeep_single)+1]);
((CoeffCoarse_t*)&coef._v[j][oi]._internal._internal[l])[ii] = CoeffCoarse_t(buf2[2*(l-nkeep_single)+0],buf2[2*(l-nkeep_single)+1]);
}
}
@ -721,7 +721,7 @@ namespace Grid {
// set checkerboard
for (int i=0;i<(int)pr._evec.size();i++)
pr._evec._v[i].checkerboard = Odd;
pr._evec._v[i].Checkerboard() = Odd;
gsw2.Stop();
seconds=gsw2.useconds()/1e6;
@ -875,7 +875,7 @@ namespace Grid {
gsw4.Start();
gsw5.Start();
for (int l=0;l<nsingleCap;l++) {
auto res = ((CoeffCoarse_t*)&coef._v[j]._odata[oi]._internal._internal[l])[ii];
auto res = ((CoeffCoarse_t*)&coef._v[j][oi]._internal._internal[l])[ii];
buf[2*l+0] = res.real();
buf[2*l+1] = res.imag();
//nrmTest += res.real() * res.real() + res.imag() * res.imag();
@ -884,7 +884,7 @@ namespace Grid {
write_floats(f,fbuf,crc, &buf[0], size1 );
gsw4.Stop();
for (int l=nsingleCap;l<(int)pr._evec.size();l++) {
auto res = ((CoeffCoarse_t*)&coef._v[j]._odata[oi]._internal._internal[l])[ii];
auto res = ((CoeffCoarse_t*)&coef._v[j][oi]._internal._internal[l])[ii];
buf[2*(l-nsingleCap)+0] = res.real();
buf[2*(l-nsingleCap)+1] = res.imag();
//nrmTest += res.real() * res.real() + res.imag() * res.imag();
@ -990,7 +990,7 @@ namespace Grid {
for (int i=0;i<N;i++) {
if (ret._v[i].checkerboard != Odd)
if (ret._v[i].Checkerboard() != Odd)
continue;
// create buffer and put data in argonne format in there

View File

@ -142,14 +142,14 @@ public:
return false;
fseeko(_f,cur,SEEK_SET);
size_t sz = sizeof(out._odata[0]) * out._odata.size();
size_t sz = sizeof(out[0]) * out._odata.size();
GridStopWatch gsw;
gsw.Start();
uint32_t crc_exp;
assert(fread(&crc_exp,4,1,_f)==1);
assert(fread(&out._odata[0],sz,1,_f)==1);
assert(FieldVectorIO::crc32_threaded((unsigned char*)&out._odata[0],sz,0x0)==crc_exp);
assert(fread(&out[0],sz,1,_f)==1);
assert(FieldVectorIO::crc32_threaded((unsigned char*)&out[0],sz,0x0)==crc_exp);
gsw.Stop();
printf("CheckpointLinearFunction:: reading %lld\n",(long long)sz);
@ -161,13 +161,13 @@ public:
fseek(_f,0,SEEK_CUR); // switch to write
size_t sz = sizeof(out._odata[0]) * out._odata.size();
size_t sz = sizeof(out[0]) * out._odata.size();
GridStopWatch gsw;
gsw.Start();
uint32_t crc = FieldVectorIO::crc32_threaded((unsigned char*)&out._odata[0],sz,0x0);
uint32_t crc = FieldVectorIO::crc32_threaded((unsigned char*)&out[0],sz,0x0);
assert(fwrite(&crc,4,1,_f)==1);
assert(fwrite(&out._odata[0],sz,1,_f)==1);
assert(fwrite(&out[0],sz,1,_f)==1);
fflush(_f); // try this on the GPFS to suppress OPA usage for disk during dslash; this is not needed at Lustre/JLAB
gsw.Stop();
@ -390,7 +390,7 @@ void CoarseGridLanczos(BlockProjector<Field>& pr,RealD alpha2,RealD beta,int Npo
gsw.Start();
pr.coarseToFine(coef[i],v_i);
v_i.checkerboard = Odd;
v_i.Checkerboard() = Odd;
for (int j=0;j<smoothed_eval_outer;j++) {
tmp=zero;
@ -425,7 +425,7 @@ void CoarseGridLanczos(BlockProjector<Field>& pr,RealD alpha2,RealD beta,int Npo
if (cg_test_enabled) {
ConjugateGradient<LatticeFermion> CG(1.0e-8, cg_test_maxiter, false);
LatticeFermion src_orig(bgrid._grid);
src_orig.checkerboard = Odd;
src_orig.Checkerboard() = Odd;
src_orig = 1.0;
src_orig = src_orig * (1.0 / ::sqrt(norm2(src_orig)) );
auto result = src_orig;
@ -594,7 +594,7 @@ int main (int argc, char ** argv) {
LatticeFermion src(FrbGrid);
{
src=1.0;
src.checkerboard = Odd;
src.Checkerboard() = Odd;
// normalize
RealD nn = norm2(src);

View File

@ -85,7 +85,7 @@ public:
Grid::QCD::ScidacReader RD ;
RD.open(evecs_file);
for(int k=0;k<nbasis;k++) {
this->_Aggregate.subspace[k].checkerboard=this->_checkerboard;
this->_Aggregate.subspace[k].Checkerboard()=this->_checkerboard;
RD.readScidacFieldRecord(this->_Aggregate.subspace[k],record);
}

View File

@ -87,8 +87,8 @@ public:
GridBase *FineGrid = _Aggregate.FineGrid;
FineField fin(FineGrid) ;fin.checkerboard =_Aggregate.checkerboard;
FineField fout(FineGrid);fout.checkerboard =_Aggregate.checkerboard;
FineField fin(FineGrid) ;fin.Checkerboard() =_Aggregate.Checkerboard();
FineField fout(FineGrid);fout.Checkerboard() =_Aggregate.Checkerboard();
_Aggregate.PromoteFromSubspace(in,fin);
_poly(_Linop,fin,fout);
@ -139,7 +139,7 @@ public:
int Nk = nbasis;
_Aggregate.subspace.resize(Nk,_FineGrid);
_Aggregate.subspace[0]=1.0;
_Aggregate.subspace[0].checkerboard=_checkerboard;
_Aggregate.subspace[0].Checkerboard()=_checkerboard;
normalise(_Aggregate.subspace[0]);
PlainHermOp<FineField> Op(_FineOp);
for(int k=1;k<Nk;k++){
@ -148,7 +148,7 @@ public:
std::cout << GridLogMessage << "testFine subspace "<<k<<" " <<norm2(_Aggregate.subspace[k])<<std::endl;
}
for(int k=0;k<Nk;k++){
std::cout << GridLogMessage << "testFine subspace "<<k<<" cb " <<_Aggregate.subspace[k].checkerboard<<std::endl;
std::cout << GridLogMessage << "testFine subspace "<<k<<" cb " <<_Aggregate.subspace[k].Checkerboard()<<std::endl;
}
_Aggregate.Orthogonalise();
}
@ -165,14 +165,14 @@ public:
std::vector<RealD> eval(Nm);
FineField src(_FineGrid); src=1.0; src.checkerboard = _checkerboard;
FineField src(_FineGrid); src=1.0; src.Checkerboard() = _checkerboard;
ImplicitlyRestartedLanczos<FineField> IRL(ChebyOp,Op,Nk,Nk,Nm,resid,MaxIt,betastp,MinRes);
_Aggregate.subspace.resize(Nm,_FineGrid);
IRL.calc(eval,_Aggregate.subspace,src,Nk,false);
_Aggregate.subspace.resize(Nk,_FineGrid);
for(int k=0;k<Nk;k++){
std::cout << GridLogMessage << "testFine subspace "<<k<<" cb " <<_Aggregate.subspace[k].checkerboard<<std::endl;
std::cout << GridLogMessage << "testFine subspace "<<k<<" cb " <<_Aggregate.subspace[k].Checkerboard()<<std::endl;
}
_Aggregate.Orthogonalise();
}