From a3c0fb79b6fab365aca3cce8c7d736b804dbca55 Mon Sep 17 00:00:00 2001 From: Christopher Kelly Date: Mon, 11 Jul 2016 17:15:22 -0400 Subject: [PATCH 1/2] Fix to iVector and iMatrix pokeIndex and checkerboard local site indexing. --- lib/cartesian/Cartesian_base.h | 2 +- lib/cartesian/Cartesian_red_black.h | 15 +++++++++++++-- lib/tensors/Tensor_index.h | 8 ++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/cartesian/Cartesian_base.h b/lib/cartesian/Cartesian_base.h index 8272ac71..6fac30e9 100644 --- a/lib/cartesian/Cartesian_base.h +++ b/lib/cartesian/Cartesian_base.h @@ -123,7 +123,7 @@ public: ////////////////////////////////////////////////////////// // SIMD lane addressing ////////////////////////////////////////////////////////// - inline int iIndex(std::vector &lcoor) + virtual int iIndex(std::vector &lcoor) { int idx=0; for(int d=0;d<_ndimension;d++) idx+=_istride[d]*(lcoor[d]/_rdimensions[d]); diff --git a/lib/cartesian/Cartesian_red_black.h b/lib/cartesian/Cartesian_red_black.h index 2424d8dc..d6b6afe6 100644 --- a/lib/cartesian/Cartesian_red_black.h +++ b/lib/cartesian/Cartesian_red_black.h @@ -224,9 +224,20 @@ protected: idx+=_ostride[d]*(coor[d]%_rdimensions[d]); } } - return idx; + return idx; }; - + virtual int iIndex(std::vector &lcoor) + { + int idx=0; + for(int d=0;d<_ndimension;d++) { + if( d==_checker_dim ) { + idx+=_istride[d]*(lcoor[d]/(2*_rdimensions[d])); + } else { + idx+=_istride[d]*(lcoor[d]/_rdimensions[d]); + } + } + return idx; + } }; } diff --git a/lib/tensors/Tensor_index.h b/lib/tensors/Tensor_index.h index bad9b1f1..7f34f3ac 100644 --- a/lib/tensors/Tensor_index.h +++ b/lib/tensors/Tensor_index.h @@ -146,14 +146,14 @@ class TensorIndexRecursion { } template inline static - void pokeIndex(iVector &ret, const iVector::peekIndex(ret._internal,0)),N> &arg, int i) + void pokeIndex(iVector &ret, const iVector::peekIndex(ret._internal[0],0)),N> &arg, int i) { for(int ii=0;ii::pokeIndex(ret._internal[ii],arg._internal[ii],i); } } template inline static - void pokeIndex(iVector &ret, const iVector::peekIndex(ret._internal,0)),N> &arg, int i,int j) + void pokeIndex(iVector &ret, const iVector::peekIndex(ret._internal[0],0)),N> &arg, int i,int j) { for(int ii=0;ii::pokeIndex(ret._internal[ii],arg._internal[ii],i,j); @@ -161,7 +161,7 @@ class TensorIndexRecursion { } template inline static - void pokeIndex(iMatrix &ret, const iMatrix::peekIndex(ret._internal,0)),N> &arg, int i) + void pokeIndex(iMatrix &ret, const iMatrix::peekIndex(ret._internal[0][0],0)),N> &arg, int i) { for(int ii=0;ii inline static - void pokeIndex(iMatrix &ret, const iMatrix::peekIndex(ret._internal,0)),N> &arg, int i,int j) + void pokeIndex(iMatrix &ret, const iMatrix::peekIndex(ret._internal[0][0],0)),N> &arg, int i,int j) { for(int ii=0;ii Date: Wed, 13 Jul 2016 10:49:18 -0400 Subject: [PATCH 2/2] Disabled parallel for loops in ExtractSlice and InsertSlice due to race conditions. Likely will need to do so for localConvert too. --- lib/lattice/Lattice_transfer.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/lattice/Lattice_transfer.h b/lib/lattice/Lattice_transfer.h index bd53cde9..2fa72014 100644 --- a/lib/lattice/Lattice_transfer.h +++ b/lib/lattice/Lattice_transfer.h @@ -386,7 +386,7 @@ void InsertSlice(Lattice &lowDim,Lattice & higherDim,int slice, int } // the above should guarantee that the operations are local -PARALLEL_FOR_LOOP + //PARALLEL_FOR_LOOP for(int idx=0;idxlSites();idx++){ std::vector lcoor(nl); std::vector hcoor(nh); @@ -420,15 +420,15 @@ void ExtractSlice(Lattice &lowDim, Lattice & higherDim,int slice, in assert(hg->_processors[orthog]==1); int dl; dl = 0; - for(int d=0;d_processors[dl] == hg->_processors[d]); - assert(lg->_ldimensions[dl] == hg->_ldimensions[d]); - dl++; + for(int d=0;d_processors[dl] == hg->_processors[d]); + assert(lg->_ldimensions[dl] == hg->_ldimensions[d]); + dl++; } } // the above should guarantee that the operations are local -PARALLEL_FOR_LOOP + //PARALLEL_FOR_LOOP for(int idx=0;idxlSites();idx++){ std::vector lcoor(nl); std::vector hcoor(nh);