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

Namespace, indent

This commit is contained in:
paboyle 2018-01-14 23:54:25 +00:00
parent 06ab7f5661
commit 8aed4181e1

View File

@ -23,12 +23,12 @@ 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_TRANSFER_H #ifndef GRID_LATTICE_TRANSFER_H
#define GRID_LATTICE_TRANSFER_H #define GRID_LATTICE_TRANSFER_H
namespace Grid { NAMESPACE_BEGIN(Grid);
inline void subdivides(GridBase *coarse,GridBase *fine) inline void subdivides(GridBase *coarse,GridBase *fine)
{ {
@ -45,39 +45,39 @@ inline void subdivides(GridBase *coarse,GridBase *fine)
} }
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
// remove and insert a half checkerboard // remove and insert a half checkerboard
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
template<class vobj> inline void pickCheckerboard(int cb,Lattice<vobj> &half,const Lattice<vobj> &full){ template<class vobj> inline void pickCheckerboard(int cb,Lattice<vobj> &half,const Lattice<vobj> &full){
half.checkerboard = cb; half.checkerboard = cb;
parallel_for(int ss=0;ss<full._grid->oSites();ss++){ parallel_for(int ss=0;ss<full._grid->oSites();ss++){
int cbos; int cbos;
std::vector<int> coor; std::vector<int> coor;
full._grid->oCoorFromOindex(coor,ss); full._grid->oCoorFromOindex(coor,ss);
cbos=half._grid->CheckerBoard(coor); cbos=half._grid->CheckerBoard(coor);
if (cbos==cb) { if (cbos==cb) {
int ssh=half._grid->oIndex(coor); int ssh=half._grid->oIndex(coor);
half._odata[ssh] = full._odata[ss]; half._odata[ssh] = full._odata[ss];
}
} }
} }
template<class vobj> inline void setCheckerboard(Lattice<vobj> &full,const Lattice<vobj> &half){ }
int cb = half.checkerboard; template<class vobj> inline void setCheckerboard(Lattice<vobj> &full,const Lattice<vobj> &half){
parallel_for(int ss=0;ss<full._grid->oSites();ss++){ int cb = half.checkerboard;
std::vector<int> coor; parallel_for(int ss=0;ss<full._grid->oSites();ss++){
int cbos; std::vector<int> coor;
int cbos;
full._grid->oCoorFromOindex(coor,ss); full._grid->oCoorFromOindex(coor,ss);
cbos=half._grid->CheckerBoard(coor); cbos=half._grid->CheckerBoard(coor);
if (cbos==cb) { if (cbos==cb) {
int ssh=half._grid->oIndex(coor); int ssh=half._grid->oIndex(coor);
full._odata[ss]=half._odata[ssh]; full._odata[ss]=half._odata[ssh];
}
} }
} }
}
template<class vobj,class CComplex,int nbasis> template<class vobj,class CComplex,int nbasis>
@ -115,13 +115,13 @@ inline void blockProject(Lattice<iVector<CComplex,nbasis > > &coarseData,
for(int d=0;d<_ndimension;d++) coor_c[d]=coor_f[d]/block_r[d]; for(int d=0;d<_ndimension;d++) coor_c[d]=coor_f[d]/block_r[d];
Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions); Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
PARALLEL_CRITICAL PARALLEL_CRITICAL
for(int i=0;i<nbasis;i++) { for(int i=0;i<nbasis;i++) {
coarseData._odata[sc](i)=coarseData._odata[sc](i) coarseData._odata[sc](i)=coarseData._odata[sc](i)
+ innerProduct(Basis[i]._odata[sf],fineData._odata[sf]); + innerProduct(Basis[i]._odata[sf],fineData._odata[sf]);
} }
} }
return; return;
} }
@ -169,9 +169,9 @@ inline void blockZAXPY(Lattice<vobj> &fineZ,
return; return;
} }
template<class vobj,class CComplex> template<class vobj,class CComplex>
inline void blockInnerProduct(Lattice<CComplex> &CoarseInner, inline void blockInnerProduct(Lattice<CComplex> &CoarseInner,
const Lattice<vobj> &fineX, const Lattice<vobj> &fineX,
const Lattice<vobj> &fineY) const Lattice<vobj> &fineY)
{ {
typedef decltype(innerProduct(fineX._odata[0],fineY._odata[0])) dotp; typedef decltype(innerProduct(fineX._odata[0],fineY._odata[0])) dotp;
@ -230,8 +230,8 @@ inline void blockSum(Lattice<vobj> &coarseData,const Lattice<vobj> &fineData)
for(int d=0;d<_ndimension;d++) coor_c[d]=coor_f[d]/block_r[d]; for(int d=0;d<_ndimension;d++) coor_c[d]=coor_f[d]/block_r[d];
Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions); Lexicographic::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
PARALLEL_CRITICAL PARALLEL_CRITICAL
coarseData._odata[sc]=coarseData._odata[sc]+fineData._odata[sf]; coarseData._odata[sc]=coarseData._odata[sc]+fineData._odata[sf];
} }
} }
@ -422,11 +422,11 @@ void ExtractSlice(Lattice<vobj> &lowDim,const Lattice<vobj> & higherDim,int slic
assert(hg->_processors[orthog]==1); assert(hg->_processors[orthog]==1);
int dl; dl = 0; int dl; dl = 0;
for(int d=0;d<nh;d++){ for(int d=0;d<nh;d++){
if ( d != orthog) { if ( d != orthog) {
assert(lg->_processors[dl] == hg->_processors[d]); assert(lg->_processors[dl] == hg->_processors[d]);
assert(lg->_ldimensions[dl] == hg->_ldimensions[d]); assert(lg->_ldimensions[dl] == hg->_ldimensions[d]);
dl++; dl++;
} }
} }
// the above should guarantee that the operations are local // the above should guarantee that the operations are local
@ -602,7 +602,7 @@ unvectorizeToLexOrdArray(std::vector<sobj> &out, const Lattice<vobj> &in)
//Copy SIMD-vectorized lattice to array of scalar objects in lexicographic order //Copy SIMD-vectorized lattice to array of scalar objects in lexicographic order
template<typename vobj, typename sobj> template<typename vobj, typename sobj>
typename std::enable_if<isSIMDvectorized<vobj>::value typename std::enable_if<isSIMDvectorized<vobj>::value
&& !isSIMDvectorized<sobj>::value, void>::type && !isSIMDvectorized<sobj>::value, void>::type
vectorizeFromLexOrdArray( std::vector<sobj> &in, Lattice<vobj> &out) vectorizeFromLexOrdArray( std::vector<sobj> &in, Lattice<vobj> &out)
{ {
@ -987,5 +987,5 @@ void Grid_unsplit(std::vector<Lattice<Vobj> > & full,Lattice<Vobj> & split)
} }
} }
} NAMESPACE_END(Grid);
#endif #endif