/* * Test_fatLinks.cc * * D. Clarke * * Test the various constructs used to make fat links. * */ #include #include #include using namespace Grid; // This is to optimize the SIMD (will also need to be in the class, at least for now) template void gpermute(vobj & inout,int perm) { vobj tmp=inout; if (perm & 0x1) {permute(inout,tmp,0); tmp=inout;} if (perm & 0x2) {permute(inout,tmp,1); tmp=inout;} if (perm & 0x4) {permute(inout,tmp,2); tmp=inout;} if (perm & 0x8) {permute(inout,tmp,3); tmp=inout;} } // Make the logger work like Python print() template inline std::string sjoin(Args&&... args) noexcept { std::ostringstream msg; (msg << ... << args); return msg.str(); } template inline void Grid_log(Args&&... args) { std::string msg = sjoin(std::forward(args)...); std::cout << GridLogMessage << msg << std::endl; } struct fatParams: Serializable { GRID_SERIALIZABLE_CLASS_MEMBERS( fatParams, std::string, conf_in, std::string, conf_out); template fatParams(Reader& Reader){ read(Reader, "parameters", *this); } }; int main (int argc, char **argv) { Grid_init(&argc,&argv); Coordinate latt_size = GridDefaultLatt(); Coordinate simd_layout = GridDefaultSimd(Nd,vComplexD::Nsimd()); Coordinate mpi_layout = GridDefaultMpi(); Grid_log("mpi = ",mpi_layout); Grid_log("simd = ",simd_layout); Grid_log("latt = ",latt_size); GridCartesian GRID(latt_size,simd_layout,mpi_layout); XmlReader Reader("fatParams.xml",false, "grid"); fatParams param(Reader); LatticeGaugeField Umu(&GRID); FieldMetaData header; NerscIO::readConfiguration(Umu, header, param.conf_in); // Create a padded cell of extra padding depth=1 int depth = 1; PaddedCell Ghost(depth,&GRID); LatticeGaugeField Ughost = Ghost.Exchange(Umu); // Array for (x) GridBase *GhostGrid = Ughost.Grid(); LatticeComplex gplaq(GhostGrid); // This is where the 3-link constructs will be stored LatticeGaugeField Ughost_3link(Ughost.Grid()); // Create 3-link stencil (class will build its own stencils) // writing your own stencil, you're hard-coding the periodic BCs, so you don't need // the policy-based stuff, at least for now std::vector shifts; for(int mu=0;mu_offset; int o1 = SE1->_offset; int o2 = SE2->_offset; int o3 = SE3->_offset; int o4 = SE4->_offset; int o5 = SE5->_offset; auto U0 = U_v[o0](nu); auto U1 = adj(U_v[o1](mu)); auto U2 = adj(U_v[o2](nu)); gpermute(U0,SE0->_permute); gpermute(U1,SE1->_permute); gpermute(U2,SE2->_permute); auto U3 = adj(U_v[o3](nu)); auto U4 = adj(U_v[o4](mu)); auto U5 = U_v[o5](nu); gpermute(U3,SE3->_permute); gpermute(U4,SE4->_permute); gpermute(U5,SE5->_permute); // Forward contribution from this orientation auto W = U0*U1*U2; U_3link_v[ss](mu) = U_3link_v[ss](mu) + W; // Backward contribution from this orientation W = U3*U4*U5; U_3link_v[ss](mu) = U_3link_v[ss](mu) + W; s=s+6; } } } // Here is my understanding of this part: The padded cell has its own periodic BCs, so // if I take a step to the right at the right-most side of the cell, I end up on the // left-most side. This means that the plaquettes in the padding are wrong. Luckily // all we care about are the plaquettes in the cell, which we obtain from Extract. Umu = Ghost.Extract(Ughost_3link); NerscIO::writeConfiguration(Umu,param.conf_out,"HISQ"); Grid_finalize(); }