10int Init(
const int istart,
const int ibound,
const int iread,
const float beta,
const float fmu,
const float akappa,\
12 Complex_f gamval_f[20],
unsigned short gamin[16],
double *dk[2],
float *dk_f[2],\
13 unsigned int *iu,
unsigned int *
id){
14 const char funcname[] =
"Init";
28 printf(
"Checked addresses\n");
30 double chem1=exp(-fmu);
double chem2 = 1/chem1;
32#pragma omp parallel for simd
33 for(
unsigned int i = 0; i<
kvol; i++){
34 dk[0][i]=akappa*chem1; dk[1][i]=akappa*chem2;
40 printf(
"Implementing antiperiodic boundary conditions on rank %i\n",
rank);
42#pragma omp parallel for simd
60#pragma omp parallel for simd
61 for(
unsigned int i=0;i<
kvol+
halo;i++){
62 dk_f[1][i]=(float)dk[1][i];
63 dk_f[0][i]=(float)dk[0][i];
67 unsigned short __attribute__((aligned(
AVX))) gamin_t[4][4] = {{3,2,1,0},{3,2,1,0},{2,3,0,1},{2,3,0,1}};
72 cudaMemcpy(gamin,gamin_t,4*4*
sizeof(
short),cudaMemcpyHostToDevice);
74 memcpy(gamin,gamin_t,4*4*
sizeof(
short));
77 Complex __attribute__((aligned(
AVX))) gamval_t[5][4] = {{-
I,-
I,
I,
I},{-1,1,1,-1},{-
I,
I,
I,-
I},{1,1,1,1},{1,1,-1,-1}};
82 cblas_zdscal(5*4, akappa, gamval_t, 1);
84#pragma omp parallel for simd collapse(2) aligned(gamval,gamval_f:AVX)
85 for(
unsigned short i=0;i<5;i++)
86 for(
unsigned short j=0;j<4;j++)
87 gamval_t[i][j]*=akappa;
92 cudaMemcpy(gamval,gamval_t,5*4*
sizeof(
Complex),cudaMemcpyHostToDevice);
95 memcpy(gamval,gamval_t,5*4*
sizeof(
Complex));
96 for(
unsigned short i=0;i<5*4;i++)
101 if(!
rank) printf(
"Calling Par_sread() for configuration: %i\n", iread);
102 Par_sread(iread, beta, fmu, akappa, ajq,c_sw,u[0],u[1],ut[0],ut[1]);
110#pragma omp parallel for simd
112 for(
unsigned int i=0; i<
kvol;i++)
113 for(
unsigned short mu=0;mu<
ndim;mu++){
120 for(
unsigned int i=0; i<
kvol;i++)
121 for(
unsigned short mu=0;mu<
ndim;mu++){
127 for(
unsigned int i=0; i<
kvol;i++)
128 for(
unsigned short mu=0;mu<
ndim;mu++){
135 fprintf(stderr,
"Warning %i in %s: Gauge fields are not initialised.\n",
NOINIT, funcname);
139 cudaGetDevice(&device);
148 for(
unsigned short mu=0;mu<
ndim;mu++){
157 for(
unsigned short mu=0;mu<
ndim;mu++){
164 printf(
"Initialisation Complete\n");
170 unsigned short *sigin,
double *dk[2],
float *dk_f[2],
Complex_f jqq,
float akappa,
float beta,
float c_sw,
double *ancgh,
172 const char funcname[] =
"Hamilton";
177 cudaGetDevice(&device);
181#elif defined USE_BLAS
182 double hp = cblas_dnrm2(
kmom, pp, 1);
186 for(
unsigned int i = 0; i<
kmom; i++)
190 double avplaqs, avplaqt;
195 alignas(8)
double hf = 0;
int itercg = 0;
199 cudaMallocManaged((
void **)&smallPhi,
kferm2*
sizeof(
Complex),cudaMemAttachGlobal);
201 cudaMallocAsync((
void **)&smallPhi,
kferm2*
sizeof(
Complex),NULL);
210 for(
unsigned short na=0;na<
nf;na++){
213 for(
unsigned short j=0;j<
nc*
ndirac;j++)
219 for(
unsigned short j=0;j<
nc*
ndirac;j++)
223 if(
Congradq(na,res2,X1,smallPhi,ud,ut,clover,iu,
id,gamval,gamval_f,gamin,sigval,sigval_f,sigin,dk,dk_f,\
224 jqq,akappa,c_sw,&itercg))
225 fprintf(stderr,
"Trajectory %d\n", traj);
230 for(
unsigned short j=0;j<
nc*
ndirac;j++)
236 for(
unsigned short j=0;j<
nc*
ndirac;j++)
243 for(
unsigned short j=0;j<
nc*
ndirac;j++){
249 cublasZdotc(
cublas_handle,
kferm2,(cuDoubleComplex *)smallPhi,1,(cuDoubleComplex *) X1,1,(cuDoubleComplex *) &dot);
252#elif defined USE_BLAS
254 for(
unsigned short j=0;j<
nc*
ndirac;j++){
263#pragma omp parallel for simd collapse(2) aligned(smallPhi,X1:AVX)
264 for(
unsigned short j=0;j<
nc*
ndirac;j++)
265 for(
unsigned int i=0;i<
kvol;i++)
275 cudaFreeAsync(smallPhi,NULL);
284 *s=hg+hf; *h=(*s)+hp;
287 printf(
"hg=%.5e; hf=%.5e; hp=%.5e; h=%.5e\n", hg, hf, hp, *h);
293 const char funcname[] =
"C_gather";
296#pragma omp parallel for simd aligned (x,y,table:AVX)
297 for(
unsigned int i=0; i<n; i++)
303 const char funcname[] =
"Z_gather";
306#pragma omp parallel for simd aligned (x,y,table:AVX)
307 for(
unsigned int i=0; i<n; i++)
313 const char funcname[] =
"Fill_Small_Phi";
318#pragma omp parallel for simd aligned(smallPhi,Phi:AVX) collapse(3)
319 for(
unsigned int i = 0; i<
kvol;i++)
320 for(
unsigned short idirac = 0; idirac<
ndirac; idirac++)
321 for(
unsigned short ic= 0; ic<
nc; ic++)
332#pragma omp parallel for simd collapse(2) aligned(X0,R1:AVX)
333 for(
unsigned int i=0; i<
kvol; i++)
334 for(
unsigned short idirac=0;idirac<
ndirac;idirac++){
343 const char funcname[] =
"Reunitarise";
347#pragma omp parallel for simd
348 for(
unsigned short mu=0;mu<
ndim;mu++)
349 for(
unsigned int i=0; i<
kvol; i++){
Routines needed for Clover improved wilson fermions.
#define NOINIT
Not initialising the lattice.
int Average_Plaquette(double *hg, double *avplaqs, double *avplaqt, Complex_f *ut[2], unsigned int *iu, float beta)
Calculates the gauge action using new (how new?) lookup table Follows a routine called qedplaq in som...
void Clover_free(Complex_f *clover[nc])
Free's memory used for clover terms and leaves.
void Clover(Complex_f *clover[2], Complex_f *ut[2], unsigned int *iu, unsigned int *id)
Calculates the clovers in all directions at all sites.
int Z_gather(Complex *x, Complex *y, int n, unsigned int *table, unsigned int mu)
Extracts all the double precision gauge links in the direction only.
void cuReunitarise(Complex *ut[2], dim3 dimGrid, dim3 dimBlock)
Reunitarises u11t and u12t as in conj(u11t[i])*u11t[i]+conj(u12t[i])*u12t[i]=1.
void cuUpDownPart(const unsigned int na, Complex *X0, Complex *R1, dim3 dimBlock, dim3 dimGrid)
Up/Down partitioning of the pseudofermion field.
int Init(const int istart, const int ibound, const int iread, const float beta, const float fmu, const float akappa, const Complex_f ajq, const float c_sw, Complex *u[2], Complex *ut[2], Complex_f *ut_f[2], Complex gamval[20], Complex_f gamval_f[20], unsigned short gamin[16], double *dk[2], float *dk_f[2], unsigned int *iu, unsigned int *id)
Initialises the system.
__device__ __forceinline__ T conj(const T &z)
Complex Conjugation.
int UpDownPart(const unsigned int na, Complex *X0, Complex *R1)
Up/Down partitioning of the pseudofermion field.
void cuReal_convert(float *a, double *b, const unsigned int len, const bool dtof, dim3 dimBlock, dim3 dimGrid)
takes an array of real-valued float and double precision numbers and converts the precision
int Reunitarise(Complex *ut[2])
Reunitarises u11t and u12t as in conj(u11t[i])*u11t[i]+conj(u12t[i])*u12t[i]=1.
void cuComplex_convert(Complex_f *a, Complex *b, const unsigned int len, const bool dtof, dim3 dimBlock, dim3 dimGrid)
takes an array of complex float and double precision numbers and converts the precision
int Fill_Small_Phi(int na, Complex *smallPhi, Complex *Phi)
Copies necessary (2*4*kvol) elements of Phi into a vector variable.
void cuFill_Small_Phi(const unsigned int na, Complex *smallPhi, Complex *Phi, dim3 dimBlock, dim3 dimGrid)
Copies necessary (2*4*kvol) elements of Phi into a vector variable.
int C_gather(Complex_f *x, Complex_f *y, int n, unsigned int *table, unsigned int mu)
Extracts all the single precision gauge links in the direction only.
int Check_addr(unsigned int *table, int lns, int lnt, int imin, int imax)
Checks that the addresses are within bounds before an update.
int Addrc(unsigned int *iu, unsigned int *id)
Loads the addresses required during the update.
int Congradq(int na, double res, Complex *X1, Complex *r, Complex *ud[2], Complex_f *ut[2], Complex_f *clover_f[nc], 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], Complex_f jqq, float akappa, float c_sw, int *itercg)
Matrix Inversion via Conjugate Gradient (up/down flavour partitioning). Solves Implements up/down pa...
int Par_sread(const int iread, const float beta, const float fmu, const float akappa, const Complex_f ajq, const float c_sw, Complex *u11, Complex *u12, Complex *u11t, Complex *u12t)
Reads and assigns the gauges from file.
int DHalo_swap_dir(double *d, int ncpt, int idir, int layer)
Swaps the halos along the axis given by idir in the direction given by layer.
int Par_dsum(double *dval)
Performs a reduction on a double dval to get a sum which is then distributed to all ranks.
int Hamilton(double *h, double *s, double res2, double *pp, Complex *X0, Complex *X1, Complex *Phi, Complex *ud[2], Complex_f *ut[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], Complex_f jqq, float akappa, float beta, float c_sw, double *ancgh, int traj)
Calculate the Hamiltonian.
int Par_ranset(unsigned long *seed, int iread)
Uses the rank to get a new seed. Copying from the FORTRAN description here c create new seeds in rang...
Matrix multiplication and related declarations.
#define UP
Flag for send up.
int * pcoord
The processor grid.
unsigned long seed
RANLUX seed.
gsl_rng * ranlux_instd
RANLUX instance.
#define AVX
Alignment of arrays. 64 for AVX-512, 32 for AVX/AVX2. 16 for SSE. Since AVX is standard on modern x86...
#define kmom
sublattice momentum sites
#define ngorkov
Gor'kov indices.
#define ksizet
Sublattice t extent.
#define kvol
Sublattice volume.
#define Complex
Double precision complex number.
#define nthreads
Number of threads for OpenMP, which can be overwritten at runtime.
#define ksize
Sublattice spatial extent for a cubic lattice.
#define nf
Fermion flavours (double it).
#define ndirac
Dirac indices.
#define cudaDeviceSynchronise()
Get rid of that bastardised yankee English.
dim3 dimBlockOne
block size of one
dim3 dimGridOne
Grid size of one.
cublasHandle_t cublas_handle
Handle for cuBLAS.
#define kvol3
Sublattice spatial volume.
#define halo
Total Halo size.
#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 kferm2
sublattice size including Dirac indices
#define npt
Processor grid t extent.
#define kvolHalo
Subvolume + halo size.
dim3 dimBlock
Default block size. Usually 128.
cudaStream_t streams[ndirac *ndim *nadj]
An array of concurrent GPU streams to keep it busy.
#define creal(z)
Extract Real Component using C standard notation.
#define I
Define I in double precision using C standard notation.