43
43
#include <io/params.h>
44
44
#include "measure_gauge_action.h"
45
45
46
- double measure_gauge_action (const su3 * * const gf ) {
46
+ double measure_plaquette (const su3 * * const gf ) {
47
47
static double res ;
48
48
#ifdef MPI
49
49
double ALIGN mres ;
@@ -55,61 +55,136 @@ double measure_gauge_action(const su3 ** const gf) {
55
55
int thread_num = omp_get_thread_num ();
56
56
#endif
57
57
58
- int ix , ix1 ,ix2 , mu1 , mu2 ;
58
+ int ix1 ,ix2 ;
59
59
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 ;
62
62
63
- if (g_update_gauge_energy ) {
64
- kc = 0.0 ; ks = 0.0 ;
63
+ kc = 0.0 ; ks = 0.0 ;
65
64
#ifdef OMP
66
65
#pragma omp for
67
66
#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 ;
86
84
}
87
85
}
88
- kc = (kc + ks )/3.0 ;
86
+ }
87
+ kc = (kc + ks )/3.0 ;
89
88
#ifdef OMP
90
- g_omp_acc_re [thread_num ] = kc ;
89
+ g_omp_acc_re [thread_num ] = kc ;
91
90
#else
92
- res = kc ;
91
+ res = kc ;
93
92
#endif
94
- }
95
93
96
94
#ifdef OMP
97
95
} /* OpenMP parallel closing brace */
98
96
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 ;
105
104
#endif
105
+ return res ;
106
+ }
107
+
108
+ double measure_gauge_action (const su3 * * const gf , const double lambda ) {
109
+ static double res ;
106
110
#ifdef MPI
107
- MPI_Allreduce (& res , & mres , 1 , MPI_DOUBLE , MPI_SUM , MPI_COMM_WORLD );
108
- res = mres ;
111
+ double ALIGN mres ;
109
112
#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
+ }
112
168
}
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 ;
113
188
return res ;
114
189
}
115
190
0 commit comments