26 ave_dSdpi[0]=0; ave_dSdpi[1]=0; ave_dSdpi[2]=0;
27 for(
unsigned int i=0;i<
kvol*
ndim;i++){
28 ave_dSdpi[0]+=dSdpi[i];
38 char funcname[] =
"Gauge_Update";
42#pragma omp parallel for simd collapse(2) aligned(pp:AVX)
43 for(
unsigned int i=0;i<
kvol;i++)
44 for(
unsigned short mu = 0; mu<
ndim; mu++){
51 const unsigned int ind = i+
kvol*mu;
52 double AAA = d*sqrt(pp[ind]*pp[ind]\
55 double CCC = cos(AAA);
56 double SSS = d*sin(AAA)/AAA;
73 const char funcname[] =
"Momentum_Update";
78 cblas_daxpy(
kmom, d, dSdpi, 1, pp, 1);
80#pragma omp parallel for simd
81 for(
int i=0;i<
kmom;i++)
88 double *dSdpi,
double *pp,
unsigned int *iu,
unsigned int *
id,
Complex gamval[20],
Complex_f gamval_f[20],
const unsigned short gamin[16],
89 Complex *sigval,
Complex_f *sigval_f,
unsigned short *sigin,
const Complex jqq,
const float beta,
const float akappa,
90 const float c_sw,
const int stepl,
const float dt,
double *ancg,
int *itot,
const float proby)
92 const char funcname[] =
"Leapfrog";
95 const double d =-dt*0.5;
99 printf(
"Evaluating force on rank %i\n",
rank);
101 Force(dSdpi, 1,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
105 bool end_traj=
false;
int step =1;
110 printf(
"Step: %d\n", step);
120 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
140#elif defined INT_OMF2
142 double *dSdpi,
double *pp,
unsigned int *iu,
unsigned int *
id,
Complex gamval[20],
Complex_f gamval_f[20],
const unsigned short gamin[16],
143 Complex *sigval,
Complex_f *sigval_f,
unsigned short *sigin,
const Complex jqq,
const float beta,
const float akappa,
144 const float c_sw,
const int stepl,
const float dt,
double *ancg,
int *itot,
const float proby)
146 const char funcname[] =
"OMF2";
147 const double lambda=0.5-(pow(2.0*sqrt(326.0)+36.0,1.0/3.0)/12.0)+1.0/(6*pow(2.0*sqrt(326.0) + 36.0,1.0/3.0));
152 const double dU = dt*0.5;
155 const double dp= -lambda*dt;
156 const double dp2= 2.0*dp;
157 const double dpm= -(1.0-2.0*lambda)*dt;
164 printf(
"Before evaluating force on rank %i, dSdpi[0] %e dSdpi[1] %e dSdpi[2] %e\n",
rank,ave_dSdpi[0],ave_dSdpi[1],ave_dSdpi[2]);
167 printf(
"Average momentum pp[0] %e pp[1] %e pp[2] %e\n", ave_pp[0],ave_pp[1],ave_pp[2]);
170 Force(dSdpi, 1,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
175 printf(
"Average force on rank %i, dSdpi[0] %e dSdpi[1] %e dSdpi[2] %e\n",
rank,ave_dSdpi[0],ave_dSdpi[1],ave_dSdpi[2]);
184 printf(
"Average initial momentum on rank %i, pp[0] %e pp[1] %e pp[2] %e\n",
rank,ave_pp[0],ave_pp[1],ave_pp[2]);
190 bool end_traj=
false;
int step =1;
195 printf(
"Step: %d\n", step);
201 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
206 printf(
"First force update on rank %i, dSdpi[0] %e dSdpi[1] %e dSdpi[2] %e\n",
rank,ave_dSdpi[0],ave_dSdpi[1],ave_dSdpi[2]);
215 printf(
"Average middle momentum on rank %i, pp[0] %e pp[1] %e pp[2] %e\n",
rank,ave_pp[0],ave_pp[1],ave_pp[2]);
223 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
228 printf(
"Second force update on rank %i, dSdpi[0] %e dSdpi[1] %e dSdpi[2] %e\n",
rank,ave_dSdpi[0],ave_dSdpi[1],ave_dSdpi[2]);
240 printf(
"Average final momentum on rank %i, pp[0] %e pp[1] %e pp[2] %e\n",
rank,ave_pp[0],ave_pp[1],ave_pp[2]);
257 printf(
"Average intermediate momentum on rank %i, pp[0] %e pp[1] %e pp[2] %e\n",
rank,ave_pp[0],ave_pp[1],ave_pp[2]);
265#elif defined INT_OMF4
266#warning "OMF4 can be less efficient than OMF2 in certain cases. Use with caution. See http://dx.doi.org/10.1103/PhysRevE.73.036706"
268 double *dSdpi,
double *pp,
unsigned int *iu,
unsigned int *
id,
Complex gamval[20],
Complex_f gamval_f[20],
const unsigned short gamin[16],
269 Complex *sigval,
Complex_f *sigval_f,
unsigned short *sigin,
const Complex jqq,
const float beta,
const float akappa,
270 const float c_sw,
const int stepl,
const float dt,
double *ancg,
int *itot,
const float proby)
272 const char funcname[] =
"OMF4";
274 const double theta = 0.08398315262876693;
275 const double rho = 0.2539785108410595;
276 const double lambda = 0.6822365335719091;
277 const double vartheta = -0.03230286765269967;
281 const double dpO= -theta*dt;
282 const double dpO2= 2*dpO;
284 const double dpM= -lambda*dt;
286 const double dpI= -(0.5-theta-lambda)*dt;
290 const double duO = dt*rho;
292 const double duM = dt*vartheta;
294 const double duI = dt*(1-2*(rho+vartheta));
299 printf(
"Evaluating force on rank %i\n",
rank);
301 Force(dSdpi, 1,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
306 bool end_traj=
false;
int step =1;
311 printf(
"Step: %d\n", step);
317 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
325 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
333 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
341 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
349 Force(dSdpi, 0,
rescgg,X0,X1,Phi,ut,ut_f,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,jqq,akappa,beta,c_sw,ancg);
void Force_debug(double ave_dSdpi[3], double *dSdpi)
Gets average for each generator of the Lie algebra.
double cureduce_sum_d(double *input, const unsigned int n, const unsigned short stream)
Sum all terms in an array of doubles.
__device__ __forceinline__ T conj(const T &z)
Complex Conjugation.
int Reunitarise(Complex *ut[2])
Reunitarises u11t and u12t as in conj(u11t[i])*u11t[i]+conj(u12t[i])*u12t[i]=1.
void cuGauge_Update(const double d, double *pp, Complex *ut[2], dim3 dimGrid, dim3 dimBlock)
CUDA wrapper for the gauge update during the integration step of the HMC.
int OMF2(Complex *ut[2], Complex_f *ut_f[2], Complex *X0, Complex *X1, Complex *Phi, double *dk[2], float *dk_f[2], double *dSdpi, double *pp, unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, const Complex jqq, const float beta, const float akappa, const float c_sw, const int stepl, const float dt, double *ancg, int *itot, const float proby)
OMF second order five step integrator.
int Leapfrog(Complex *ut[2], Complex_f *ut_f[2], Complex *X0, Complex *X1, Complex *Phi, double *dk[2], float *dk_f[2], double *dSdpi, double *pp, unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, const Complex jqq, const float beta, const float akappa, const float c_sw, const int stepl, const float dt, double *ancg, int *itot, const float proby)
Leapfrog integrator. Each trajectory step takes the form of p->p+dt/2,u->u+dt,p->p+dt/2 In practice t...
int OMF4(Complex *ut[2], Complex_f *ut_f[2], Complex *X0, Complex *X1, Complex *Phi, double *dk[2], float *dk_f[2], double *dSdpi, double *pp, unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, const Complex jqq, const float beta, const float akappa, const float c_sw, const int stepl, const float dt, double *ancg, int *itot, const float proby)
OMF fourth order eleven step integrator.
int Gauge_Update(const double d, double *pp, Complex *ut[2], Complex_f *ut_f[2])
Gauge update for the integration step of the HMC.
int Momentum_Update(const double d, const double *dSdpi, double *pp)
Wrapper for the momentum update during the integration step of the HMC.
int Force(double *dSdpi, const bool iflag, double res1, Complex *X0, Complex *X1, Complex *Phi, Complex *ut[2], Complex_f *ut_f[2], unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, double *dk[2], float *dk_f[2], const Complex_f jqq, const float akappa, const float beta, const float c_sw, double *ancg)
Calculates the force at each intermediate time.
int Trial_Exchange(Complex *ut[2], Complex_f *ut_f[2])
Exchanges the trial fields.
Matrix multiplication and related declarations.
#define rescgg
Conjugate gradient residue for update.
#define kmom
sublattice momentum sites
#define kvol
Sublattice volume.
#define Complex
Double precision complex number.
#define cudaDeviceSynchronise()
Get rid of that bastardised yankee English.
cublasHandle_t cublas_handle
Handle for cuBLAS.
#define Complex_f
Single precision complex number.
dim3 dimGrid
Default grid size. First component is normally nt. Second and third depend whatever is needed to get ...
#define kvolHalo
Subvolume + halo size.
dim3 dimBlock
Default block size. Usually 128.
Function declarations for most of the routines.
#define I
Define I in double precision using C standard notation.