From ab894186589224d570e0ecef8eea06443194a8ab Mon Sep 17 00:00:00 2001 From: paboyle Date: Wed, 11 May 2016 15:18:47 +0100 Subject: [PATCH] Precision change going in; useful for mixed precision algorithms for example. --- lib/lattice/Lattice_transfer.h | 49 +++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/lib/lattice/Lattice_transfer.h b/lib/lattice/Lattice_transfer.h index f361f7d4..178b5937 100644 --- a/lib/lattice/Lattice_transfer.h +++ b/lib/lattice/Lattice_transfer.h @@ -325,6 +325,41 @@ inline void blockPromote(const Lattice > &coarseData, } +// Useful for precision conversion, or indeed anything where an operator= does a conversion on scalars. +// Simd layouts need not match since we use peek/poke Local +template +void localConvert(const Lattice &in,Lattice &out) +{ + typedef typename vobj::scalar_object sobj; + typedef typename vvobj::scalar_object ssobj; + + sobj s; + ssobj ss; + + GridBase *ig = in._grid; + GridBase *og = out._grid; + + int ni = ig->_ndimension; + int no = og->_ndimension; + + assert(ni == no); + + for(int d=0;d_processors[d] == og->_processors[d]); + assert(ig->_ldimensions[d] == og->_ldimensions[d]); + } + +PARALLEL_FOR_LOOP + for(int idx=0;idxlSites();idx++){ + std::vector lcoor(ni); + ig->LocalIndexToLocalCoor(idx,lcoor); + peekLocalSite(s,in,lcoor); + ss=s; + pokeLocalSite(ss,out,lcoor); + } +} + + template void InsertSlice(const Lattice &lowDim,Lattice & higherDim,int slice, int orthog) { @@ -351,12 +386,13 @@ void InsertSlice(const Lattice &lowDim,Lattice & higherDim,int slice } // the above should guarantee that the operations are local - std::vector lcoor(nl); - std::vector hcoor(nh); - hcoor[orthog] = slice; +PARALLEL_FOR_LOOP for(int idx=0;idxlSites();idx++){ + std::vector lcoor(nl); + std::vector hcoor(nh); lg->LocalIndexToLocalCoor(idx,lcoor); dl=0; + hcoor[orthog] = slice; for(int d=0;d &lowDim,const Lattice & higherDim,int slic } } // the above should guarantee that the operations are local - std::vector lcoor(nl); - std::vector hcoor(nh); - hcoor[orthog] = slice; +PARALLEL_FOR_LOOP for(int idx=0;idxlSites();idx++){ + std::vector lcoor(nl); + std::vector hcoor(nh); lg->LocalIndexToLocalCoor(idx,lcoor); dl=0; + hcoor[orthog] = slice; for(int d=0;d