#include "Grid.h" using namespace std; using namespace Grid; using namespace Grid::QCD; template class SimpleCompressor { public: void Point(int) {}; vobj operator() (const vobj &arg) { return arg; } }; int main (int argc, char ** argv) { Grid_init(&argc,&argv); std::vector simd_layout({1,1,2,2}); std::vector mpi_layout ({2,2,2,2}); std::vector latt_size ({8,8,8,8}); double volume = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; GridCartesian Fine(latt_size,simd_layout,mpi_layout); GridRedBlackCartesian rbFine(latt_size,simd_layout,mpi_layout); GridParallelRNG fRNG(&Fine); fRNG.SeedRandomDevice(); LatticeColourMatrix Foo(&Fine); LatticeColourMatrix Bar(&Fine); LatticeColourMatrix Check(&Fine); LatticeColourMatrix Diff(&Fine); random(fRNG,Foo); gaussian(fRNG,Bar); for(int dir=0;dir<4;dir++){ for(int disp=0;disp directions(npoint,dir); std::vector displacements(npoint,disp); CartesianStencil myStencil(&Fine,npoint,0,directions,displacements); printf("STENCIL: osites %d %d dir %d disp %d\n",Fine.oSites(),(int)myStencil._offsets[0].size(),dir,disp); std::vector ocoor(4); for(int o=0;o > comm_buf(myStencil._unified_buffer_size); printf("calling halo exchange\n");fflush(stdout); SimpleCompressor compress; myStencil.HaloExchange(Foo,comm_buf,compress); Bar = Cshift(Foo,dir,disp); // Implement a stencil code that should agree with cshift! for(int i=0;ioSites();i++){ int offset = myStencil._offsets [0][i]; int local = myStencil._is_local[0][i]; int permute_type = myStencil._permute_type[0]; int perm =myStencil._permute[0][i]; if ( local && perm ) permute(Check._odata[i],Foo._odata[offset],permute_type); else if (local) Check._odata[i] = Foo._odata[offset]; else Check._odata[i] = comm_buf[offset]; } Real nrmC = norm2(Check); Real nrmB = norm2(Bar); Real nrm = norm2(Check-Bar); printf("N2diff = %le (%le, %le) \n",nrm,nrmC,nrmB);fflush(stdout); Real snrmC =0; Real snrmB =0; Real snrm =0; std::vector coor(4); for(coor[3]=0;coor[3] 0){ printf("Coor (%d %d %d %d) \t rc %d%d \t %le %le %le\n", coor[0],coor[1],coor[2],coor[3],r,c, nn, real(check()()(r,c)), real(bar()()(r,c)) ); } snrmC=snrmC+real(conj(check()()(r,c))*check()()(r,c)); snrmB=snrmB+real(conj(bar()()(r,c))*bar()()(r,c)); snrm=snrm+nn; }} }}}} printf("scalar N2diff = %le (%le, %le) \n",snrm,snrmC,snrmB);fflush(stdout); } } Grid_finalize(); }