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:
parent
2b4067bb71
commit
43cea62855
@ -98,7 +98,7 @@ inline sobj eval(const unsigned int ss, const sobj &arg)
|
||||
}
|
||||
template <class lobj>
|
||||
inline const lobj &eval(const unsigned int ss, const Lattice<lobj> &arg) {
|
||||
return arg._odata[ss];
|
||||
return arg[ss];
|
||||
}
|
||||
|
||||
// handle nodes in syntax tree
|
||||
@ -179,9 +179,9 @@ template <class T1,
|
||||
inline void CBFromExpression(int &cb, const T1 &lat) // Lattice leaf
|
||||
{
|
||||
if ((cb == Odd) || (cb == Even)) {
|
||||
assert(cb == lat.checkerboard);
|
||||
assert(cb == lat.Checkerboard());
|
||||
}
|
||||
cb = lat.checkerboard;
|
||||
cb = lat.Checkerboard();
|
||||
// std::cout<<GridLogMessage<<"Lattice leaf cb "<<cb<<std::endl;
|
||||
}
|
||||
template <class T1,
|
||||
|
@ -35,71 +35,71 @@ NAMESPACE_BEGIN(Grid);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mult(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
conformable(lhs,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
mult(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mult(&tmp,&lhs[ss],&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
mult(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||
mult(&ret[ss],&lhs[ss],&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
conformable(lhs,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
mac(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mac(&tmp,&lhs[ss],&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
mac(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||
mac(&ret[ss],&lhs[ss],&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
conformable(lhs,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
sub(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
sub(&tmp,&lhs[ss],&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
sub(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||
sub(&ret[ss],&lhs[ss],&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
conformable(lhs,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
add(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
add(&tmp,&lhs[ss],&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
add(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||
add(&ret[ss],&lhs[ss],&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
@ -109,55 +109,55 @@ void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mult(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(lhs,ret);
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
mult(&tmp,&lhs._odata[ss],&rhs);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mult(&tmp,&lhs[ss],&rhs);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,lhs);
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
mac(&tmp,&lhs._odata[ss],&rhs);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mac(&tmp,&lhs[ss],&rhs);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(ret,lhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
sub(&tmp,&lhs._odata[ss],&rhs);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
sub(&tmp,&lhs[ss],&rhs);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
sub(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
||||
sub(&ret[ss],&lhs[ss],&rhs);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||
ret.checkerboard = lhs.checkerboard;
|
||||
ret.Checkerboard() = lhs.Checkerboard();
|
||||
conformable(lhs,ret);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,lhs,{
|
||||
obj1 tmp;
|
||||
add(&tmp,&lhs._odata[ss],&rhs);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
add(&tmp,&lhs[ss],&rhs);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,lhs,{
|
||||
add(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
||||
add(&ret[ss],&lhs[ss],&rhs);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
@ -167,107 +167,107 @@ void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mult(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,rhs,{
|
||||
obj1 tmp;
|
||||
mult(&tmp,&lhs,&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mult(&tmp,&lhs,&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,rhs,{
|
||||
mult(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||
mult(&ret[ss],&lhs,&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void mac(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,rhs,{
|
||||
obj1 tmp;
|
||||
mac(&tmp,&lhs,&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
mac(&tmp,&lhs,&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,rhs,{
|
||||
mac(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||
mac(&ret[ss],&lhs,&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void sub(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,rhs,{
|
||||
obj1 tmp;
|
||||
sub(&tmp,&lhs,&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
sub(&tmp,&lhs,&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,rhs,{
|
||||
sub(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||
sub(&ret[ss],&lhs,&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
template<class obj1,class obj2,class obj3> inline
|
||||
void add(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,rhs,{
|
||||
obj1 tmp;
|
||||
add(&tmp,&lhs,&rhs._odata[ss]);
|
||||
vstream(ret._odata[ss],tmp);
|
||||
add(&tmp,&lhs,&rhs[ss]);
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,rhs,{
|
||||
add(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||
add(&ret[ss],&lhs,&rhs[ss]);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class sobj,class vobj> inline
|
||||
void axpy(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||
ret.checkerboard = x.checkerboard;
|
||||
ret.Checkerboard() = x.Checkerboard();
|
||||
conformable(ret,x);
|
||||
conformable(x,y);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,x,{
|
||||
vobj tmp = a*x._odata[ss]+y._odata[ss];
|
||||
vstream(ret._odata[ss],tmp);
|
||||
vobj tmp = a*x[ss]+y[ss];
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,x,{
|
||||
ret._odata[ss]=a*x._odata[ss]+y._odata[ss];
|
||||
ret[ss]=a*x[ss]+y[ss];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
template<class sobj,class vobj> inline
|
||||
void axpby(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||
ret.checkerboard = x.checkerboard;
|
||||
ret.Checkerboard() = x.Checkerboard();
|
||||
conformable(ret,x);
|
||||
conformable(x,y);
|
||||
#ifdef STREAMING_STORES
|
||||
accelerator_loop(ss,x,{
|
||||
vobj tmp = a*x._odata[ss]+b*y._odata[ss];
|
||||
vstream(ret._odata[ss],tmp);
|
||||
vobj tmp = a*x[ss]+b*y[ss];
|
||||
vstream(ret[ss],tmp);
|
||||
});
|
||||
#else
|
||||
accelerator_loop(ss,x,{
|
||||
ret._odata[ss]=a*x._odata[ss]+b*y._odata[ss];
|
||||
ret[ss]=a*x[ss]+b*y[ss];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class sobj,class vobj> inline
|
||||
RealD axpy_norm(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||
ret.checkerboard = x.checkerboard;
|
||||
ret.Checkerboard() = x.Checkerboard();
|
||||
conformable(ret,x);
|
||||
conformable(x,y);
|
||||
axpy(ret,a,x,y);
|
||||
@ -275,7 +275,7 @@ RealD axpy_norm(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<v
|
||||
}
|
||||
template<class sobj,class vobj> inline
|
||||
RealD axpby_norm(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||
ret.checkerboard = x.checkerboard;
|
||||
ret.Checkerboard() = x.Checkerboard();
|
||||
conformable(ret,x);
|
||||
conformable(x,y);
|
||||
axpby(ret,a,b,x,y);
|
||||
|
@ -69,9 +69,11 @@ public:
|
||||
accelerator_inline LatticeAccelerator() : checkerboard(0), _odata(nullptr), _odata_size(0) {
|
||||
// std::cout << " Lattice accelerator object "<<this->_odata<<" size "<<this->_odata_size<<std::endl;
|
||||
};
|
||||
accelerator_inline int Checkerboard(void){ return checkerboard; };
|
||||
accelerator_inline int Checkerboard(void) const { return checkerboard; };
|
||||
accelerator_inline int &Checkerboard(void) { return checkerboard; };
|
||||
accelerator_inline uint64_t begin(void) const { return 0;};
|
||||
accelerator_inline uint64_t end(void) const { return _odata_size; };
|
||||
accelerator_inline uint64_t size(void) const { return _odata_size; };
|
||||
accelerator_inline vobj & operator[](size_t i) { return _odata[i]; };
|
||||
accelerator_inline const vobj & operator[](size_t i) const { return _odata[i]; };
|
||||
};
|
||||
@ -328,9 +330,9 @@ public:
|
||||
// std::cout << "Lattice constructor(const Lattice &) "<<this<<std::endl;
|
||||
_grid = r._grid;
|
||||
resize(r._odata_size);
|
||||
this->checkerboard = r.checkerboard;
|
||||
this->checkerboard = r.Checkerboard();
|
||||
accelerator_loop(ss,(*this),{
|
||||
this->_odata[ss]=r._odata[ss];
|
||||
this->_odata[ss]=r[ss];
|
||||
});
|
||||
}
|
||||
Lattice(Lattice && r){ // move constructor
|
||||
@ -338,7 +340,7 @@ public:
|
||||
_grid = r._grid;
|
||||
this->_odata = r._odata;
|
||||
this->_odata_size = r._odata_size;
|
||||
this->checkerboard= r.checkerboard;
|
||||
this->checkerboard= r.Checkerboard();
|
||||
r._odata = nullptr;
|
||||
r._odata_size = 0;
|
||||
}
|
||||
@ -346,20 +348,20 @@ public:
|
||||
template<class robj> inline Lattice<vobj> & operator = (const Lattice<robj> & r){
|
||||
// std::cout << "Lattice = (Lattice &)"<<std::endl;
|
||||
typename std::enable_if<!std::is_same<robj,vobj>::value,int>::type i=0;
|
||||
this->checkerboard = r.checkerboard;
|
||||
this->checkerboard = r.Checkerboard();
|
||||
conformable(*this,r);
|
||||
accelerator_loop(ss,(*this),{
|
||||
this->_odata[ss]=r._odata[ss];
|
||||
this->_odata[ss]=r[ss];
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
// Copy assignment
|
||||
inline Lattice<vobj> & operator = (const Lattice<vobj> & r){
|
||||
// std::cout << "Lattice = (Lattice &)"<<std::endl;
|
||||
this->checkerboard = r.checkerboard;
|
||||
this->checkerboard = r.Checkerboard();
|
||||
conformable(*this,r);
|
||||
accelerator_loop(ss,(*this),{
|
||||
this->_odata[ss]=r._odata[ss];
|
||||
this->_odata[ss]=r[ss];
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
@ -369,11 +371,11 @@ public:
|
||||
resize(0); // delete if appropriate
|
||||
|
||||
this->_grid = r._grid;
|
||||
this->checkerboard = r.checkerboard;
|
||||
this->checkerboard = r.Checkerboard();
|
||||
|
||||
this->_odata = r._odata;
|
||||
this->_odata_size = r._odata_size;
|
||||
this->checkerboard= r.checkerboard;
|
||||
this->checkerboard= r.Checkerboard();
|
||||
|
||||
r._odata = nullptr;
|
||||
r._odata_size = 0;
|
||||
|
@ -48,7 +48,7 @@ inline Lattice<vInteger> LLComparison(vfunctor op,const Lattice<lobj> &lhs,const
|
||||
{
|
||||
Lattice<vInteger> ret(rhs._grid);
|
||||
accelerator_loop( ss, rhs, {
|
||||
ret._odata[ss]=op(lhs._odata[ss],rhs._odata[ss]);
|
||||
ret[ss]=op(lhs[ss],rhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
@ -60,7 +60,7 @@ inline Lattice<vInteger> LSComparison(vfunctor op,const Lattice<lobj> &lhs,const
|
||||
{
|
||||
Lattice<vInteger> ret(lhs._grid);
|
||||
accelerator_loop( ss, lhs, {
|
||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||
ret[ss]=op(lhs[ss],rhs);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
@ -72,7 +72,7 @@ inline Lattice<vInteger> SLComparison(vfunctor op,const lobj &lhs,const Lattice<
|
||||
{
|
||||
Lattice<vInteger> ret(rhs._grid);
|
||||
accelerator_loop( ss, rhs, {
|
||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||
ret[ss]=op(lhs[ss],rhs);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ NAMESPACE_BEGIN(Grid);
|
||||
template<class obj1,class obj2> void conformable(const Lattice<obj1> &lhs,const Lattice<obj2> &rhs)
|
||||
{
|
||||
assert(lhs._grid == rhs._grid);
|
||||
assert(lhs.checkerboard == rhs.checkerboard);
|
||||
assert(lhs.Checkerboard() == rhs.Checkerboard());
|
||||
}
|
||||
|
||||
NAMESPACE_END(Grid);
|
||||
|
@ -48,14 +48,14 @@ template<class iobj> inline void LatticeCoordinate(Lattice<iobj> &l,int mu)
|
||||
mergebuf[i]=(Integer)gcoor[mu];
|
||||
}
|
||||
merge<vector_type,scalar_type>(vI,mergebuf);
|
||||
l._odata[o]=vI;
|
||||
l[o]=vI;
|
||||
}
|
||||
};
|
||||
|
||||
// LatticeCoordinate();
|
||||
// FIXME for debug; deprecate this; made obscelete by
|
||||
template<class vobj> void lex_sites(Lattice<vobj> &l){
|
||||
Real *v_ptr = (Real *)&l._odata[0];
|
||||
Real *v_ptr = (Real *)&l[0];
|
||||
size_t o_len = l._grid->oSites();
|
||||
size_t v_len = sizeof(vobj)/sizeof(vRealF);
|
||||
size_t vec_len = vRealF::Nsimd();
|
||||
|
@ -44,7 +44,7 @@ inline auto localNorm2 (const Lattice<vobj> &rhs)-> Lattice<typename vobj::tenso
|
||||
{
|
||||
Lattice<typename vobj::tensor_reduced> ret(rhs._grid);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=innerProduct(rhs._odata[ss],rhs._odata[ss]);
|
||||
ret[ss]=innerProduct(rhs[ss],rhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
@ -55,7 +55,7 @@ inline auto localInnerProduct (const Lattice<vobj> &lhs,const Lattice<vobj> &rhs
|
||||
{
|
||||
Lattice<typename vobj::tensor_reduced> ret(rhs._grid);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=innerProduct(lhs._odata[ss],rhs._odata[ss]);
|
||||
ret[ss]=innerProduct(lhs[ss],rhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
@ -63,11 +63,11 @@ inline auto localInnerProduct (const Lattice<vobj> &lhs,const Lattice<vobj> &rhs
|
||||
// outerProduct Scalar x Scalar -> Scalar
|
||||
// Vector x Vector -> Matrix
|
||||
template<class ll,class rr>
|
||||
inline auto outerProduct (const Lattice<ll> &lhs,const Lattice<rr> &rhs) -> Lattice<decltype(outerProduct(lhs._odata[0],rhs._odata[0]))>
|
||||
inline auto outerProduct (const Lattice<ll> &lhs,const Lattice<rr> &rhs) -> Lattice<decltype(outerProduct(lhs[0],rhs[0]))>
|
||||
{
|
||||
Lattice<decltype(outerProduct(lhs._odata[0],rhs._odata[0]))> ret(rhs._grid);
|
||||
Lattice<decltype(outerProduct(lhs[0],rhs[0]))> ret(rhs._grid);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=outerProduct(lhs._odata[ss],rhs._odata[ss]);
|
||||
ret[ss]=outerProduct(lhs[ss],rhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
@ -42,22 +42,22 @@ NAMESPACE_BEGIN(Grid);
|
||||
// Peek internal indices of a Lattice object
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<int Index,class vobj>
|
||||
auto PeekIndex(const Lattice<vobj> &lhs,int i) -> Lattice<decltype(peekIndex<Index>(lhs._odata[0],i))>
|
||||
auto PeekIndex(const Lattice<vobj> &lhs,int i) -> Lattice<decltype(peekIndex<Index>(lhs[0],i))>
|
||||
{
|
||||
Lattice<decltype(peekIndex<Index>(lhs._odata[0],i))> ret(lhs._grid);
|
||||
ret.checkerboard=lhs.checkerboard;
|
||||
Lattice<decltype(peekIndex<Index>(lhs[0],i))> ret(lhs._grid);
|
||||
ret.Checkerboard()=lhs.Checkerboard();
|
||||
cpu_loop( ss, lhs, {
|
||||
ret._odata[ss] = peekIndex<Index>(lhs._odata[ss],i);
|
||||
ret[ss] = peekIndex<Index>(lhs[ss],i);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
template<int Index,class vobj>
|
||||
auto PeekIndex(const Lattice<vobj> &lhs,int i,int j) -> Lattice<decltype(peekIndex<Index>(lhs._odata[0],i,j))>
|
||||
auto PeekIndex(const Lattice<vobj> &lhs,int i,int j) -> Lattice<decltype(peekIndex<Index>(lhs[0],i,j))>
|
||||
{
|
||||
Lattice<decltype(peekIndex<Index>(lhs._odata[0],i,j))> ret(lhs._grid);
|
||||
ret.checkerboard=lhs.checkerboard;
|
||||
Lattice<decltype(peekIndex<Index>(lhs[0],i,j))> ret(lhs._grid);
|
||||
ret.Checkerboard()=lhs.Checkerboard();
|
||||
cpu_loop( ss, lhs, {
|
||||
ret._odata[ss] = peekIndex<Index>(lhs._odata[ss],i,j);
|
||||
ret[ss] = peekIndex<Index>(lhs[ss],i,j);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
@ -66,17 +66,17 @@ auto PeekIndex(const Lattice<vobj> &lhs,int i,int j) -> Lattice<decltype(peekInd
|
||||
// Poke internal indices of a Lattice object
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<int Index,class vobj>
|
||||
void PokeIndex(Lattice<vobj> &lhs,const Lattice<decltype(peekIndex<Index>(lhs._odata[0],0))> & rhs,int i)
|
||||
void PokeIndex(Lattice<vobj> &lhs,const Lattice<decltype(peekIndex<Index>(lhs[0],0))> & rhs,int i)
|
||||
{
|
||||
cpu_loop( ss, lhs, {
|
||||
pokeIndex<Index>(lhs._odata[ss],rhs._odata[ss],i);
|
||||
pokeIndex<Index>(lhs[ss],rhs[ss],i);
|
||||
});
|
||||
}
|
||||
template<int Index,class vobj>
|
||||
void PokeIndex(Lattice<vobj> &lhs,const Lattice<decltype(peekIndex<Index>(lhs._odata[0],0,0))> & rhs,int i,int j)
|
||||
void PokeIndex(Lattice<vobj> &lhs,const Lattice<decltype(peekIndex<Index>(lhs[0],0,0))> & rhs,int i,int j)
|
||||
{
|
||||
cpu_loop( ss, lhs, {
|
||||
pokeIndex<Index>(lhs._odata[ss],rhs._odata[ss],i,j);
|
||||
pokeIndex<Index>(lhs[ss],rhs[ss],i,j);
|
||||
});
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ void pokeSite(const sobj &s,Lattice<vobj> &l,const std::vector<int> &site){
|
||||
|
||||
int Nsimd = grid->Nsimd();
|
||||
|
||||
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
||||
assert( l.Checkerboard()== l._grid->CheckerBoard(site));
|
||||
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
||||
|
||||
int rank,odx,idx;
|
||||
@ -105,9 +105,9 @@ void pokeSite(const sobj &s,Lattice<vobj> &l,const std::vector<int> &site){
|
||||
|
||||
// extract-modify-merge cycle is easiest way and this is not perf critical
|
||||
if ( rank == grid->ThisRank() ) {
|
||||
extract(l._odata[odx],buf);
|
||||
extract(l[odx],buf);
|
||||
buf[idx] = s;
|
||||
merge(l._odata[odx],buf);
|
||||
merge(l[odx],buf);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -127,13 +127,13 @@ void peekSite(sobj &s,const Lattice<vobj> &l,const std::vector<int> &site){
|
||||
|
||||
int Nsimd = grid->Nsimd();
|
||||
|
||||
assert( l.checkerboard == l._grid->CheckerBoard(site));
|
||||
assert( l.Checkerboard() == l._grid->CheckerBoard(site));
|
||||
|
||||
int rank,odx,idx;
|
||||
grid->GlobalCoorToRankIndex(rank,odx,idx,site);
|
||||
|
||||
std::vector<sobj> buf(Nsimd);
|
||||
extract(l._odata[odx],buf);
|
||||
extract(l[odx],buf);
|
||||
|
||||
s = buf[idx];
|
||||
|
||||
@ -156,7 +156,7 @@ void peekLocalSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
|
||||
|
||||
int Nsimd = grid->Nsimd();
|
||||
|
||||
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
||||
assert( l.Checkerboard()== l._grid->CheckerBoard(site));
|
||||
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
||||
|
||||
static const int words=sizeof(vobj)/sizeof(vector_type);
|
||||
@ -164,7 +164,7 @@ void peekLocalSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
|
||||
idx= grid->iIndex(site);
|
||||
odx= grid->oIndex(site);
|
||||
|
||||
scalar_type * vp = (scalar_type *)&l._odata[odx];
|
||||
scalar_type * vp = (scalar_type *)&l[odx];
|
||||
scalar_type * pt = (scalar_type *)&s;
|
||||
|
||||
for(int w=0;w<words;w++){
|
||||
@ -184,7 +184,7 @@ void pokeLocalSite(const sobj &s,Lattice<vobj> &l,std::vector<int> &site){
|
||||
|
||||
int Nsimd = grid->Nsimd();
|
||||
|
||||
assert( l.checkerboard== l._grid->CheckerBoard(site));
|
||||
assert( l.Checkerboard()== l._grid->CheckerBoard(site));
|
||||
assert( sizeof(sobj)*Nsimd == sizeof(vobj));
|
||||
|
||||
static const int words=sizeof(vobj)/sizeof(vector_type);
|
||||
@ -192,7 +192,7 @@ void pokeLocalSite(const sobj &s,Lattice<vobj> &l,std::vector<int> &site){
|
||||
idx= grid->iIndex(site);
|
||||
odx= grid->oIndex(site);
|
||||
|
||||
scalar_type * vp = (scalar_type *)&l._odata[odx];
|
||||
scalar_type * vp = (scalar_type *)&l[odx];
|
||||
scalar_type * pt = (scalar_type *)&s;
|
||||
|
||||
for(int w=0;w<words;w++){
|
||||
|
@ -49,7 +49,7 @@ template<class vobj> inline Lattice<vobj> adj(const Lattice<vobj> &lhs){
|
||||
template<class vobj> inline Lattice<vobj> conjugate(const Lattice<vobj> &lhs){
|
||||
Lattice<vobj> ret(lhs._grid);
|
||||
accelerator_loop( ss, lhs, {
|
||||
ret._odata[ss] = conjugate(lhs._odata[ss]);
|
||||
ret[ss] = conjugate(lhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
@ -52,9 +52,9 @@ inline ComplexD innerProduct(const Lattice<vobj> &left,const Lattice<vobj> &righ
|
||||
int mywork, myoff;
|
||||
GridThread::GetWork(left._grid->oSites(),thr,mywork,myoff);
|
||||
|
||||
decltype(innerProductD(left._odata[0],right._odata[0])) vnrm=zero; // private to thread; sub summation
|
||||
decltype(innerProductD(left[0],right[0])) vnrm=zero; // private to thread; sub summation
|
||||
for(int ss=myoff;ss<mywork+myoff; ss++){
|
||||
vnrm = vnrm + innerProductD(left._odata[ss],right._odata[ss]);
|
||||
vnrm = vnrm + innerProductD(left[ss],right[ss]);
|
||||
}
|
||||
sumarray[thr]=TensorRemove(vnrm) ;
|
||||
}
|
||||
@ -110,7 +110,7 @@ inline typename vobj::scalar_object sum(const Lattice<vobj> &arg)
|
||||
|
||||
vobj vvsum=zero;
|
||||
for(int ss=myoff;ss<mywork+myoff; ss++){
|
||||
vvsum = vvsum + arg._odata[ss];
|
||||
vvsum = vvsum + arg[ss];
|
||||
}
|
||||
sumarray[thr]=vvsum;
|
||||
}
|
||||
@ -180,7 +180,7 @@ template<class vobj> inline void sliceSum(const Lattice<vobj> &Data,std::vector<
|
||||
for(int n=0;n<e1;n++){
|
||||
for(int b=0;b<e2;b++){
|
||||
int ss= so+n*stride+b;
|
||||
lvSum[r]=lvSum[r]+Data._odata[ss];
|
||||
lvSum[r]=lvSum[r]+Data[ss];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ static void sliceInnerProductVector( std::vector<ComplexD> & result, const Latti
|
||||
for(int n=0;n<e1;n++){
|
||||
for(int b=0;b<e2;b++){
|
||||
int ss= so+n*stride+b;
|
||||
vector_type vv = TensorRemove(innerProduct(lhs._odata[ss],rhs._odata[ss]));
|
||||
vector_type vv = TensorRemove(innerProduct(lhs[ss],rhs[ss]));
|
||||
lvSum[r]=lvSum[r]+vv;
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ static void sliceMaddVector(Lattice<vobj> &R,std::vector<RealD> &a,const Lattice
|
||||
parallel_for_nest2(int n=0;n<e1;n++){
|
||||
for(int b=0;b<e2;b++){
|
||||
int ss= so+n*stride+b;
|
||||
R._odata[ss] = at*X._odata[ss]+Y._odata[ss];
|
||||
R[ss] = at*X[ss]+Y[ss];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ public:
|
||||
fillScalar(pointer[idx], dist[gdx], _generators[gdx]);
|
||||
}
|
||||
// merge into SIMD lanes, FIXME suboptimal implementation
|
||||
merge(l._odata[sm], buf);
|
||||
merge(l[sm], buf);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -39,11 +39,11 @@ NAMESPACE_BEGIN(Grid);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class vobj>
|
||||
inline auto trace(const Lattice<vobj> &lhs)
|
||||
-> Lattice<decltype(trace(lhs._odata[0]))>
|
||||
-> Lattice<decltype(trace(lhs[0]))>
|
||||
{
|
||||
Lattice<decltype(trace(lhs._odata[0]))> ret(lhs._grid);
|
||||
Lattice<decltype(trace(lhs[0]))> ret(lhs._grid);
|
||||
accelerator_loop( ss, lhs, {
|
||||
ret._odata[ss] = trace(lhs._odata[ss]);
|
||||
ret[ss] = trace(lhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
@ -52,11 +52,11 @@ inline auto trace(const Lattice<vobj> &lhs)
|
||||
// Trace Index level dependent operation
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<int Index,class vobj>
|
||||
inline auto TraceIndex(const Lattice<vobj> &lhs) -> Lattice<decltype(traceIndex<Index>(lhs._odata[0]))>
|
||||
inline auto TraceIndex(const Lattice<vobj> &lhs) -> Lattice<decltype(traceIndex<Index>(lhs[0]))>
|
||||
{
|
||||
Lattice<decltype(traceIndex<Index>(lhs._odata[0]))> ret(lhs._grid);
|
||||
Lattice<decltype(traceIndex<Index>(lhs[0]))> ret(lhs._grid);
|
||||
accelerator_loop( ss, lhs, {
|
||||
ret._odata[ss] = traceIndex<Index>(lhs._odata[ss]);
|
||||
ret[ss] = traceIndex<Index>(lhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ inline void subdivides(GridBase *coarse,GridBase *fine)
|
||||
// remove and insert a half checkerboard
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class vobj> inline void pickCheckerboard(int cb,Lattice<vobj> &half,const Lattice<vobj> &full){
|
||||
half.checkerboard = cb;
|
||||
half.Checkerboard() = cb;
|
||||
|
||||
thread_loop( (int ss=0;ss<full._grid->oSites();ss++),{
|
||||
int cbos;
|
||||
@ -59,12 +59,12 @@ template<class vobj> inline void pickCheckerboard(int cb,Lattice<vobj> &half,con
|
||||
|
||||
if (cbos==cb) {
|
||||
int ssh=half._grid->oIndex(coor);
|
||||
half._odata[ssh] = full._odata[ss];
|
||||
half[ssh] = full[ss];
|
||||
}
|
||||
});
|
||||
}
|
||||
template<class vobj> inline void setCheckerboard(Lattice<vobj> &full,const Lattice<vobj> &half){
|
||||
int cb = half.checkerboard;
|
||||
int cb = half.Checkerboard();
|
||||
thread_loop( (int ss=0;ss<full._grid->oSites();ss++), {
|
||||
std::vector<int> coor;
|
||||
int cbos;
|
||||
@ -74,7 +74,7 @@ template<class vobj> inline void setCheckerboard(Lattice<vobj> &full,const Latti
|
||||
|
||||
if (cbos==cb) {
|
||||
int ssh=half._grid->oIndex(coor);
|
||||
full._odata[ss]=half._odata[ssh];
|
||||
full[ss]=half[ssh];
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -117,8 +117,8 @@ inline void blockProject(Lattice<iVector<CComplex,nbasis > > &coarseData,
|
||||
|
||||
thread_critical {
|
||||
for(int i=0;i<nbasis;i++) {
|
||||
coarseData._odata[sc](i)=coarseData._odata[sc](i)
|
||||
+ innerProduct(Basis[i]._odata[sf],fineData._odata[sf]);
|
||||
coarseData[sc](i)=coarseData[sc](i)
|
||||
+ innerProduct(Basis[i][sf],fineData[sf]);
|
||||
|
||||
}
|
||||
}
|
||||
@ -135,8 +135,8 @@ inline void blockZAXPY(Lattice<vobj> &fineZ,
|
||||
GridBase * fine = fineZ._grid;
|
||||
GridBase * coarse= coarseA._grid;
|
||||
|
||||
fineZ.checkerboard=fineX.checkerboard;
|
||||
assert(fineX.checkerboard==fineY.checkerboard);
|
||||
fineZ.Checkerboard()=fineX.Checkerboard();
|
||||
assert(fineX.Checkerboard()==fineY.Checkerboard());
|
||||
subdivides(coarse,fine); // require they map
|
||||
conformable(fineX,fineY);
|
||||
conformable(fineX,fineZ);
|
||||
@ -162,7 +162,7 @@ inline void blockZAXPY(Lattice<vobj> &fineZ,
|
||||
Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
|
||||
|
||||
// z = A x + y
|
||||
fineZ._odata[sf]=coarseA._odata[sc]*fineX._odata[sf]+fineY._odata[sf];
|
||||
fineZ[sf]=coarseA[sc]*fineX[sf]+fineY[sf];
|
||||
|
||||
});
|
||||
|
||||
@ -173,26 +173,26 @@ inline void blockInnerProduct(Lattice<CComplex> &CoarseInner,
|
||||
const Lattice<vobj> &fineX,
|
||||
const Lattice<vobj> &fineY)
|
||||
{
|
||||
typedef decltype(innerProduct(fineX._odata[0],fineY._odata[0])) dotp;
|
||||
typedef decltype(innerProduct(fineX[0],fineY[0])) dotp;
|
||||
|
||||
GridBase *coarse(CoarseInner._grid);
|
||||
GridBase *fine (fineX._grid);
|
||||
|
||||
Lattice<dotp> fine_inner(fine); fine_inner.checkerboard = fineX.checkerboard;
|
||||
Lattice<dotp> fine_inner(fine); fine_inner.Checkerboard() = fineX.Checkerboard();
|
||||
Lattice<dotp> coarse_inner(coarse);
|
||||
|
||||
// Precision promotion?
|
||||
fine_inner = localInnerProduct(fineX,fineY);
|
||||
blockSum(coarse_inner,fine_inner);
|
||||
thread_loop( (int ss=0;ss<coarse->oSites();ss++),{
|
||||
CoarseInner._odata[ss] = coarse_inner._odata[ss];
|
||||
CoarseInner[ss] = coarse_inner[ss];
|
||||
});
|
||||
}
|
||||
template<class vobj,class CComplex>
|
||||
inline void blockNormalise(Lattice<CComplex> &ip,Lattice<vobj> &fineX)
|
||||
{
|
||||
GridBase *coarse = ip._grid;
|
||||
Lattice<vobj> zz(fineX._grid); zz=zero; zz.checkerboard=fineX.checkerboard;
|
||||
Lattice<vobj> zz(fineX._grid); zz=zero; zz.Checkerboard()=fineX.Checkerboard();
|
||||
blockInnerProduct(ip,fineX,fineX);
|
||||
ip = pow(ip,-0.5);
|
||||
blockZAXPY(fineX,ip,fineX,zz);
|
||||
@ -231,7 +231,7 @@ inline void blockSum(Lattice<vobj> &coarseData,const Lattice<vobj> &fineData)
|
||||
Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
|
||||
|
||||
thread_critical {
|
||||
coarseData._odata[sc]=coarseData._odata[sc]+fineData._odata[sf];
|
||||
coarseData[sc]=coarseData[sc]+fineData[sf];
|
||||
}
|
||||
|
||||
});
|
||||
@ -244,7 +244,7 @@ inline void blockPick(GridBase *coarse,const Lattice<vobj> &unpicked,Lattice<vob
|
||||
{
|
||||
GridBase * fine = unpicked._grid;
|
||||
|
||||
Lattice<vobj> zz(fine); zz.checkerboard = unpicked.checkerboard;
|
||||
Lattice<vobj> zz(fine); zz.Checkerboard() = unpicked.Checkerboard();
|
||||
Lattice<iScalar<vInteger> > fcoor(fine);
|
||||
|
||||
zz = zero;
|
||||
@ -320,8 +320,8 @@ inline void blockPromote(const Lattice<iVector<CComplex,nbasis > > &coarseData,
|
||||
Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
|
||||
|
||||
for(int i=0;i<nbasis;i++) {
|
||||
if(i==0) fineData._odata[sf]=coarseData._odata[sc](i) * Basis[i]._odata[sf];
|
||||
else fineData._odata[sf]=fineData._odata[sf]+coarseData._odata[sc](i)*Basis[i]._odata[sf];
|
||||
if(i==0) fineData[sf]=coarseData[sc](i) * Basis[i][sf];
|
||||
else fineData[sf]=fineData[sf]+coarseData[sc](i)*Basis[i][sf];
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -596,7 +596,7 @@ unvectorizeToLexOrdArray(std::vector<sobj> &out, const Lattice<vobj> &in)
|
||||
}
|
||||
|
||||
//Unpack into those ptrs
|
||||
const vobj & in_vobj = in._odata[in_oidx];
|
||||
const vobj & in_vobj = in[in_oidx];
|
||||
extract1(in_vobj, out_ptrs, 0);
|
||||
});
|
||||
}
|
||||
@ -645,7 +645,7 @@ vectorizeFromLexOrdArray( std::vector<sobj> &in, Lattice<vobj> &out)
|
||||
//pack from those ptrs
|
||||
vobj vecobj;
|
||||
merge1(vecobj, ptrs, 0);
|
||||
out._odata[oidx] = vecobj;
|
||||
out[oidx] = vecobj;
|
||||
});
|
||||
}
|
||||
|
||||
@ -654,7 +654,7 @@ template<class VobjOut, class VobjIn>
|
||||
void precisionChange(Lattice<VobjOut> &out, const Lattice<VobjIn> &in){
|
||||
|
||||
assert(out._grid->Nd() == in._grid->Nd());
|
||||
out.checkerboard = in.checkerboard;
|
||||
out.Checkerboard() = in.Checkerboard();
|
||||
GridBase *in_grid=in._grid;
|
||||
GridBase *out_grid = out._grid;
|
||||
|
||||
@ -689,7 +689,7 @@ void precisionChange(Lattice<VobjOut> &out, const Lattice<VobjIn> &in){
|
||||
int llex; Lexicographic::IndexFromCoor(lcoor, llex, out_grid->_ldimensions);
|
||||
ptrs[lane] = &in_slex_conv[llex];
|
||||
}
|
||||
merge(out._odata[out_oidx], ptrs, 0);
|
||||
merge(out[out_oidx], ptrs, 0);
|
||||
});
|
||||
}
|
||||
|
||||
@ -759,15 +759,15 @@ void Grid_split(std::vector<Lattice<Vobj> > & full,Lattice<Vobj> & split)
|
||||
////////////////////////////////
|
||||
// Checkerboard management
|
||||
////////////////////////////////
|
||||
int cb = full[0].checkerboard;
|
||||
split.checkerboard = cb;
|
||||
int cb = full[0].Checkerboard();
|
||||
split.Checkerboard() = cb;
|
||||
|
||||
//////////////////////////////
|
||||
// Checks
|
||||
//////////////////////////////
|
||||
assert(full_grid->_ndimension==split_grid->_ndimension);
|
||||
for(int n=0;n<full_vecs;n++){
|
||||
assert(full[n].checkerboard == cb);
|
||||
assert(full[n].Checkerboard() == cb);
|
||||
for(int d=0;d<ndim;d++){
|
||||
assert(full[n]._grid->_gdimensions[d]==split._grid->_gdimensions[d]);
|
||||
assert(full[n]._grid->_fdimensions[d]==split._grid->_fdimensions[d]);
|
||||
@ -885,15 +885,15 @@ void Grid_unsplit(std::vector<Lattice<Vobj> > & full,Lattice<Vobj> & split)
|
||||
////////////////////////////////
|
||||
// Checkerboard management
|
||||
////////////////////////////////
|
||||
int cb = full[0].checkerboard;
|
||||
split.checkerboard = cb;
|
||||
int cb = full[0].Checkerboard();
|
||||
split.Checkerboard() = cb;
|
||||
|
||||
//////////////////////////////
|
||||
// Checks
|
||||
//////////////////////////////
|
||||
assert(full_grid->_ndimension==split_grid->_ndimension);
|
||||
for(int n=0;n<full_vecs;n++){
|
||||
assert(full[n].checkerboard == cb);
|
||||
assert(full[n].Checkerboard() == cb);
|
||||
for(int d=0;d<ndim;d++){
|
||||
assert(full[n]._grid->_gdimensions[d]==split._grid->_gdimensions[d]);
|
||||
assert(full[n]._grid->_fdimensions[d]==split._grid->_fdimensions[d]);
|
||||
|
@ -42,7 +42,7 @@ template<class vobj>
|
||||
inline Lattice<vobj> transpose(const Lattice<vobj> &lhs){
|
||||
Lattice<vobj> ret(lhs._grid);
|
||||
accelerator_loop(ss,lhs,{
|
||||
ret._odata[ss] = transpose(lhs._odata[ss]);
|
||||
ret[ss] = transpose(lhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
@ -51,11 +51,11 @@ inline Lattice<vobj> transpose(const Lattice<vobj> &lhs){
|
||||
// Index level dependent transpose
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<int Index,class vobj>
|
||||
inline auto TransposeIndex(const Lattice<vobj> &lhs) -> Lattice<decltype(transposeIndex<Index>(lhs._odata[0]))>
|
||||
inline auto TransposeIndex(const Lattice<vobj> &lhs) -> Lattice<decltype(transposeIndex<Index>(lhs[0]))>
|
||||
{
|
||||
Lattice<decltype(transposeIndex<Index>(lhs._odata[0]))> ret(lhs._grid);
|
||||
Lattice<decltype(transposeIndex<Index>(lhs[0]))> ret(lhs._grid);
|
||||
accelerator_loop(ss,lhs,{
|
||||
ret._odata[ss] = transposeIndex<Index>(lhs._odata[ss]);
|
||||
ret[ss] = transposeIndex<Index>(lhs[ss]);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
@ -35,39 +35,39 @@ NAMESPACE_BEGIN(Grid);
|
||||
|
||||
template<class obj> Lattice<obj> pow(const Lattice<obj> &rhs,RealD y){
|
||||
Lattice<obj> ret(rhs._grid);
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=pow(rhs._odata[ss],y);
|
||||
ret[ss]=pow(rhs[ss],y);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
template<class obj> Lattice<obj> mod(const Lattice<obj> &rhs,Integer y){
|
||||
Lattice<obj> ret(rhs._grid);
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=mod(rhs._odata[ss],y);
|
||||
ret[ss]=mod(rhs[ss],y);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class obj> Lattice<obj> div(const Lattice<obj> &rhs,Integer y){
|
||||
Lattice<obj> ret(rhs._grid);
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=div(rhs._odata[ss],y);
|
||||
ret[ss]=div(rhs[ss],y);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class obj> Lattice<obj> expMat(const Lattice<obj> &rhs, RealD alpha, Integer Nexp = DEFAULT_MAT_EXP){
|
||||
Lattice<obj> ret(rhs._grid);
|
||||
ret.checkerboard = rhs.checkerboard;
|
||||
ret.Checkerboard() = rhs.Checkerboard();
|
||||
conformable(ret,rhs);
|
||||
accelerator_loop(ss,rhs,{
|
||||
ret._odata[ss]=Exponentiate(rhs._odata[ss],alpha, Nexp);
|
||||
ret[ss]=Exponentiate(rhs[ss],alpha, Nexp);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
@ -60,15 +60,15 @@ inline void whereWolf(Lattice<vobj> &ret,const Lattice<iobj> &predicate,Lattice<
|
||||
|
||||
thread_loop( (int ss=iftrue.begin(); ss<iftrue.end();ss++) , COMMA_SAFE({
|
||||
|
||||
extract(iftrue._odata[ss] ,truevals);
|
||||
extract(iffalse._odata[ss] ,falsevals);
|
||||
extract<vInteger,Integer>(TensorRemove(predicate._odata[ss]),mask);
|
||||
extract(iftrue[ss] ,truevals);
|
||||
extract(iffalse[ss] ,falsevals);
|
||||
extract<vInteger,Integer>(TensorRemove(predicate[ss]),mask);
|
||||
|
||||
for(int s=0;s<Nsimd;s++){
|
||||
if (mask[s]) falsevals[s]=truevals[s];
|
||||
}
|
||||
|
||||
merge(ret._odata[ss],falsevals);
|
||||
merge(ret[ss],falsevals);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user