9#include <thrust/reduce.h>
27 const unsigned int i,
const unsigned short mu,
const unsigned short nu){
28 const unsigned int uidm = iu[i+
kvol*mu];
29 unsigned int ind=i+
kvol*mu;
31 unsigned int indn=uidm+
kvol*nu;
32 *Sigma11=u11t[ind]*u11t[indn]-u12t[ind]*
conj(u12t[indn]);
33 *Sigma12=u11t[ind]*u12t[indn]+u12t[ind]*
conj(u11t[indn]);
35 const int uidn = iu[i+
kvol*nu];
38 Complex_f a12=-*Sigma11*u12t[ind]+*Sigma12*u11t[ind];
41 *Sigma11=a11*
conj(u11t[ind])+a12*
conj(u12t[ind]);
42 *Sigma12=-a11*u12t[ind]+a12*u11t[ind];
60 const unsigned int gsize = gridDim.x*gridDim.y*gridDim.z;
61 const unsigned int bsize = blockDim.x*blockDim.y*blockDim.z;
62 const unsigned int blockId = blockIdx.x+ blockIdx.y * gridDim.x+ gridDim.x * gridDim.y * blockIdx.z;
63 const unsigned int threadId= blockId * bsize+(threadIdx.z * blockDim.y+ threadIdx.y)* blockDim.x+ threadIdx.x;
66 for(
unsigned int i=threadId;i<
kvol;i+=bsize*gsize){
70 for(
unsigned short mu=1;mu<
ndim;mu++)
71 for(
unsigned short nu=0;nu<mu;nu++){
73 cuSU2plaq(u11t,u12t,&Sigma11,&Sigma12,iu,i,mu,nu);
77 hg_c[0] -=
creal(Sigma11);
81 hg_c[1] -=
creal(Sigma11);
85 hgt_d[i]=hg_c[0]; hgs_d[i]=hg_c[1];
98 const unsigned int gsize = gridDim.x*gridDim.y*gridDim.z;
99 const unsigned int bsize = blockDim.x*blockDim.y*blockDim.z;
100 const unsigned int blockId = blockIdx.x+ blockIdx.y * gridDim.x+ gridDim.x * gridDim.y * blockIdx.z;
101 const unsigned int threadId= blockId * bsize+(threadIdx.z * blockDim.y+ threadIdx.y)* blockDim.x+ threadIdx.x;
102 for(
unsigned int i=threadId;i<
kvol3;i+=gsize*bsize){
103 Complex_f Sig[2]; Sig[0]=Sigma11[i]; Sig[1]=Sigma12[i];
105 for(
unsigned int it=1;it<
ksizet;it++){
106 const unsigned int indexu=it*
kvol3+i;
107 u[0]=u11t[indexu+3*
kvol];u[1]=u12t[indexu+3*
kvol];
110 Sig[1]=Sig[0]*u[1]+Sig[1]*
conj(u[0]);
113 Sigma11[i]=Sig[0]; Sigma12[i]=Sig[1];
123 cudaGetDevice(&device);
124 float *hgs_d, *hgt_d;
126 cudaMallocAsync((
void **)&hgs_d,
kvol*
sizeof(
float),NULL);
127 thrust::device_ptr<float> hgs_T = thrust::device_pointer_cast(hgs_d);
128 cudaMallocAsync((
void **)&hgt_d,
kvol*
sizeof(
float),NULL);
129 thrust::device_ptr<float> hgt_T = thrust::device_pointer_cast(hgt_d);
134 *hgs= (double)thrust::reduce(hgs_T,hgs_T+
kvol,(
float)0);
135 *hgt= (double)thrust::reduce(hgt_T,hgt_T+
kvol,(
float)0);
142 cudaGetDevice(&device);
143 cudaMallocManaged((
void **)&Sigma[0],
kvol3*
sizeof(
Complex_f),cudaMemAttachGlobal);
145 cudaMallocManaged((
void **)&Sigma[1],
kvol3*
sizeof(
Complex_f),cudaMemAttachGlobal);
159 cudaFreeAsync(Sigma[1],
streams[1]);
__global__ void Polyakov(Complex_f *Sigma11, Complex_f *Sigma12, Complex_f *u11t, Complex_f *u12t)
Calculate the Polyakov loop (no prizes for guessing that one...).
void cuPolyakov(Complex_f *Sigma[2], Complex_f *ut[2], dim3 dimGrid, dim3 dimBlock)
Calculate the Polyakov loop (no prizes for guessing that one...).
__host__ void cuAverage_Plaquette(double *hgs, double *hgt, Complex_f *u11t, Complex_f *u12t, unsigned int *iu, dim3 dimGrid, dim3 dimBlock)
Calling wrappers.
__global__ void Average_Plaquette(float *hgs_d, float *hgt_d, Complex_f *u11t, Complex_f *u12t, unsigned int *iu)
Calculates the gauge action using new (how new?) lookup table Follows a routine called qedplaq in som...
__device__ void cuSU2plaq(Complex_f *u11t, Complex_f *u12t, Complex_f *Sigma11, Complex_f *Sigma12, unsigned int *iu, const unsigned int i, const unsigned short mu, const unsigned short nu)
Calculates the SU2 plaquette.
__device__ __forceinline__ T conj(const T &z)
Complex Conjugation.
Matrix multiplication and related declarations.
#define ksizet
Sublattice t extent.
#define kvol
Sublattice volume.
#define cudaDeviceSynchronise()
Get rid of that bastardised yankee English.
cublasHandle_t cublas_handle
Handle for cuBLAS.
#define kvol3
Sublattice spatial volume.
#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.
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.