13int Addrc(
unsigned int *iu,
unsigned int *
id){
14 const char funcname[] =
"Addrc";
17 int ih[2][4] = {{-1,-1,-1,-1},{-1,-1,-1,-1}};
19 hd = (
unsigned int *)aligned_alloc(
AVX,
ndim*
halo*
sizeof(
int));
20 hu = (
unsigned int *)aligned_alloc(
AVX,
ndim*
halo*
sizeof(
int));
80 for(
int jt=0;jt<
ksizet;jt++)
81 for(
int jz=0;jz<
ksizez;jz++)
82 for(
int jy=0;jy<
ksizey;jy++)
83 for(
int jx=0;jx<
ksizex;jx++){
90 iaddr =
ia(jx-1,jy,jz,jt);
96 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
97 "\nExiting...\n\n",
HALOLIM, funcname, 0, 0, ih[0][0],
halo);
105 iaddr=
h1d[0]+ih[0][0];
107 iaddr =
ia(jx-1,jy,jz,jt);
113 iaddr =
ia(jx+1,jy,jz,jt);
118 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
119 "\nExiting...\n\n",
HALOLIM, funcname, 1, 0, ih[1][0],
halo);
127 iaddr=ih[1][0]+
h1u[0];
129 iaddr =
ia(jx+1,jy,jz,jt);
135 iaddr =
ia(jx,jy-1,jz,jt);
140 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
141 "\nExiting...\n\n",
HALOLIM, funcname, 0, 1, ih[0][1],
halo);
149 iaddr=
h1d[1]+ih[0][1];
151 iaddr =
ia(jx,jy-1,jz,jt);
157 iaddr =
ia(jx,jy+1,jz,jt);
162 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
163 "\nExiting...\n\n",
HALOLIM, funcname, 1, 1, ih[1][1],
halo);
171 iaddr=ih[1][1]+
h1u[1];
173 iaddr =
ia(jx,jy+1,jz,jt);
179 iaddr =
ia(jx,jy,jz-1,jt);
184 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
185 "\nExiting...\n\n",
HALOLIM, funcname, 0, 2, ih[0][2],
halo);
193 iaddr=
h1d[2]+ih[0][2];
195 iaddr =
ia(jx,jy,jz-1,jt);
201 iaddr =
ia(jx,jy,jz+1,jt);
206 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
207 "\nExiting...\n\n",
HALOLIM, funcname, 1, 2, ih[1][2],
halo);
215 iaddr=ih[1][2]+
h1u[2];
217 iaddr =
ia(jx,jy,jz+1,jt);
223 iaddr =
ia(jx,jy,jz,jt-1);
228 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
229 "\nExiting...\n\n",
HALOLIM, funcname, 0, 3, ih[0][3],
halo);
237 iaddr=
h1d[3]+ih[0][3];
239 iaddr =
ia(jx,jy,jz,jt-1);
245 iaddr =
ia(jx,jy,jz,jt+1);
250 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
251 "\nExiting...\n\n",
HALOLIM, funcname, 1, 3, ih[1][3],
halo);
259 iaddr=ih[1][3]+
h1u[3];
261 iaddr =
ia(jx,jy,jz,jt+1);
268#pragma omp parallel sections
272 FILE *id_out = fopen(
"id_out",
"w");
273 fprintf(id_out,
"x\ty\tz\ti\n");
274 for(
int i=0;i<
kvol;i++)
275 fprintf(id_out,
"%03i\t%03i\t%03i\t%03i\n",
id[i],
id[i+
kvol*1],
id[i+
kvol*2],
id[i+
kvol*3]);
280 FILE *iu_out = fopen(
"iu_out",
"w");
281 fprintf(iu_out,
"x\ty\tz\ti\n");
282 for(
int i=0;i<
kvol;i++)
283 fprintf(iu_out,
"%03i\t%03i\t%03i\t%03i\n",iu[i],iu[i+
kvol*1],iu[i+
kvol*2],iu[i+
kvol*3]);
293inline int ia(
int x,
int y,
int z,
int t){
294 const char funcname[] =
"ia";
305int Check_addr(
unsigned int *table,
int lns,
int lnt,
int imin,
int imax){
306 const char funcname[] =
"Check_addr";
308 int ntable = lns*lns*lns*lnt;
311 for(
int j=0; j<ntable*
ndim; j++){
313 if((iaddr<imin) || (iaddr>= imax)){
314 fprintf(stderr,
"Error %i in %s: %i is out of the bounds of (%i,%i)\n"\
315 "for a table of size %i^3 *%i.\nExiting...\n\n",\
328 const char funcname[] =
"Index2lcoord";
343 const char funcname[] =
"Index2gcoord";
349 coord[3] = index%
nt; index/=
nt;
350 coord[2] = index%
nz; index/=
nz;
351 coord[1] = index%
ny; index/=
ny;
357 const char funcname[] =
"Coord2gindex";
366 const char funcname[] =
"Coord2gindex";
372 return ix+
nx*(iy+
ny*(iz+
nz*it));
375 const char funcname[] =
"Testlcoord";
377 int coord[4], index, index2;
378 for(index =0; index<cap; index++){
380 printf(
"Coordinates for %i are (x,y,z,t):[%i,%i,%i,%i].\n", index,\
381 coord[0], coord[1], coord[2], coord[3]);
383 if(!(index==index2)){
384 fprintf(stderr,
"Error %i in %s: Converted index %i does not match "
385 "original index %i.\nExiting...\n\n",\
397 const char funcname[] =
"Testgcoord";
398 int coord[4], index, index2;
399#pragma omp parallel for private(coord, index, index2)
400 for(index=0; index<cap; index++){
403 printf(
"Coordinates for %i are (x,y,z,t):[%i,%i,%i,%i].\n", index,\
404 coord[0], coord[1], coord[2], coord[3]);
406 if(!(index==index2)){
407 fprintf(stderr,
"Error %i in %s: Converted index %i does not match "\
408 "original index %i.\nExiting...\n\n",\
421 const char funcname[] =
"ComplexConvert";
424 fprintf(stderr,
"Error %i in %s: Stride of %d is not valid.\nExiting...\n\n",
STRDERROR,funcname,stride);
436#pragma omp parallel for simd aligned(a,b:AVX)
437 for(
unsigned int i=0;i<len*stride;i++)
440#pragma omp parallel for simd aligned(a,b:AVX)
441 for(
unsigned int i=0;i<len*stride;i++)
446 for(
unsigned short j=0;j<stride;j++){
451#pragma omp parallel for simd aligned(a,b:AVX)
452 for(
unsigned int i=0;i<len;i++)
455#pragma omp parallel for simd aligned(a,b:AVX)
456 for(
unsigned int i=0;i<len;i++)
unsigned int halosize[ndim]
Array containing the size of the halo in each direction.
unsigned int * hd
Down halo indices.
unsigned int * hu
Up halo indices.
unsigned int h1d[ndim]
Down halo starting element.
unsigned int h1u[ndim]
Up halo starting element.
#define BOUNDERROR
Accessing out of bounds element.
#define STRDERROR
Undefined stride.
#define HALOLIM
Index goes beyond the halo.
#define INDTOCOORD
Issues converting index to coordinates.
int ComplexConvert(Complex_f *a, Complex *b, const unsigned int len, const bool dtof, const unsigned short stride)
takes an array of complex float and double precision numbers and converts the precision
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 Coord2gindex(int ix, int iy, int iz, int it)
Converts the coordinates of a global lattice point to its index in the computer memory.
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 ia(int x, int y, int z, int t)
Described as a 21st Century address calculator, it gets the memory address of an array entry.
int Testlcoord(int cap)
Tests if the local coordinate transformation functions are working.
int Index2lcoord(int index, int *coord)
Converts the index of a point in memory to the equivalent point in the 4 dimensional array,...
int Index2gcoord(int index, int *coord)
Converts the index of a point in memory to the equivalent point in the 4 dimensional array,...
int Testgcoord(int cap)
This is completely new and missing from the original code.
int Coord2lindex(int ix, int iy, int iz, int it)
Converts the coordinates of a local lattice point to its index in the computer memory.
#define ksizex
Sublattice x extent.
#define AVX
Alignment of arrays. 64 for AVX-512, 32 for AVX/AVX2. 16 for SSE. Since AVX is standard on modern x86...
#define nt
Lattice temporal extent. This also corresponds to the inverse temperature.
#define nproc
Number of processors for MPI.
#define nx
Lattice x extent.
#define ksizet
Sublattice t extent.
#define kvol
Sublattice volume.
#define Complex
Double precision complex number.
#define ksize
Sublattice spatial extent for a cubic lattice.
#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 ksizez
Sublattice z extent.
#define ksizey
Sublattice y extent.
#define nz
Lattice z extent. We normally use cubic lattices so this is the same as nx.
#define ny
Lattice y extent. We normally use cubic lattices so this is the same as nx.
dim3 dimBlock
Default block size. Usually 128.
Function declarations for most of the routines.