mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
fast local peek-poke
This commit is contained in:
parent
20a091c3ed
commit
392e064513
@ -154,7 +154,7 @@ PARALLEL_FOR_LOOP
|
|||||||
template<class vobj,class sobj>
|
template<class vobj,class sobj>
|
||||||
void peekLocalSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
|
void peekLocalSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
|
||||||
|
|
||||||
GridBase *grid=l._grid;
|
GridBase *grid = l._grid;
|
||||||
|
|
||||||
typedef typename vobj::scalar_type scalar_type;
|
typedef typename vobj::scalar_type scalar_type;
|
||||||
typedef typename vobj::vector_type vector_type;
|
typedef typename vobj::vector_type vector_type;
|
||||||
@ -164,16 +164,18 @@ PARALLEL_FOR_LOOP
|
|||||||
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
||||||
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
||||||
|
|
||||||
|
static const int words=sizeof(vobj)/sizeof(vector_type);
|
||||||
int odx,idx;
|
int odx,idx;
|
||||||
idx= grid->iIndex(site);
|
idx= grid->iIndex(site);
|
||||||
odx= grid->oIndex(site);
|
odx= grid->oIndex(site);
|
||||||
|
|
||||||
std::vector<sobj> buf(Nsimd);
|
scalar_type * vp = (scalar_type *)&l._odata[odx];
|
||||||
|
scalar_type * pt = (scalar_type *)&s;
|
||||||
extract(l._odata[odx],buf);
|
|
||||||
|
for(int w=0;w<words;w++){
|
||||||
|
pt[w] = vp[idx+w*Nsimd];
|
||||||
|
}
|
||||||
|
|
||||||
s = buf[idx];
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -190,18 +192,17 @@ PARALLEL_FOR_LOOP
|
|||||||
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
||||||
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
||||||
|
|
||||||
|
static const int words=sizeof(vobj)/sizeof(vector_type);
|
||||||
int odx,idx;
|
int odx,idx;
|
||||||
idx= grid->iIndex(site);
|
idx= grid->iIndex(site);
|
||||||
odx= grid->oIndex(site);
|
odx= grid->oIndex(site);
|
||||||
|
|
||||||
std::vector<sobj> buf(Nsimd);
|
scalar_type * vp = (scalar_type *)&l._odata[odx];
|
||||||
|
scalar_type * pt = (scalar_type *)&s;
|
||||||
// extract-modify-merge cycle is easiest way and this is not perf critical
|
|
||||||
extract(l._odata[odx],buf);
|
|
||||||
|
|
||||||
buf[idx] = s;
|
for(int w=0;w<words;w++){
|
||||||
|
vp[idx+w*Nsimd] = pt[w];
|
||||||
merge(l._odata[odx],buf);
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user