34#ifndef QCD_UTILS_WILSON_LOOPS_H
35#define QCD_UTILS_WILSON_LOOPS_H
44 typedef typename Gimpl::GaugeLinkField
GaugeMat;
51 const int mu,
const int nu) {
66 plaq = Gimpl::CovShiftForward(
U[mu],mu,
67 Gimpl::CovShiftForward(
U[nu],nu,
68 Gimpl::CovShiftBackward(
U[mu],mu,
69 Gimpl::CovShiftIdentityBackward(
U[nu], nu))));
79 const std::vector<GaugeMat> &
U,
const int mu,
89 const std::vector<GaugeMat> &
U) {
92 for (
int mu = 1; mu <
Nd; mu++) {
93 for (
int nu = 0; nu < mu; nu++) {
95 Plaq = Plaq + sitePlaq;
103 std::vector<GaugeMat>
U(
Nd, Umu.Grid());
105 for (
int mu = 0; mu <
Nd; mu++) {
123 double vol = Umu.Grid()->gSites();
124 double faces = (1.0 *
Nd * (
Nd - 1)) / 2.0;
125 return sumplaq / vol / faces /
Nc;
132 const std::vector<GaugeMat> &
U) {
135 for (
int mu = 1; mu <
Nd-1; mu++) {
136 for (
int nu = 0; nu < mu; nu++) {
138 Plaq = Plaq + sitePlaq;
147 std::vector<GaugeMat>
U(
Nd, Umu.Grid());
149 for (
int mu = 0; mu <
Nd; mu++) {
157 std::vector<sobj> Tq;
160 std::vector<Real> out(Tq.size());
161 for(
int t=0;t<Tq.size();t++) out[t] =
TensorRemove(Tq[t]).real();
170 int Lt = Umu.Grid()->FullDimensions()[
Nd-1];
171 assert(sumplaq.size() == Lt);
172 double vol = Umu.Grid()->gSites() / Lt;
173 double faces = (1.0 * (
Nd - 1)* (
Nd - 2)) / 2.0;
174 for(
int t=0;t<Lt;t++)
175 sumplaq[t] = sumplaq[t] / vol / faces /
Nc;
185 if ((mu < 0 ) || (mu > 3)) {
186 std::cout <<
GridLogError <<
"Index is not an integer inclusively between 0 and 3." << std::endl;
191 GaugeMat U_loop(Umu.Grid()), P(Umu.Grid());
193 int T = Umu.Grid()->GlobalDimensions()[3];
194 int X = Umu.Grid()->GlobalDimensions()[0];
195 int Y = Umu.Grid()->GlobalDimensions()[1];
196 int Z = Umu.Grid()->GlobalDimensions()[2];
199 int N_mu = Umu.Grid()->GlobalDimensions()[mu];
203 for (
int t=1;t<N_mu;t++){
204 P = Gimpl::CovShiftForward(U_loop,mu,P);
222 std::vector<GaugeMat>
U(
Nd, Umu.Grid());
226 for (
int mu = 0; mu <
Nd; mu++) {
234 double vol = Umu.Grid()->gSites();
236 return p.real() / vol / (4.0 *
Nc ) ;
247 std::vector<GaugeMat>
U(
Nd, grid);
248 for (
int d = 0; d <
Nd; d++) {
264 staple += Gimpl::ShiftStaple(
265 Gimpl::CovShiftForward(
267 Gimpl::CovShiftBackward(
268 U[mu], mu, Gimpl::CovShiftIdentityBackward(
U[nu], nu))),
276 staple += Gimpl::ShiftStaple(
277 Gimpl::CovShiftBackward(
U[nu], nu,
278 Gimpl::CovShiftBackward(
U[mu], mu,
U[nu])),
315 std::vector<GaugeMat> Umu(
Nd,
U.Grid());
316 for (
int d = 0; d <
Nd; d++) {
326 staple_v[i] = Zero();
329 for (
int nu = 0; nu <
Nd; nu++) {
342 staple += Gimpl::ShiftStaple(
343 Gimpl::CovShiftForward(
345 Gimpl::CovShiftBackward(
346 Umu[mu], mu, Gimpl::CovShiftIdentityBackward(Umu[nu], nu))),
355 staple += Gimpl::ShiftStaple(
356 Gimpl::CovShiftBackward(Umu[nu], nu,
357 Gimpl::CovShiftBackward(Umu[mu], mu, Umu[nu])), mu);
367 static void StapleAll(std::vector<GaugeMat> &staple,
const std::vector<GaugeMat> &
U) {
368 assert(staple.size() ==
Nd); assert(
U.size() ==
Nd);
369 for(
int mu=0;mu<
Nd;mu++)
Staple(staple[mu],
U, mu);
382 std::vector<Coordinate> shifts = this->
getShifts();
383 nshift = shifts.size();
389 std::cout <<
GridLogPerformance <<
" WilsonLoopPaddedWorkspace timings: coord:" << (t1-t0)/1000 <<
"ms, stencil:" << (t2-t1)/1000 <<
"ms" << std::endl;
394 assert(pcell.
depth >= this->paddingDepth());
414 for(
auto const &s :
stencil_wk) max_depth=std::max(max_depth, s->paddingDepth());
445 std::vector<Coordinate> shifts;
446 for(
int mu=0;mu<
Nd;mu++){
447 for(
int nu=0;nu<
Nd;nu++){
453 Coordinate shift_mnu_pmu(
Nd,0); shift_mnu_pmu[nu]=-1; shift_mnu_pmu[mu]=1;
457 shifts.push_back(shift_nu);
458 shifts.push_back(shift_mu);
461 shifts.push_back(shift_mnu);
462 shifts.push_back(shift_mnu);
463 shifts.push_back(shift_mnu_pmu);
478 StaplePaddedAllWorkspace wk;
490 assert(U_padded.size() ==
Nd); assert(staple.size() ==
Nd);
492 assert(Cell.
depth >= 1);
493 GridBase *ggrid = U_padded[0].Grid();
499 size_t vsize =
Nd*
sizeof(GaugeViewType);
500 GaugeViewType* Ug_dirs_v_host = (GaugeViewType*)malloc(vsize);
508 for(
int mu=0;mu<
Nd;mu++){
514 decltype(coalescedRead(Ug_dirs_v[0][0])) stencil_ss;
518 for(int nu=0;nu<Nd;nu++){
520 GeneralStencilEntry const* e = gStencil_v.GetEntry(off++,ss);
521 auto U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
522 e = gStencil_v.GetEntry(off++,ss);
523 auto U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
524 e = gStencil_v.GetEntry(off++,ss);
525 auto U2 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
527 stencil_ss = stencil_ss + U2 * U1 * U0;
529 e = gStencil_v.GetEntry(off++,ss);
530 U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
531 e = gStencil_v.GetEntry(off++,ss);
532 U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
533 e = gStencil_v.GetEntry(off++,ss);
534 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
536 stencil_ss = stencil_ss + U2 * U1 * U0;
545 staple[mu] = Cell.
Extract(gStaple);
546 outer_off += shift_mu_off;
549 for(
int i=0;i<
Nd;i++) Ug_dirs_v_host[i].ViewClose();
550 free(Ug_dirs_v_host);
555 std::cout <<
GridLogPerformance <<
"StaplePaddedAll timing:" << (t1-t0)/1000 <<
"ms" << std::endl;
567 std::vector<GaugeMat>
U(
Nd, grid);
568 for (
int d = 0; d <
Nd; d++) {
581 staple = Gimpl::ShiftStaple(
582 Gimpl::CovShiftForward(
584 Gimpl::CovShiftBackward(
585 U[mu], mu, Gimpl::CovShiftIdentityBackward(
U[nu], nu))),
598 std::vector<GaugeMat>
U(
Nd, grid);
599 for (
int d = 0; d <
Nd; d++) {
612 staple = Gimpl::ShiftStaple(
613 Gimpl::CovShiftBackward(
U[nu], nu,
614 Gimpl::CovShiftBackward(
U[mu], mu,
U[nu])),
630 GaugeMat Vup(Umu.Grid()), Vdn(Umu.Grid());
637 FS = (u*v + Gimpl::CshiftLink(vu, mu, -1));
638 FS = 0.125*(FS -
adj(FS));
656 double coeff = 8.0/(32.0*
M_PI*
M_PI);
659 auto Tq =
sum(qfield);
668#define Fmu(A) Gimpl::CovShiftForward(Umu, mu, A)
669#define Bmu(A) Gimpl::CovShiftBackward(Umu, mu, A)
670#define Fnu(A) Gimpl::CovShiftForward(Unu, nu, A)
671#define Bnu(A) Gimpl::CovShiftBackward(Unu, nu, A)
672#define FmuI Gimpl::CovShiftIdentityForward(Umu, mu)
673#define BmuI Gimpl::CovShiftIdentityBackward(Umu, mu)
674#define FnuI Gimpl::CovShiftIdentityForward(Unu, nu)
675#define BnuI Gimpl::CovShiftIdentityBackward(Unu, nu)
747 FS = 0.125 * (
F -
adj(
F) );
750 GaugeMat horizontal(Umu.Grid()), vertical(Umu.Grid());
753 FS = 0.0625 * ( horizontal -
adj(horizontal) + vertical -
adj(vertical) );
762 std::vector<std::vector<GaugeMat*> >
F(
Nd,std::vector<GaugeMat*>(
Nd,
nullptr));
766 for(
int mu=0;mu<
Nd-1;mu++){
767 for(
int nu=mu+1; nu<
Nd; nu++){
774 static const int combs[3][4] = { {0,1,2,3}, {0,2,1,3}, {0,3,1,2} };
775 static const int signs[3] = { 1, -1, 1 };
779 for(
int c=0;c<3;c++){
780 int mu = combs[c][0], nu = combs[c][1], rho = combs[c][2], sigma = combs[c][3];
782 fsum = fsum + (8. * coeff * eps) *
trace( (*
F[mu][nu]) * (*
F[rho][sigma]) );
785 for(
int mu=0;mu<
Nd-1;mu++)
786 for(
int nu=mu+1; nu<
Nd; nu++)
790 std::vector<sobj> Tq;
793 std::vector<Real> out(Tq.size());
794 for(
int t=0;t<Tq.size();t++) out[t] =
TensorRemove(Tq[t]).real();
800 for(
int t=0;t<Tq.size();t++) out += Tq[t];
814 static const int exts[5][2] = { {1,1}, {2,2}, {1,2}, {1,3}, {3,3} };
815 std::vector<std::vector<Real> > out(5);
816 for(
int i=0;i<5;i++){
823 static const int exts[5][2] = { {1,1}, {2,2}, {1,2}, {1,3}, {3,3} };
824 std::vector<Real> out(5);
825 std::cout <<
GridLogMessage <<
"Computing topological charge" << std::endl;
826 for(
int i=0;i<5;i++){
828 std::cout <<
GridLogMessage << exts[i][0] <<
"x" << exts[i][1] <<
" Wilson loop contribution " << out[i] << std::endl;
838 double c4=1./5.-2.*c5;
839 double c3=(-64.+640.*c5)/45.;
840 double c2=(1-64.*c5)/9.;
841 double c1=(19.-55.*c5)/9.;
843 int Lt = loops[0].size();
844 std::vector<Real> out(Lt,0.);
845 for(
int t=0;t<Lt;t++)
846 out[t] += c1*loops[0][t] + c2*loops[1][t] + c3*loops[2][t] + c4*loops[3][t] + c5*loops[4][t];
853 for(
int t=0;t<Qt.size();t++) Q += Qt[t];
854 std::cout <<
GridLogMessage <<
"5Li Topological charge: " << Q << std::endl;
865 const int mu,
const int nu) {
866 rect = Gimpl::CovShiftForward(
867 U[mu], mu, Gimpl::CovShiftForward(
U[mu], mu,
U[nu])) *
868 adj(Gimpl::CovShiftForward(
869 U[nu], nu, Gimpl::CovShiftForward(
U[mu], mu,
U[mu])));
871 Gimpl::CovShiftForward(
872 U[mu], mu, Gimpl::CovShiftForward(
U[nu], nu,
U[nu])) *
873 adj(Gimpl::CovShiftForward(
874 U[nu], nu, Gimpl::CovShiftForward(
U[nu], nu,
U[mu])));
877 const std::vector<GaugeMat> &
U,
const int mu,
884 const std::vector<GaugeMat> &
U) {
887 for (
int mu = 1; mu <
Nd; mu++) {
888 for (
int nu = 0; nu < mu; nu++) {
890 Rect = Rect + siteRect;
899 std::vector<GaugeMat>
U(
Nd, Umu.Grid());
901 for (
int mu = 0; mu <
Nd; mu++) {
920 double vol = Umu.Grid()->gSites();
922 double faces = (1.0 *
Nd * (
Nd - 1));
924 return sumrect / vol / faces /
Nc;
931 U2 =
U * Gimpl::CshiftLink(
U, mu, 1);
938 const std::vector<GaugeMat> &
U,
int mu) {
947 for (
int nu = 0; nu <
Nd; nu++) {
952 tmp = Gimpl::CshiftLink(
adj(
U[nu]), nu, -1);
953 tmp =
adj(
U2[mu]) * tmp;
954 tmp = Gimpl::CshiftLink(tmp, mu, -2);
956 Staple2x1 = Gimpl::CovShiftForward(
U[nu], nu, tmp);
961 tmp =
adj(
U2[mu]) *
U[nu];
962 Staple2x1 += Gimpl::CovShiftBackward(
U[nu], nu, Gimpl::CshiftLink(tmp, mu, -2));
969 Stap += Gimpl::CshiftLink(Gimpl::CovShiftForward(
U[mu], mu, Staple2x1), mu, 1);
978 Stap += Gimpl::CshiftLink(Staple2x1, mu, 1) * Gimpl::CshiftLink(
U[mu], mu, -1);
986 tmp = Gimpl::CshiftLink(
adj(
U2[nu]), nu, -2);
987 tmp = Gimpl::CovShiftBackward(
U[mu], mu, tmp);
988 tmp =
U2[nu] * Gimpl::CshiftLink(tmp, nu, 2);
989 Stap += Gimpl::CshiftLink(tmp, mu, 1);
996 tmp = Gimpl::CovShiftBackward(
U[mu], mu,
U2[nu]);
997 tmp =
adj(
U2[nu]) * tmp;
998 tmp = Gimpl::CshiftLink(tmp, nu, -2);
999 Stap += Gimpl::CshiftLink(tmp, mu, 1);
1008 std::vector<GaugeMat>
U(
Nd, grid);
1009 for (
int d = 0; d <
Nd; d++) {
1015 for (
int nu = 0; nu <
Nd; nu++) {
1020 Stap += Gimpl::ShiftStaple(
1021 Gimpl::CovShiftForward(
1023 Gimpl::CovShiftForward(
1025 Gimpl::CovShiftBackward(
1027 Gimpl::CovShiftBackward(
1029 Gimpl::CovShiftIdentityBackward(
U[nu], nu))))),
1035 Stap += Gimpl::ShiftStaple(
1036 Gimpl::CovShiftForward(
1038 Gimpl::CovShiftBackward(
1040 Gimpl::CovShiftBackward(
1041 U[mu], mu, Gimpl::CovShiftBackward(
U[mu], mu,
U[nu])))),
1047 Stap += Gimpl::ShiftStaple(
1048 Gimpl::CovShiftBackward(
1050 Gimpl::CovShiftBackward(
1052 Gimpl::CovShiftBackward(
1053 U[mu], mu, Gimpl::CovShiftForward(
U[nu], nu,
U[mu])))),
1059 Stap += Gimpl::ShiftStaple(
1060 Gimpl::CovShiftForward(
1062 Gimpl::CovShiftBackward(
1064 Gimpl::CovShiftBackward(
1065 U[mu], mu, Gimpl::CovShiftBackward(
U[nu], nu,
U[mu])))),
1073 Stap += Gimpl::ShiftStaple(
1074 Gimpl::CovShiftForward(
1076 Gimpl::CovShiftForward(
1078 Gimpl::CovShiftBackward(
1080 Gimpl::CovShiftBackward(
1082 Gimpl::CovShiftIdentityBackward(
U[nu], nu))))),
1090 Stap += Gimpl::ShiftStaple(
1091 Gimpl::CovShiftBackward(
1093 Gimpl::CovShiftBackward(
1095 Gimpl::CovShiftBackward(
1096 U[mu], mu, Gimpl::CovShiftForward(
U[nu], nu,
U[nu])))),
1106 std::vector<GaugeMat> &
U2, std::vector<GaugeMat> &
U,
1115 static void RectStapleAll(std::vector<GaugeMat> &Stap,
const std::vector<GaugeMat> &
U){
1116 assert(Stap.size() ==
Nd); assert(
U.size() ==
Nd);
1117 std::vector<GaugeMat>
U2(
Nd,
U[0].
Grid());
1126 std::vector<Coordinate> shifts;
1127 for (
int mu = 0; mu <
Nd; mu++){
1128 for (
int nu = 0; nu <
Nd; nu++) {
1130 auto genShift = [&](
int mushift,
int nushift){
1131 Coordinate out(
Nd,0); out[mu]=mushift; out[nu]=nushift;
return out;
1135 shifts.push_back(genShift(0,0));
1136 shifts.push_back(genShift(0,+1));
1137 shifts.push_back(genShift(+1,+1));
1138 shifts.push_back(genShift(+2,0));
1139 shifts.push_back(genShift(+1,0));
1142 shifts.push_back(genShift(0,-1));
1143 shifts.push_back(genShift(0,-1));
1144 shifts.push_back(genShift(+1,-1));
1145 shifts.push_back(genShift(+2,-1));
1146 shifts.push_back(genShift(+1,0));
1149 shifts.push_back(genShift(-1,0));
1150 shifts.push_back(genShift(-1,-1));
1151 shifts.push_back(genShift(-1,-1));
1152 shifts.push_back(genShift(0,-1));
1153 shifts.push_back(genShift(+1,-1));
1156 shifts.push_back(genShift(-1,0));
1157 shifts.push_back(genShift(-1,0));
1158 shifts.push_back(genShift(-1,+1));
1159 shifts.push_back(genShift(0,+1));
1160 shifts.push_back(genShift(+1,0));
1163 shifts.push_back(genShift(0,0));
1164 shifts.push_back(genShift(0,+1));
1165 shifts.push_back(genShift(0,+2));
1166 shifts.push_back(genShift(+1,+1));
1167 shifts.push_back(genShift(+1,0));
1170 shifts.push_back(genShift(0,-1));
1171 shifts.push_back(genShift(0,-2));
1172 shifts.push_back(genShift(0,-2));
1173 shifts.push_back(genShift(+1,-2));
1174 shifts.push_back(genShift(+1,-1));
1189 RectStaplePaddedAllWorkspace wk;
1200 assert(U_padded.size() ==
Nd); assert(staple.size() ==
Nd);
1202 assert(Cell.
depth >= 2);
1203 GridBase *ggrid = U_padded[0].Grid();
1206 int mu_off_delta = nshift /
Nd;
1210 size_t vsize =
Nd*
sizeof(GaugeViewType);
1211 GaugeViewType* Ug_dirs_v_host = (GaugeViewType*)malloc(vsize);
1219 for(
int mu=0; mu<
Nd; mu++){
1226 decltype(coalescedRead(Ug_dirs_v[0][0])) stencil_ss;
1227 stencil_ss = Zero();
1229 for(int nu=0;nu<Nd;nu++){
1232 GeneralStencilEntry const* e = gStencil_v.GetEntry(s++,ss);
1233 auto U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1234 e = gStencil_v.GetEntry(s++,ss);
1235 auto U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1236 e = gStencil_v.GetEntry(s++,ss);
1237 auto U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1238 e = gStencil_v.GetEntry(s++,ss);
1239 auto U3 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1240 e = gStencil_v.GetEntry(s++,ss);
1241 auto U4 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
1243 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1246 e = gStencil_v.GetEntry(s++,ss);
1247 U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1248 e = gStencil_v.GetEntry(s++,ss);
1249 U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1250 e = gStencil_v.GetEntry(s++,ss);
1251 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1252 e = gStencil_v.GetEntry(s++,ss);
1253 U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1254 e = gStencil_v.GetEntry(s++,ss);
1255 U4 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
1257 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1260 e = gStencil_v.GetEntry(s++,ss);
1261 U0 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
1262 e = gStencil_v.GetEntry(s++,ss);
1263 U1 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1264 e = gStencil_v.GetEntry(s++,ss);
1265 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1266 e = gStencil_v.GetEntry(s++,ss);
1267 U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1268 e = gStencil_v.GetEntry(s++,ss);
1269 U4 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1271 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1274 e = gStencil_v.GetEntry(s++,ss);
1275 U0 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
1276 e = gStencil_v.GetEntry(s++,ss);
1277 U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1278 e = gStencil_v.GetEntry(s++,ss);
1279 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1280 e = gStencil_v.GetEntry(s++,ss);
1281 U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1282 e = gStencil_v.GetEntry(s++,ss);
1283 U4 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1285 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1288 e = gStencil_v.GetEntry(s++,ss);
1289 U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1290 e = gStencil_v.GetEntry(s++,ss);
1291 U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1292 e = gStencil_v.GetEntry(s++,ss);
1293 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1294 e = gStencil_v.GetEntry(s++,ss);
1295 U3 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1296 e = gStencil_v.GetEntry(s++,ss);
1297 U4 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1299 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1302 e = gStencil_v.GetEntry(s++,ss);
1303 U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1304 e = gStencil_v.GetEntry(s++,ss);
1305 U1 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
1306 e = gStencil_v.GetEntry(s++,ss);
1307 U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
1308 e = gStencil_v.GetEntry(s++,ss);
1309 U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1310 e = gStencil_v.GetEntry(s++,ss);
1311 U4 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
1313 stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
1320 offset += mu_off_delta;
1323 staple[mu] = Cell.
Extract(gStaple);
1326 for(
int i=0;i<
Nd;i++) Ug_dirs_v_host[i].ViewClose();
1327 free(Ug_dirs_v_host);
1332 std::cout <<
GridLogPerformance <<
"RectStaplePaddedAll timings:" << (t1-t0)/1000 <<
"ms" << std::endl;
1351 StapleAndRectStapleAllWorkspace wk;
1362 static void StapleAndRectStapleAll(std::vector<GaugeMat> &Stap, std::vector<GaugeMat> &RectStap,
const std::vector<GaugeMat> &
U, StapleAndRectStapleAllWorkspace &wk){
1370 const PaddedCell &Ghost = wk.getPaddedCell(unpadded_grid);
1373 std::vector<GaugeMat> U_pad(
Nd, Ghost.
grids.back());
1374 for(
int mu=0;mu<
Nd;mu++) U_pad[mu] = Ghost.
Exchange(
U[mu], cshift_impl);
1380 std::cout <<
GridLogPerformance <<
"StapleAndRectStapleAll timings: pad:" << (t1-t0)/1000 <<
"ms, staple:" << (t2-t1)/1000 <<
"ms, rect-staple:" << (t3-t2)/1000 <<
"ms" << std::endl;
1388 const int Rmu,
const int Rnu,
1389 const int mu,
const int nu) {
1392 for(
int i = 0; i < Rnu-1; i++){
1393 wl = Gimpl::CovShiftForward(
U[nu], nu, wl);
1396 for(
int i = 0; i < Rmu; i++){
1397 wl = Gimpl::CovShiftForward(
U[mu], mu, wl);
1400 for(
int i = 0; i < Rnu; i++){
1401 wl = Gimpl::CovShiftBackward(
U[nu], nu, wl);
1404 for(
int i = 0; i < Rmu; i++){
1405 wl = Gimpl::CovShiftBackward(
U[mu], mu, wl);
1412 const std::vector<GaugeMat> &
U,
1413 const int Rmu,
const int Rnu,
1414 const int mu,
const int nu) {
1423 const std::vector<GaugeMat> &
U,
1424 const int R1,
const int R2) {
1427 for (
int mu = 1; mu <
U[0].Grid()->_ndimension; mu++) {
1428 for (
int nu = 0; nu < mu; nu++) {
1441 const std::vector<GaugeMat> &
U,
1442 const int R1,
const int R2) {
1445 int ndim =
U[0].Grid()->_ndimension;
1448 for (
int nu = 0; nu < ndim - 1; nu++) {
1457 const std::vector<GaugeMat> &
U,
1458 const int R1,
const int R2) {
1462 for (
int mu = 1; mu <
U[0].Grid()->_ndimension - 1; mu++) {
1463 for (
int nu = 0; nu < mu; nu++) {
1475 const int R1,
const int R2) {
1476 std::vector<GaugeMat>
U(4, Umu.Grid());
1478 for (
int mu = 0; mu < Umu.Grid()->_ndimension; mu++) {
1494 const int R1,
const int R2) {
1495 std::vector<GaugeMat>
U(4, Umu.Grid());
1497 for (
int mu = 0; mu < Umu.Grid()->_ndimension; mu++) {
1513 const int R1,
const int R2) {
1514 std::vector<GaugeMat>
U(4, Umu.Grid());
1516 for (
int mu = 0; mu < Umu.Grid()->_ndimension; mu++) {
1532 const int R1,
const int R2) {
1533 int ndim = Umu.Grid()->_ndimension;
1535 Real vol = Umu.Grid()->gSites();
1536 Real faces = 1.0 * ndim * (ndim - 1);
1537 return sumWl / vol / faces /
Nc;
1543 const int R1,
const int R2) {
1544 int ndim = Umu.Grid()->_ndimension;
1546 Real vol = Umu.Grid()->gSites();
1547 Real faces = 1.0 * (ndim - 1);
1548 return sumWl / vol / faces /
Nc;
1554 const int R1,
const int R2) {
1555 int ndim = Umu.Grid()->_ndimension;
1557 Real vol = Umu.Grid()->gSites();
1558 Real faces = 1.0 * (ndim - 1) * (ndim - 2);
1559 return sumWl / vol / faces /
Nc;
void * acceleratorAllocDevice(size_t bytes)
void acceleratorCopyToDevice(void *from, void *to, size_t bytes)
#define accelerator_for(iterator, num, nsimd,...)
void acceleratorFreeDevice(void *ptr)
AcceleratorVector< int, MaxDims > Coordinate
accelerator_inline Grid_simd2< S, V > trace(const Grid_simd2< S, V > &arg)
auto PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< vobj > adj(const Lattice< vobj > &lhs)
vobj::scalar_object sum(const vobj *arg, Integer osites)
void sliceSum(const Lattice< vobj > &Data, std::vector< typename vobj::scalar_object > &result, int orthogdim)
#define autoView(l_v, l, mode)
GridLogger GridLogError(1, "Error", GridLogColours, "RED")
GridLogger GridLogPerformance(1, "Performance", GridLogColours, "GREEN")
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
static constexpr int Xdir
static constexpr int Tdir
static constexpr int Zdir
Lattice< vTComplex > LatticeComplex
static constexpr int Ydir
iSinglet< Complex > TComplex
auto peekLorentz(const vobj &rhs, int i) -> decltype(PeekIndex< LorentzIndex >(rhs, 0))
std::complex< RealD > ComplexD
std::complex< Real > Complex
accelerator_inline void coalescedWrite(vobj &__restrict__ vec, const vobj &__restrict__ extracted, int lane=0)
accelerator_inline std::enable_if<!isGridTensor< T >::value, T >::type TensorRemove(T arg)
WilsonLoops< PeriodicGimplR > SU2WilsonLoops
WilsonLoops< PeriodicGimplR > ColourWilsonLoops
WilsonLoops< PeriodicGimplR > SU3WilsonLoops
WilsonLoops< PeriodicGimplR > U1WilsonLoops
static INTERNAL_PRECISION U
static INTERNAL_PRECISION F
accelerator_inline void push_back(const value &val)
Lattice< SiteComplex > ComplexField
View_type View(int mode) const
static accelerator_inline constexpr int Nsimd(void)
SiteComplex::scalar_object scalar_object
Lattice< vobj > Extract(const Lattice< vobj > &in) const
std::vector< GridCartesian * > grids
Lattice< vobj > Exchange(const Lattice< vobj > &in, const CshiftImplBase< vobj > &cshift=CshiftImplDefault< vobj >()) const
int paddingDepth() const override
std::vector< Coordinate > getShifts() const override
StapleAndRectStapleAllWorkspace()
int paddingDepth() const override
std::vector< Coordinate > getShifts() const override
const GeneralLocalStencil & getStencil(const PaddedCell &pcell)
virtual int paddingDepth() const =0
virtual std::vector< Coordinate > getShifts() const =0
std::unique_ptr< GeneralLocalStencil > stencil
virtual ~WilsonLoopPaddedStencilWorkspace()
void generateStencil(GridBase *padded_grid)
const GeneralLocalStencil & getStencil(const size_t stencil_idx, GridBase *unpadded_grid)
void generatePcell(GridBase *unpadded_grid)
std::unique_ptr< PaddedCell > pcell
~WilsonLoopPaddedWorkspace()
std::vector< WilsonLoopPaddedStencilWorkspace * > stencil_wk
void addStencil(WilsonLoopPaddedStencilWorkspace *stencil)
const PaddedCell & getPaddedCell(GridBase *unpadded_grid)
static Real avgTimelikeWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap, std::vector< GaugeMat > &U2, std::vector< GaugeMat > &U, int mu)
static void StaplePaddedAll(std::vector< GaugeMat > &staple, const std::vector< GaugeMat > &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil)
static RealD avgRectangle(const GaugeLorentz &Umu)
static RealD sumRectangle(const GaugeLorentz &Umu)
static void traceDirRectangle(ComplexField &rect, const std::vector< GaugeMat > &U, const int mu, const int nu)
Gimpl::GaugeLinkField GaugeMat
static RealD sumPlaquette(const GaugeLorentz &Umu)
static std::vector< RealD > timesliceAvgSpatialPlaquette(const GaugeLorentz &Umu)
static void RectStaplePaddedAll(std::vector< GaugeMat > &staple, const std::vector< GaugeMat > &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil)
static void StapleLower(GaugeMat &staple, const GaugeLorentz &Umu, int mu, int nu)
static void RectStapleUnoptimised(GaugeMat &Stap, const GaugeLorentz &Umu, int mu)
static void siteSpatialWilsonLoop(LatticeComplex &Wl, const std::vector< GaugeMat > &U, const int R1, const int R2)
static void RectStaplePaddedAll(std::vector< GaugeMat > &staple, const std::vector< GaugeMat > &U_padded, const PaddedCell &Cell)
static void traceDirPlaquette(ComplexField &plaq, const std::vector< GaugeMat > &U, const int mu, const int nu)
static void Staple(GaugeMat &staple, const std::vector< GaugeMat > &Umu, int mu)
static void FieldStrength(GaugeMat &FS, const GaugeLorentz &Umu, int mu, int nu)
static void siteSpatialPlaquette(ComplexField &Plaq, const std::vector< GaugeMat > &U)
static void CloverleafMxN(GaugeMat &FS, const GaugeMat &Umu, const GaugeMat &Unu, int mu, int nu, int M, int N)
static Real sumWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
static void RectStapleDouble(GaugeMat &U2, const GaugeMat &U, int mu)
static RealD avgPlaquette(const GaugeLorentz &Umu)
static void RectStapleOptimised(GaugeMat &Stap, const std::vector< GaugeMat > &U2, const std::vector< GaugeMat > &U, int mu)
static ComplexD avgPolyakovLoop(const GaugeField &Umu, const int mu)
static void siteTimelikeWilsonLoop(LatticeComplex &Wl, const std::vector< GaugeMat > &U, const int R1, const int R2)
static std::vector< RealD > timesliceSumSpatialPlaquette(const GaugeLorentz &Umu)
static Real TopologicalCharge(const GaugeLorentz &U)
static void Staple(GaugeMat &staple, const GaugeLorentz &U, int mu)
static void FieldStrengthMxN(GaugeMat &FS, const GaugeLorentz &U, int mu, int nu, int M, int N)
static std::vector< std::vector< Real > > TimesliceTopologicalCharge5LiContributions(const GaugeLorentz &U)
static std::vector< Real > TimesliceTopologicalChargeMxN(const GaugeLorentz &U, int M, int N)
static RealD linkTrace(const GaugeLorentz &Umu)
static void StapleUpper(GaugeMat &staple, const GaugeLorentz &Umu, int mu, int nu)
static Real sumSpatialWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
static void siteWilsonLoop(LatticeComplex &Wl, const std::vector< GaugeMat > &U, const int R1, const int R2)
static void dirPlaquette(GaugeMat &plaq, const std::vector< GaugeMat > &U, const int mu, const int nu)
static void StaplePaddedAll(std::vector< GaugeMat > &staple, const std::vector< GaugeMat > &U_padded, const PaddedCell &Cell)
static void StapleAll(std::vector< GaugeMat > &staple, const std::vector< GaugeMat > &U)
static void StapleAndRectStapleAll(std::vector< GaugeMat > &Stap, std::vector< GaugeMat > &RectStap, const std::vector< GaugeMat > &U, StapleAndRectStapleAllWorkspace &wk)
static void wilsonLoop(GaugeMat &wl, const std::vector< GaugeMat > &U, const int Rmu, const int Rnu, const int mu, const int nu)
static Real TopologicalCharge5Li(const GaugeLorentz &U)
static Real sumTimelikeWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
static Real avgSpatialWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
static Real TopologicalChargeMxN(const GaugeLorentz &U, int M, int N)
INHERIT_GIMPL_TYPES(Gimpl)
static Real avgWilsonLoop(const GaugeLorentz &Umu, const int R1, const int R2)
Gimpl::GaugeField GaugeLorentz
static std::vector< Real > TimesliceTopologicalCharge5Li(const GaugeLorentz &U)
static void sitePlaquette(ComplexField &Plaq, const std::vector< GaugeMat > &U)
static void StapleAndRectStapleAll(std::vector< GaugeMat > &Stap, std::vector< GaugeMat > &RectStap, const std::vector< GaugeMat > &U)
static std::vector< Real > TopologicalCharge5LiContributions(const GaugeLorentz &U)
static void traceWilsonLoop(LatticeComplex &wl, const std::vector< GaugeMat > &U, const int Rmu, const int Rnu, const int mu, const int nu)
static void siteRectangle(ComplexField &Rect, const std::vector< GaugeMat > &U)
static void RectStaple(GaugeMat &Stap, const GaugeLorentz &Umu, int mu)
static void dirRectangle(GaugeMat &rect, const std::vector< GaugeMat > &U, const int mu, const int nu)
static void RectStapleAll(std::vector< GaugeMat > &Stap, const std::vector< GaugeMat > &U)
static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu, int nu)
static ComplexD avgPolyakovLoop(const GaugeField &Umu)