mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 06:00:45 +01:00
Namespace and indentation
This commit is contained in:
parent
550b905bb8
commit
8c675064bd
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
|
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
@ -23,241 +23,240 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
See the full license in the file "LICENSE" in the top level distribution directory
|
See the full license in the file "LICENSE" in the top level distribution directory
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
#ifndef GRID_LATTICE_ARITH_H
|
#ifndef GRID_LATTICE_ARITH_H
|
||||||
#define GRID_LATTICE_ARITH_H
|
#define GRID_LATTICE_ARITH_H
|
||||||
|
|
||||||
namespace Grid {
|
NAMESPACE_BEGIN(Grid);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
// avoid copy back routines for mult, mac, sub, add
|
||||||
// avoid copy back routines for mult, mac, sub, add
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
void mult(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||||
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(ret,rhs);
|
conformable(lhs,rhs);
|
||||||
conformable(lhs,rhs);
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
#ifdef STREAMING_STORES
|
||||||
obj1 tmp;
|
obj1 tmp;
|
||||||
mult(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
mult(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
vstream(ret._odata[ss],tmp);
|
vstream(ret._odata[ss],tmp);
|
||||||
#else
|
#else
|
||||||
mult(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
mult(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
conformable(lhs,rhs);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
mac(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
mac(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
conformable(lhs,rhs);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
sub(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
sub(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
conformable(lhs,rhs);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
add(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
add(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// avoid copy back routines for mult, mac, sub, add
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void mult(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(lhs,ret);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
obj1 tmp;
|
|
||||||
mult(&tmp,&lhs._odata[ss],&rhs);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(ret,lhs);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
obj1 tmp;
|
|
||||||
mac(&tmp,&lhs._odata[ss],&rhs);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(ret,lhs);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
sub(&tmp,&lhs._odata[ss],&rhs);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
sub(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
|
||||||
ret.checkerboard = lhs.checkerboard;
|
|
||||||
conformable(lhs,ret);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
add(&tmp,&lhs._odata[ss],&rhs);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
add(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// avoid copy back routines for mult, mac, sub, add
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void mult(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = rhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
mult(&tmp,&lhs,&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
mult(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void mac(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = rhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
mac(&tmp,&lhs,&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
mac(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void sub(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = rhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
sub(&tmp,&lhs,&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
sub(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class obj1,class obj2,class obj3> strong_inline
|
|
||||||
void add(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
|
||||||
ret.checkerboard = rhs.checkerboard;
|
|
||||||
conformable(ret,rhs);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
obj1 tmp;
|
|
||||||
add(&tmp,&lhs,&rhs._odata[ss]);
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
add(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class sobj,class vobj> strong_inline
|
|
||||||
void axpy(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
|
||||||
ret.checkerboard = x.checkerboard;
|
|
||||||
conformable(ret,x);
|
|
||||||
conformable(x,y);
|
|
||||||
parallel_for(int ss=0;ss<x._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
vobj tmp = a*x._odata[ss]+y._odata[ss];
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
ret._odata[ss]=a*x._odata[ss]+y._odata[ss];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class sobj,class vobj> strong_inline
|
|
||||||
void axpby(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
|
||||||
ret.checkerboard = x.checkerboard;
|
|
||||||
conformable(ret,x);
|
|
||||||
conformable(x,y);
|
|
||||||
parallel_for(int ss=0;ss<x._grid->oSites();ss++){
|
|
||||||
#ifdef STREAMING_STORES
|
|
||||||
vobj tmp = a*x._odata[ss]+b*y._odata[ss];
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
#else
|
|
||||||
ret._odata[ss]=a*x._odata[ss]+b*y._odata[ss];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class sobj,class vobj> strong_inline
|
|
||||||
RealD axpy_norm(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
|
||||||
ret.checkerboard = x.checkerboard;
|
|
||||||
conformable(ret,x);
|
|
||||||
conformable(x,y);
|
|
||||||
axpy(ret,a,x,y);
|
|
||||||
return norm2(ret);
|
|
||||||
}
|
|
||||||
template<class sobj,class vobj> strong_inline
|
|
||||||
RealD axpby_norm(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
|
||||||
ret.checkerboard = x.checkerboard;
|
|
||||||
conformable(ret,x);
|
|
||||||
conformable(x,y);
|
|
||||||
axpby(ret,a,b,x,y);
|
|
||||||
return norm2(ret); // FIXME implement parallel norm in ss loop
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
conformable(lhs,rhs);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
mac(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
mac(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
conformable(lhs,rhs);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
sub(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
sub(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
conformable(lhs,rhs);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
add(&tmp,&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
add(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// avoid copy back routines for mult, mac, sub, add
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void mult(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(lhs,ret);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
obj1 tmp;
|
||||||
|
mult(&tmp,&lhs._odata[ss],&rhs);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void mac(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(ret,lhs);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
obj1 tmp;
|
||||||
|
mac(&tmp,&lhs._odata[ss],&rhs);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void sub(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(ret,lhs);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
sub(&tmp,&lhs._odata[ss],&rhs);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
sub(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void add(Lattice<obj1> &ret,const Lattice<obj2> &lhs,const obj3 &rhs){
|
||||||
|
ret.checkerboard = lhs.checkerboard;
|
||||||
|
conformable(lhs,ret);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
add(&tmp,&lhs._odata[ss],&rhs);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
add(&ret._odata[ss],&lhs._odata[ss],&rhs);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// avoid copy back routines for mult, mac, sub, add
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void mult(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = rhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
mult(&tmp,&lhs,&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
mult(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void mac(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = rhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
mac(&tmp,&lhs,&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
mac(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void sub(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = rhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
sub(&tmp,&lhs,&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
sub(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class obj1,class obj2,class obj3> strong_inline
|
||||||
|
void add(Lattice<obj1> &ret,const obj2 &lhs,const Lattice<obj3> &rhs){
|
||||||
|
ret.checkerboard = rhs.checkerboard;
|
||||||
|
conformable(ret,rhs);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
obj1 tmp;
|
||||||
|
add(&tmp,&lhs,&rhs._odata[ss]);
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
add(&ret._odata[ss],&lhs,&rhs._odata[ss]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class sobj,class vobj> strong_inline
|
||||||
|
void axpy(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||||
|
ret.checkerboard = x.checkerboard;
|
||||||
|
conformable(ret,x);
|
||||||
|
conformable(x,y);
|
||||||
|
parallel_for(int ss=0;ss<x._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
vobj tmp = a*x._odata[ss]+y._odata[ss];
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
ret._odata[ss]=a*x._odata[ss]+y._odata[ss];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class sobj,class vobj> strong_inline
|
||||||
|
void axpby(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||||
|
ret.checkerboard = x.checkerboard;
|
||||||
|
conformable(ret,x);
|
||||||
|
conformable(x,y);
|
||||||
|
parallel_for(int ss=0;ss<x._grid->oSites();ss++){
|
||||||
|
#ifdef STREAMING_STORES
|
||||||
|
vobj tmp = a*x._odata[ss]+b*y._odata[ss];
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
#else
|
||||||
|
ret._odata[ss]=a*x._odata[ss]+b*y._odata[ss];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class sobj,class vobj> strong_inline
|
||||||
|
RealD axpy_norm(Lattice<vobj> &ret,sobj a,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||||
|
ret.checkerboard = x.checkerboard;
|
||||||
|
conformable(ret,x);
|
||||||
|
conformable(x,y);
|
||||||
|
axpy(ret,a,x,y);
|
||||||
|
return norm2(ret);
|
||||||
|
}
|
||||||
|
template<class sobj,class vobj> strong_inline
|
||||||
|
RealD axpby_norm(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const Lattice<vobj> &y){
|
||||||
|
ret.checkerboard = x.checkerboard;
|
||||||
|
conformable(ret,x);
|
||||||
|
conformable(x,y);
|
||||||
|
axpby(ret,a,b,x,y);
|
||||||
|
return norm2(ret); // FIXME implement parallel norm in ss loop
|
||||||
|
}
|
||||||
|
|
||||||
|
NAMESPACE_END(Grid);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user