Skip to content

Commit 5ccf111

Browse files
committed
Wilson EM Plaquette action following 1205.6410
1 parent 0889062 commit 5ccf111

16 files changed

+280
-63
lines changed

check_locallity.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ int main(int argc,char *argv[]) {
238238
eigenvalues(&no_eigenvalues, 1000, eigenvalue_precision, 0, compute_evs, nstore, even_odd_flag);
239239
}
240240
/*compute the energy of the gauge field*/
241-
plaquette_energy = measure_gauge_action(g_gauge_field);
241+
plaquette_energy = measure_plaquette(g_gauge_field);
242242

243243
if(g_proc_id == 0) {
244244
printf("The plaquette value is %e\n", plaquette_energy/(6.*VOLUME*g_nproc)); fflush(stdout);
@@ -251,7 +251,7 @@ int main(int argc,char *argv[]) {
251251
g_update_gauge_copy = 1;
252252
g_update_gauge_energy = 1;
253253
g_update_rectangle_energy = 1;
254-
plaquette_energy = measure_gauge_action(g_gauge_field);
254+
plaquette_energy = measure_plaquette(g_gauge_field);
255255

256256
if (g_proc_id == 0) {
257257
printf("# The plaquette value after stouting is %e\n", plaquette_energy / (6.*VOLUME*g_nproc));

get_staples.c

+74
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,77 @@ void get_staples(su3* const staple, const int x, const int mu, const su3 ** in_g
6969
}
7070

7171

72+
void get_spacelike_staples(su3* const staple, const int x, const int mu, const su3 ** in_gauge_field) {
73+
74+
int iy;
75+
su3 ALIGN st;
76+
const su3 *w1,*w2,*w3;
77+
78+
#ifdef _KOJAK_INST
79+
#pragma pomp inst begin(staples)
80+
#endif
81+
82+
_su3_zero(*staple);
83+
for(int k=1;k<4;k++) {
84+
if(k!=mu){
85+
w1=&in_gauge_field[x][k];
86+
w2=&in_gauge_field[g_iup[x][k]][mu];
87+
w3=&in_gauge_field[g_iup[x][mu]][k];
88+
89+
/* st = w2 * w3^d */
90+
_su3_times_su3d(st,*w2,*w3);
91+
/* v = v + w1 * st */
92+
_su3_times_su3_acc(*staple,*w1,st);
93+
94+
iy=g_idn[x][k];
95+
w1=&in_gauge_field[iy][k];
96+
w2=&in_gauge_field[iy][mu];
97+
w3=&in_gauge_field[g_iup[iy][mu]][k];
98+
/* st = w2 * w3 */
99+
_su3_times_su3(st,*w2,*w3);
100+
/* v = v + w1^d * st */
101+
_su3d_times_su3_acc(*staple,*w1,st);
102+
}
103+
}
104+
#ifdef _KOJAK_INST
105+
#pragma pomp inst end(staples)
106+
#endif
107+
}
108+
109+
void get_timelike_staples(su3* const staple, const int x, const int mu, const su3 ** in_gauge_field) {
110+
111+
int iy;
112+
su3 ALIGN st;
113+
const su3 *w1,*w2,*w3;
114+
115+
#ifdef _KOJAK_INST
116+
#pragma pomp inst begin(staples)
117+
#endif
118+
119+
_su3_zero(*staple);
120+
int k = 0;
121+
if(k!=mu){
122+
w1=&in_gauge_field[x][k];
123+
w2=&in_gauge_field[g_iup[x][k]][mu];
124+
w3=&in_gauge_field[g_iup[x][mu]][k];
125+
126+
/* st = w2 * w3^d */
127+
_su3_times_su3d(st,*w2,*w3);
128+
/* v = v + w1 * st */
129+
_su3_times_su3_acc(*staple,*w1,st);
130+
131+
iy=g_idn[x][k];
132+
w1=&in_gauge_field[iy][k];
133+
w2=&in_gauge_field[iy][mu];
134+
w3=&in_gauge_field[g_iup[iy][mu]][k];
135+
/* st = w2 * w3 */
136+
_su3_times_su3(st,*w2,*w3);
137+
/* v = v + w1^d * st */
138+
_su3d_times_su3_acc(*staple,*w1,st);
139+
}
140+
#ifdef _KOJAK_INST
141+
#pragma pomp inst end(staples)
142+
#endif
143+
}
144+
145+

get_staples.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
#include"su3.h"
2424

2525
void get_staples(su3* const staple, const int x, const int mu, const su3 ** in_gauge_field);
26-
26+
void get_timelike_staples(su3* const staple, const int x, const int mu, const su3 ** in_gauge_field);
27+
void get_spacelike_staples(su3* const staple, const int x, const int mu, const su3 ** in_gauge_field);
2728
#endif

hmc_tm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ int main(int argc,char *argv[]) {
391391
}
392392
}
393393

394-
plaquette_energy = measure_gauge_action( (const su3**) g_gauge_field);
394+
plaquette_energy = measure_plaquette( (const su3**) g_gauge_field);
395395
if(g_rgi_C1 > 0. || g_rgi_C1 < 0.) {
396396
rectangle_energy = measure_rectangles( (const su3**) g_gauge_field);
397397
if(g_proc_id == 0){

invert.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ int main(int argc, char *argv[])
343343
#endif
344344

345345
/*compute the energy of the gauge field*/
346-
plaquette_energy = measure_gauge_action( (const su3**) g_gauge_field);
346+
plaquette_energy = measure_plaquette( (const su3**) g_gauge_field);
347347

348348
if (g_cart_id == 0) {
349349
printf("# The computed plaquette value is %e.\n", plaquette_energy / (6.*VOLUME*g_nproc));
@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
358358
g_update_gauge_copy = 1;
359359
g_update_gauge_energy = 1;
360360
g_update_rectangle_energy = 1;
361-
plaquette_energy = measure_gauge_action( (const su3**) g_gauge_field);
361+
plaquette_energy = measure_plaquette( (const su3**) g_gauge_field);
362362

363363
if (g_cart_id == 0) {
364364
printf("# The plaquette value after stouting is %e\n", plaquette_energy / (6.*VOLUME*g_nproc));

invert_doublet_eo.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ int invert_doublet_eo(spinor * const Even_new_s, spinor * const Odd_new_s,
8888
}
8989

9090
/* do trafo */
91-
plaquette1 = measure_gauge_action(g_gauge_field);
91+
plaquette1 = measure_plaquette(g_gauge_field);
9292
apply_gtrafo(g_gauge_field, g_trafo); // transformation of the gauge field
93-
plaquette2 = measure_gauge_action(g_gauge_field);
93+
plaquette2 = measure_plaquette(g_gauge_field);
9494
if (g_proc_id == 0) printf("\tPlaquette before gauge fixing: %.16e\n", plaquette1/6./VOLUME);
9595
if (g_proc_id == 0) printf("\tPlaquette after gauge fixing: %.16e\n", plaquette2/6./VOLUME);
9696

@@ -207,10 +207,10 @@ int invert_doublet_eo(spinor * const Even_new_s, spinor * const Odd_new_s,
207207
/* undo trafo */
208208
/* apply_inv_gtrafo(g_gauge_field, g_trafo);*/
209209
/* copy back the saved original field located in g_tempgauge_field -> update necessary*/
210-
plaquette1 = measure_gauge_action(g_gauge_field);
210+
plaquette1 = measure_plaquette(g_gauge_field);
211211
copy_gauge_field(g_gauge_field, g_tempgauge_field);
212212
g_update_gauge_copy = 1;
213-
plaquette2 = measure_gauge_action(g_gauge_field);
213+
plaquette2 = measure_plaquette(g_gauge_field);
214214
if (g_proc_id == 0) printf("\tPlaquette before inverse gauge fixing: %.16e\n", plaquette1/6./VOLUME);
215215
if (g_proc_id == 0) printf("\tPlaquette after inverse gauge fixing: %.16e\n", plaquette2/6./VOLUME);
216216

invert_eo.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ int invert_eo(spinor * const Even_new, spinor * const Odd_new,
9797
if(g_proc_id == 0) printf("Error while gauge fixing to temporal gauge. Aborting...\n");
9898
exit(200);
9999
}
100-
plaquette = measure_gauge_action(g_gauge_field);
100+
plaquette = measure_plaquette(g_gauge_field);
101101
if(g_proc_id == 0) printf("Plaquette before gauge fixing: %.16e\n", plaquette/6./VOLUME);
102102
/* do trafo */
103103
apply_gtrafo(g_gauge_field, g_trafo);
104-
plaquette = measure_gauge_action(g_gauge_field);
104+
plaquette = measure_plaquette(g_gauge_field);
105105
if(g_proc_id == 0) printf("Plaquette after gauge fixing: %.16e\n", plaquette/6./VOLUME);
106106

107107
/* do trafo to odd part of source */
@@ -244,7 +244,7 @@ int invert_eo(spinor * const Even_new, spinor * const Odd_new,
244244
/* return from temporal gauge again */
245245
#ifdef TEMPORALGAUGE
246246
if(usegpu_flag){
247-
plaquette = measure_gauge_action(g_gauge_field);
247+
plaquette = measure_plaquette(g_gauge_field);
248248
if(g_proc_id == 0) printf("Plaquette before inverse gauge fixing: %.16e\n", plaquette/6./VOLUME);
249249

250250
/* undo trafo */
@@ -255,7 +255,7 @@ int invert_eo(spinor * const Even_new, spinor * const Odd_new,
255255
g_update_gauge_copy = 1;
256256

257257

258-
plaquette = measure_gauge_action(g_gauge_field);
258+
plaquette = measure_plaquette(g_gauge_field);
259259
if(g_proc_id == 0) printf("Plaquette after inverse gauge fixing: %.16e\n", plaquette/6./VOLUME);
260260

261261
/* undo trafo to source (Even, Odd) */

measure_gauge_action.c

+113-38
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include <io/params.h>
4444
#include "measure_gauge_action.h"
4545

46-
double measure_gauge_action(const su3 ** const gf) {
46+
double measure_plaquette(const su3 ** const gf) {
4747
static double res;
4848
#ifdef MPI
4949
double ALIGN mres;
@@ -55,61 +55,136 @@ double measure_gauge_action(const su3 ** const gf) {
5555
int thread_num = omp_get_thread_num();
5656
#endif
5757

58-
int ix,ix1,ix2,mu1,mu2;
58+
int ix1,ix2;
5959
su3 ALIGN pr1,pr2;
60-
const su3 *v,*w;
61-
double ALIGN ac,ks,kc,tr,ts,tt;
60+
const su3 * restrict v,* restrict w;
61+
double ALIGN ac, ks, kc, tr, ts, tt;
6262

63-
if(g_update_gauge_energy) {
64-
kc=0.0; ks=0.0;
63+
kc=0.0; ks=0.0;
6564
#ifdef OMP
6665
#pragma omp for
6766
#endif
68-
for (ix=0;ix<VOLUME;ix++){
69-
for (mu1=0;mu1<3;mu1++){
70-
ix1=g_iup[ix][mu1];
71-
for (mu2=mu1+1;mu2<4;mu2++){
72-
ix2=g_iup[ix][mu2];
73-
v=&gf[ix][mu1];
74-
w=&gf[ix1][mu2];
75-
_su3_times_su3(pr1,*v,*w);
76-
v=&gf[ix][mu2];
77-
w=&gf[ix2][mu1];
78-
_su3_times_su3(pr2,*v,*w);
79-
_trace_su3_times_su3d(ac,pr1,pr2);
80-
tr=ac+kc;
81-
ts=tr+ks;
82-
tt=ts-ks;
83-
ks=ts;
84-
kc=tr-tt;
85-
}
67+
for (int ix = 0; ix < VOLUME; ix++){
68+
for (int mu1 = 0; mu1 < 3; mu1++){
69+
ix1 = g_iup[ix][mu1];
70+
for (int mu2 = mu1+1; mu2 < 4; mu2++){
71+
ix2 = g_iup[ix][mu2];
72+
v=&gf[ix][mu1];
73+
w=&gf[ix1][mu2];
74+
_su3_times_su3(pr1, *v, *w);
75+
v=&gf[ix][mu2];
76+
w=&gf[ix2][mu1];
77+
_su3_times_su3(pr2, *v, *w);
78+
_trace_su3_times_su3d(ac, pr1, pr2);
79+
tr=ac+kc;
80+
ts=tr+ks;
81+
tt=ts-ks;
82+
ks=ts;
83+
kc=tr-tt;
8684
}
8785
}
88-
kc=(kc+ks)/3.0;
86+
}
87+
kc=(kc+ks)/3.0;
8988
#ifdef OMP
90-
g_omp_acc_re[thread_num] = kc;
89+
g_omp_acc_re[thread_num] = kc;
9190
#else
92-
res = kc;
91+
res = kc;
9392
#endif
94-
}
9593

9694
#ifdef OMP
9795
} /* OpenMP parallel closing brace */
9896

99-
if(g_update_gauge_energy) {
100-
res = 0.0;
101-
for(int i=0; i < omp_num_threads; ++i)
102-
res += g_omp_acc_re[i];
103-
#else
104-
if(g_update_gauge_energy) {
97+
res = 0.0;
98+
for(int i=0; i < omp_num_threads; ++i)
99+
res += g_omp_acc_re[i];
100+
#endif
101+
#ifdef MPI
102+
MPI_Allreduce(&res, &mres, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
103+
res = mres;
105104
#endif
105+
return res;
106+
}
107+
108+
double measure_gauge_action(const su3 ** const gf, const double lambda) {
109+
static double res;
106110
#ifdef MPI
107-
MPI_Allreduce(&res, &mres, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
108-
res = mres;
111+
double ALIGN mres;
109112
#endif
110-
GaugeInfo.plaquetteEnergy = res;
111-
g_update_gauge_energy = 0;
113+
114+
#ifdef OMP
115+
#pragma omp parallel
116+
{
117+
int thread_num = omp_get_thread_num();
118+
#endif
119+
120+
int ix1,ix2;
121+
su3 ALIGN pr1,pr2;
122+
const su3 * restrict v,* restrict w;
123+
double ALIGN ac, ks, kc, tr, ts, tt;
124+
125+
kc=0.0; ks=0.0;
126+
#ifdef OMP
127+
#pragma omp for
128+
#endif
129+
for (int ix = 0; ix < VOLUME; ix++){
130+
ix1 = g_iup[ix][0];
131+
// electric part
132+
for (int mu2 = 1; mu2 < 4; mu2++){
133+
ix2 = g_iup[ix][mu2];
134+
v=&gf[ix][0];
135+
w=&gf[ix1][mu2];
136+
_su3_times_su3(pr1, *v, *w);
137+
v=&gf[ix][mu2];
138+
w=&gf[ix2][0];
139+
_su3_times_su3(pr2, *v, *w);
140+
_trace_su3_times_su3d(ac, pr1, pr2);
141+
ac *= (1+lambda);
142+
tr=ac+kc;
143+
ts=tr+ks;
144+
tt=ts-ks;
145+
ks=ts;
146+
kc=tr-tt;
147+
}
148+
// magnetic part
149+
for (int mu1 = 1; mu1 < 3; mu1++){
150+
ix1 = g_iup[ix][mu1];
151+
for (int mu2 = mu1+1; mu2 < 4; mu2++){
152+
ix2 = g_iup[ix][mu2];
153+
v=&gf[ix][mu1];
154+
w=&gf[ix1][mu2];
155+
_su3_times_su3(pr1, *v, *w);
156+
v=&gf[ix][mu2];
157+
w=&gf[ix2][mu1];
158+
_su3_times_su3(pr2, *v, *w);
159+
_trace_su3_times_su3d(ac, pr1, pr2);
160+
ac *= (1-lambda);
161+
tr=ac+kc;
162+
ts=tr+ks;
163+
tt=ts-ks;
164+
ks=ts;
165+
kc=tr-tt;
166+
}
167+
}
112168
}
169+
kc=(kc+ks)/3.0;
170+
#ifdef OMP
171+
g_omp_acc_re[thread_num] = kc;
172+
#else
173+
res = kc;
174+
#endif
175+
176+
#ifdef OMP
177+
} /* OpenMP parallel closing brace */
178+
179+
res = 0.0;
180+
for(int i=0; i < omp_num_threads; ++i)
181+
res += g_omp_acc_re[i];
182+
#endif
183+
#ifdef MPI
184+
MPI_Allreduce(&res, &mres, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
185+
res = mres;
186+
#endif
187+
GaugeInfo.plaquetteEnergy = res;
113188
return res;
114189
}
115190

measure_gauge_action.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "su3.h"
2424

25-
double measure_gauge_action(const su3 ** const gf);
25+
double measure_plaquette(const su3 ** const gf);
26+
double measure_gauge_action(const su3 ** const gf, const double lambda);
2627

2728
#endif

0 commit comments

Comments
 (0)