/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/Test_main.cc Copyright (C) 2015 Author: Azusa Yamaguchi Author: Peter Boyle Author: neo Author: paboyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #include using namespace std; using namespace Grid; using namespace Grid::QCD; /* Grid_main.cc(232): error: no suitable user-defined conversion from "Grid::iScalar, 4>>" to "const Grid::iScalar>>" exists c_m = peekIdiot(scm,1,2); */ template auto peekIdiot(const vobj &rhs,int i,int j) -> decltype(peekIndex<2>(rhs,0,0)) { return peekIndex<2>(rhs,i,j); } template auto peekDumKopf(const vobj &rhs,int i,int j) -> decltype(peekIndex<3>(rhs,0,0)) { return peekIndex<3>(rhs,i,j); } template auto peekDumKopf(const vobj &rhs,int i) -> decltype(peekIndex<3>(rhs,0)) { return peekIndex<3>(rhs,i); } int main (int argc, char ** argv) { Grid_init(&argc,&argv); std::vector latt_size = GridDefaultLatt(); std::vector simd_layout = GridDefaultSimd(4,vComplex::Nsimd()); std::vector mpi_layout = GridDefaultMpi(); latt_size.resize(4); #ifdef AVX512 for(int omp=128;omp<236;omp+=16){ #else for(int omp=1;omp<2;omp*=20){ #endif #ifdef OMP omp_set_num_threads(omp); #endif for(int lat=8;lat<=16;lat+=40){ std::cout << "Lat "< saved; SerialRNG.GetState(saved,0); SerialRNG1.SetState(saved,0); RealD dd1,dd2; std::cout << "Testing RNG state save restore"< iGammaFive; ColourMatrix cmat; random(FineRNG,Foo); gaussian(FineRNG,Bar); random(FineRNG,scFoo); random(FineRNG,scBar); random(FineRNG,cMat); random(FineRNG,sMat); random(FineRNG,scMat); random(FineRNG,lcMat); random(FineRNG,cVec); random(FineRNG,sVec); random(FineRNG,scVec); fflush(stdout); TComplex tr = trace(cmat); cVec = cMat * cVec; // LatticeColourVector = LatticeColourMatrix * LatticeColourVector sVec = sMat * sVec; // LatticeSpinVector = LatticeSpinMatrix * LatticeSpinVector scVec= scMat * scVec;// LatticeSpinColourVector = LatticeSpinColourMatrix * LatticeSpinColourVector scVec= cMat * scVec; // LatticeSpinColourVector = LatticeColourMatrix * LatticeSpinColourVector scVec= sMat * scVec; // LatticeSpinColourVector = LatticeSpinMatrix * LatticeSpinColourVector cMat = outerProduct(cVec,cVec); scalar = localInnerProduct(cVec,cVec); cMat = Ta(cMat); //traceless antihermitian scalar += scalar; scalar -= scalar; scalar *= scalar; add(scalar,scalar,scalar); sub(scalar,scalar,scalar); mult(scalar,scalar,scalar); mac(scalar,scalar,scalar); scalar = scalar+scalar; scalar = scalar-scalar; scalar = scalar*scalar; scalar=outerProduct(scalar,scalar); scalar=adj(scalar); // rscalar=real(scalar); // iscalar=imag(scalar); // scalar =cmplx(rscalar,iscalar); PokeIndex(cVec,scalar,1); scalar=transpose(scalar); scalar=TransposeIndex(scalar); scalar=TraceIndex(scalar); scalar=PeekIndex(cVec,0); scalar=trace(scalar); scalar=localInnerProduct(cVec,cVec); scalar=localNorm2(cVec); // -=,+=,*=,() // add,+,sub,-,mult,mac,* // adj,conjugate // real,imag // transpose,transposeIndex // trace,traceIndex // peekIndex // innerProduct,outerProduct, // localNorm2 // localInnerProduct scMat = sMat*scMat; // LatticeSpinColourMatrix = LatticeSpinMatrix * LatticeSpinColourMatrix /////////////////////// // Non-lattice (const objects) * Lattice ColourMatrix cm; SpinColourMatrix scm; vSpinColourMatrix vscm; Complex cplx(1.0); Integer myint=1; double mydouble=1.0; // vSpinColourMatrix vscm; scMat = cMat*scMat; scm = cm * scm; // SpinColourMatrix = ColourMatrix * SpinColourMatrix scm = scm *cm; // SpinColourMatrix = SpinColourMartix * ColourMatrix scm = GammaFive * scm ; // SpinColourMatrix = SpinMatrix * SpinColourMatrix scm = scm* GammaFive ; // SpinColourMatrix = SpinColourMatrix * SpinMatrix scm = scm*cplx; vscm = vscm*cplx; scMat = scMat*cplx; scm = cplx*scm; vscm = cplx*vscm; scMat = cplx*scMat; scm = myint*scm; vscm = myint*vscm; scMat = scMat*myint; scm = scm*mydouble; vscm = vscm*mydouble; scMat = scMat*mydouble; scMat = mydouble*scMat; cMat = mydouble*cMat; sMat = adj(sMat); // LatticeSpinMatrix adjoint sMat = iGammaFive*sMat; // SpinMatrix * LatticeSpinMatrix sMat = GammaFive*sMat; // SpinMatrix * LatticeSpinMatrix scMat= adj(scMat); cMat= adj(cMat); cm=adj(cm); scm=adj(scm); scm=transpose(scm); scm=transposeIndex<1>(scm); random(SerialRNG, cm); std::cout< mysite {0,0,0,0}; random(FineRNG,cMat); cMat = Ta(cMat); peekSite(cm, cMat, mysite); std::cout<::traceIndex(sc_m); // Map to traceColour c_m = TensorIndexRecursion::traceIndex(sc_m); // map to traceSpin c = TensorIndexRecursion::traceIndex(s_m); c = TensorIndexRecursion::traceIndex(c_m); s_m = TensorIndexRecursion::peekIndex(scm,0,0); c_m = TensorIndexRecursion::peekIndex(scm,1,2); // c_m = peekSpin(scm,1,2); // c_m = peekIdiot(scm,1,2); printf("c. Level %d\n",c_m.TensorLevel); printf("c. Level %d\n",c_m().TensorLevel); printf("c. Level %d\n",c_m()().TensorLevel); c_m()() = scm()(0,0); //ColourComponents of CM <= ColourComponents of SpinColourMatrix scm()(1,1) = cm()(); //ColourComponents of CM <= ColourComponents of SpinColourMatrix c = scm()(1,1)(1,2); scm()(1,1)(2,1) = c; // pokeIndex (c_m,c,0,0); } FooBar = Bar; /* { std::vector coor(4); for(int d=0;d<4;d++) coor[d] = 0; peekSite(cmat,Foo,coor); Foo = zero; pokeSite(cmat,Foo,coor); } random(Foo); */ lex_sites(Foo); Integer mm[4]; mm[0]=1; mm[1]=Fine._rdimensions[0]; mm[2]=Fine._ldimensions[0]*Fine._ldimensions[1]; mm[3]=Fine._ldimensions[0]*Fine._ldimensions[1]*Fine._ldimensions[2]; LatticeInteger lex(&Fine); lex=zero; for(int d=0;d<4;d++){ LatticeInteger coor(&Fine); LatticeCoordinate(coor,d); lex = lex + coor*mm[d]; } // Bar = zero; // Bar = where(lex coor(4); for(coor[3]=0;coor[3]black rShifted = Cshift(bFoo,dir,shift); // Shift black->red ShiftedCheck=zero; setCheckerboard(ShiftedCheck,bShifted); // Put them all together setCheckerboard(ShiftedCheck,rShifted); // and check the results (later) // Check results std::vector coor(4); for(coor[3]=0;coor[3] diff; std::vector shiftcoor = coor; shiftcoor[dir]=(shiftcoor[dir]+shift+latt_size[dir])%(latt_size[dir]/mpi_layout[dir]); std::vector rl(4); for(int dd=0;dd<4;dd++){ rl[dd] = latt_size[dd]/simd_layout[dd]/mpi_layout[dd]; } int lex = coor[0]%rl[0] + (coor[1]%rl[1])*rl[0] + (coor[2]%rl[2])*rl[0]*rl[1] + (coor[3]%rl[3])*rl[0]*rl[1]*rl[2]; lex += +1000*(coor[0]/rl[0]) +1000*(coor[1]/rl[1])*simd_layout[0] +1000*(coor[2]/rl[2])*simd_layout[0]*simd_layout[1] +1000*(coor[3]/rl[3])*simd_layout[0]*simd_layout[1]*simd_layout[2]; int lex_coor = shiftcoor[0]%rl[0] + (shiftcoor[1]%rl[1])*rl[0] + (shiftcoor[2]%rl[2])*rl[0]*rl[1] + (shiftcoor[3]%rl[3])*rl[0]*rl[1]*rl[2]; lex_coor += +1000*(shiftcoor[0]/rl[0]) +1000*(shiftcoor[1]/rl[1])*simd_layout[0] +1000*(shiftcoor[2]/rl[2])*simd_layout[0]*simd_layout[1] +1000*(shiftcoor[3]/rl[3])*simd_layout[0]*simd_layout[1]*simd_layout[2]; ColourMatrix foo; ColourMatrix bar; ColourMatrix shifted1; ColourMatrix shifted2; ColourMatrix shifted3; ColourMatrix foobar1; ColourMatrix foobar2; ColourMatrix mdiff,amdiff; peekSite(shifted1,Shifted,coor); peekSite(shifted2,Foo,shiftcoor); peekSite(shifted3,ShiftedCheck,coor); peekSite(foo,Foo,coor); mdiff = shifted1-shifted2; amdiff=adj(mdiff); ColourMatrix prod = amdiff*mdiff; Complex trprod = trace(prod); Real Ttr=real(trprod); double nn=Ttr; if ( nn > 0 ) cout<<"Shift real trace fail "< 0 ) cout<<"Shift fail (shifted1/shifted2-ref) "< 0 ) cout<<"Shift rb fail (shifted3/shifted2-ref) "<