su2hmc
Loading...
Searching...
No Matches
sizes.h
Go to the documentation of this file.
1
28#pragma once
29#ifdef __USE_MKL__
31#define USE_BLAS
32#include <mkl.h>
33#elif (defined AMD_BLAS||defined OPENBLAS)
35#define USE_BLAS
36#include <cblas.h>
37#elif defined GSL_BLAS
39#define USE_BLAS
40#include <gsl/gsl_cblas.h>
41#endif
42#ifdef USE_GPU
43#include <cuda.h>
44#include <cuda_runtime_api.h>
45#include <cublas_v2.h>
47extern cublasHandle_t cublas_handle;
49extern cublasStatus_t cublas_status;
51extern cudaMemPool_t mempool;
53#define cudaDeviceSynchronise() cudaDeviceSynchronize()
54#endif
55#ifdef __CUDACC__
56#include <thrust_complex.h>
57#include <thrust/reduce.h>
58#include <thrust/device_vector.h>
59#else
60#include <complex.h>
62#define Complex_f float complex
64#define Complex double complex
65#endif
66
68#define FILELEN 64
69// Common block definition for parallel variables
70
72#define nx 24
73#if(nx<1)
74#error "nx is expected it to be greater than or equal to 1"
75#endif
76
77// Keep original restriction of single spatial extent
78
80#define ny nx
81#if(ny<1)
82#error "ny is expected it to be greater than or equal to 1"
83#endif
84
86#define nz nx
87#if(nz<1)
88#error "nz is expected it to be greater than or equal to 1"
89#endif
90
92#define nt 24
93#if(nt<1)
94#error "nt is expected it to be greater than or equal to 1"
95#endif
96
98#define gvol (nx*ny*nz*nt)
100#define gvol3 (nx*ny*nz)
101
103#define npx 1
104#if(npx<1)
105#error "npx is expected it to be greater than or equal to 1"
106#elif(nx%npx!=0)
107#error "npx should be a divisor of nx"
108#endif
109
110// Initially restrict to npz = npy = npx
111// This allows us to have a single ksize variable
112
114#define npy npx
115#if(npy<1)
116#error "npy is expected it to be greater than or equal to 1"
117#elif(ny%npy!=0)
118#error "npy should be a divisor of ny"
119#endif
120
122#define npz npx
123#if(npz<1)
124#error "npz is expected it to be greater than or equal to 1"
125#elif(nz%npz!=0)
126#error "npz should be a divisor of nz"
127#endif
128
130#define npt 1
131#if(npt<1)
132#error "npt is expected it to be greater than or equal to 1"
133#elif(nt%npt!=0)
134#error "npt should be a divisor of nt"
135#endif
136
138#define nproc (npx*npy*npz*npt)
139#if (defined USE_GPU && nproc>1)
140#error "Multi-GPU is not yet supported"
141#endif
142
144#define nthreads 8
145
146// Existing parameter definitions.
148#define ksizex (nx/npx)
150#define ksizey (ny/npy)
152#define ksizez (nz/npz)
153
155#define ksize ksizex
156
158#define ksizet (nt/npt)
160#define nf 1
161
163#define kvol (ksizet*ksizez*ksizey*ksizex)
165#define kvol3 (ksizez*ksizey*ksizex)
166
167// integer, parameter :: niterc=2*gvol
168// #define niterc 2*gvol
169// jis: hard limit to avoid runaway trajectories
170#if (nx*ny*nz*nt<=16384)
172#define niterc gvol
173#elif (nx>=(3*nt)/2)
175#define niterc gvol3
176#else
178#define niterc (gvol/4)
179#endif
180// Constants for dimensions.
182#define nc 2
184#define nadj 3
186#define ndirac 4
188#define ndim 4
190#define ngorkov 8
191
193#define kmom (ndim*nadj*kvol)
195#define kferm (nc*ngorkov*kvol)
197#define kferm2 (nc*ndirac*kvol)
207#if(npx>1)
208#define halox (ksizey*ksizez*ksizet)
209#else
210#define halox 0
211#endif
213#if(npy>1)
214#define haloy (ksizex*ksizez*ksizet)
215#else
216#define haloy 0
217#endif
219#if(npz>1)
220#define haloz (ksizex*ksizey*ksizet)
221#else
222#define haloz 0
223#endif
225#if(npt>1)
226#define halot (ksizex*ksizey*ksizez)
227#else
228#define halot 0
229#endif
231#define halo (2*(halox+haloy+haloz+halot))
232
234#define kvolHalo (kvol+halo)
236#define kfermHalo (nc*ngorkov*kvolHalo)
238#define kferm2Halo (nc*ndirac*kvolHalo)
240#define kmomHalo (ndim*nadj*kvolHalo)
241
242// These all used to be multipled by kferm or kferm2 at the start of Congradq or Congradp
243// On 20240516 in Room 2.19 of the Lloyd building of Trinity we copped that doing so means that the residue is larger
244// if running on a smaller number of cores. In the extreme GPU case the subvolume is the entire volume so the residue
245// can be several orders of magnitude larger than in the smallest sublattice case.
246// Instead, we rescale all the default residues here by sqrt(kferm) or sqrt(kferm2). No matter what size sublattice
247// we use now, the residue will match that of a 2^3X4 sublattice used in the earlier FORTRAN runs
249#define respbp 3.2E-5
251#define rescgg 2.26E-5
253#define rescga 2.26E-8
254
255
256#ifdef __AVX512F__
257#ifdef __unix__
258#warning AVX512 detected
259#elif (defined WIN32||_WIN32)
260#pragma message("AVX512 detected")
261#endif
263#define AVX 64
264#elif defined __AVX__
265#ifdef __unix__
266#warning AVX or AVX2 detected
267#elif (defined WIN32||_WIN32)
268#pragma message("AVX or AVX2 detected")
269#endif
271#define AVX 32
272#else
273#ifdef __unix__
274#warning No AVX detected, assuming SSE is present
275#elif (defined WIN32||_WIN32)
276#pragma message("No AVX detected, assuming SSE is present")
277#endif
279#define AVX 16
280#endif
281
282#ifdef USE_GPU
294extern dim3 dimBlock;
297extern dim3 dimGrid;
299extern dim3 dimBlockOne;
301extern dim3 dimGridOne;
303#define USE_BLAS
304#endif
cudaMemPool_t mempool
Memory pool for Async allocations.
Definition main.c:49
cublasStatus_t cublas_status
Status of cuBLAS for error reporting.
Definition main.c:48
dim3 dimBlockOne
block size of one
Definition cusu2hmc.cu:22
dim3 dimGridOne
Grid size of one.
Definition cusu2hmc.cu:23
cublasHandle_t cublas_handle
Handle for cuBLAS.
Definition main.c:47
dim3 dimGrid
Default grid size. First component is normally nt. Second and third depend whatever is needed to get ...
Definition cusu2hmc.cu:27
dim3 dimBlock
Default block size. Usually 128.
Definition cusu2hmc.cu:25
Complex Header for CUDA. Sets macros for C compatability.