#ifndef GRID_LATTICE_ARITH_H #define GRID_LATTICE_ARITH_H namespace Grid { ////////////////////////////////////////////////////////////////////////////////////////////////////// // avoid copy back routines for mult, mac, sub, add ////////////////////////////////////////////////////////////////////////////////////////////////////// template strong_inline void mult(Lattice &ret,const Lattice &lhs,const Lattice &rhs){ conformable(lhs,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mult(&tmp,&lhs._odata[ss],&rhs._odata[ss]); vstream(ret._odata[ss],tmp); // mult(&ret._odata[ss],&lhs._odata[ss],&rhs._odata[ss]); } } template strong_inline void mac(Lattice &ret,const Lattice &lhs,const Lattice &rhs){ conformable(lhs,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mac(&tmp,&lhs._odata[ss],&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void sub(Lattice &ret,const Lattice &lhs,const Lattice &rhs){ conformable(lhs,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; sub(&tmp,&lhs._odata[ss],&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void add(Lattice &ret,const Lattice &lhs,const Lattice &rhs){ conformable(lhs,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; add(&tmp,&lhs._odata[ss],&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } ////////////////////////////////////////////////////////////////////////////////////////////////////// // avoid copy back routines for mult, mac, sub, add ////////////////////////////////////////////////////////////////////////////////////////////////////// template strong_inline void mult(Lattice &ret,const Lattice &lhs,const obj3 &rhs){ conformable(lhs,ret); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mult(&tmp,&lhs._odata[ss],&rhs); vstream(ret._odata[ss],tmp); } } template strong_inline void mac(Lattice &ret,const Lattice &lhs,const obj3 &rhs){ conformable(lhs,ret); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mac(&tmp,&lhs._odata[ss],&rhs); vstream(ret._odata[ss],tmp); } } template strong_inline void sub(Lattice &ret,const Lattice &lhs,const obj3 &rhs){ conformable(lhs,ret); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; sub(&tmp,&lhs._odata[ss],&rhs); vstream(ret._odata[ss],tmp); } } template strong_inline void add(Lattice &ret,const Lattice &lhs,const obj3 &rhs){ conformable(lhs,ret); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; add(&tmp,&lhs._odata[ss],&rhs); vstream(ret._odata[ss],tmp); } } ////////////////////////////////////////////////////////////////////////////////////////////////////// // avoid copy back routines for mult, mac, sub, add ////////////////////////////////////////////////////////////////////////////////////////////////////// template strong_inline void mult(Lattice &ret,const obj2 &lhs,const Lattice &rhs){ conformable(ret,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mult(&tmp,&lhs,&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void mac(Lattice &ret,const obj2 &lhs,const Lattice &rhs){ conformable(ret,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; mac(&tmp,&lhs,&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void sub(Lattice &ret,const obj2 &lhs,const Lattice &rhs){ conformable(ret,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; sub(&tmp,&lhs,&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void add(Lattice &ret,const obj2 &lhs,const Lattice &rhs){ conformable(ret,rhs); PARALLEL_FOR_LOOP for(int ss=0;ssoSites();ss++){ obj1 tmp; add(&tmp,&lhs,&rhs._odata[ss]); vstream(ret._odata[ss],tmp); } } template strong_inline void axpy(Lattice &ret,sobj a,const Lattice &lhs,const Lattice &rhs){ conformable(lhs,rhs); #pragma omp parallel for for(int ss=0;ssoSites();ss++){ vobj tmp = a*lhs._odata[ss]; vstream(ret._odata[ss],tmp+rhs._odata[ss]); } } } #endif