16int Addrc(
unsigned int *iu,
unsigned int *
id){
33 const char *funcname =
"Addrc";
36 int ih[2][4] = {{-1,-1,-1,-1},{-1,-1,-1,-1}};
39 h1u = (
unsigned int*)aligned_alloc(
AVX,
ndim*
sizeof(
int));
40 h1d = (
unsigned int*)aligned_alloc(
AVX,
ndim*
sizeof(
int));
96 for(
int jt=0;jt<
ksizet;jt++)
97 for(
int jz=0;jz<
ksizez;jz++)
98 for(
int jy=0;jy<
ksizey;jy++)
99 for(
int jx=0;jx<
ksizex;jx++){
106 iaddr =
ia(jx-1,jy,jz,jt);
112 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
113 "\nExiting...\n\n", HALOLIM, funcname, 0, 0, ih[0][0],
halo);
115 MPI_Abort(comm,HALOLIM);
121 iaddr=
h1d[0]+ih[0][0];
123 iaddr =
ia(jx-1,jy,jz,jt);
129 iaddr =
ia(jx+1,jy,jz,jt);
134 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
135 "\nExiting...\n\n", HALOLIM, funcname, 1, 0, ih[1][0],
halo);
137 MPI_Abort(comm,HALOLIM);
143 iaddr=ih[1][0]+
h1u[0];
145 iaddr =
ia(jx+1,jy,jz,jt);
151 iaddr =
ia(jx,jy-1,jz,jt);
156 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
157 "\nExiting...\n\n", HALOLIM, funcname, 0, 1, ih[0][1],
halo);
159 MPI_Abort(comm,HALOLIM);
165 iaddr=
h1d[1]+ih[0][1];
167 iaddr =
ia(jx,jy-1,jz,jt);
173 iaddr =
ia(jx,jy+1,jz,jt);
178 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
179 "\nExiting...\n\n", HALOLIM, funcname, 1, 1, ih[1][1],
halo);
181 MPI_Abort(comm,HALOLIM);
187 iaddr=ih[1][1]+
h1u[1];
189 iaddr =
ia(jx,jy+1,jz,jt);
195 iaddr =
ia(jx,jy,jz-1,jt);
200 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
201 "\nExiting...\n\n", HALOLIM, funcname, 0, 2, ih[0][2],
halo);
203 MPI_Abort(comm,HALOLIM);
209 iaddr=
h1d[2]+ih[0][2];
211 iaddr =
ia(jx,jy,jz-1,jt);
217 iaddr =
ia(jx,jy,jz+1,jt);
222 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
223 "\nExiting...\n\n", HALOLIM, funcname, 1, 2, ih[1][2],
halo);
225 MPI_Abort(comm,HALOLIM);
231 iaddr=ih[1][2]+
h1u[2];
233 iaddr =
ia(jx,jy,jz+1,jt);
239 iaddr =
ia(jx,jy,jz,jt-1);
244 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."\
245 "\nExiting...\n\n", HALOLIM, funcname, 0, 3, ih[0][3],
halo);
247 MPI_Abort(comm,HALOLIM);
253 iaddr=
h1d[3]+ih[0][3];
255 iaddr =
ia(jx,jy,jz,jt-1);
261 iaddr =
ia(jx,jy,jz,jt+1);
266 fprintf(stderr,
"Error %i in %s: Index ih[%i][%i]=%i is larger than the halo size %i."
267 "\nExiting...\n\n", HALOLIM, funcname, 1, 3, ih[1][3],
halo);
269 MPI_Abort(comm,HALOLIM);
275 iaddr=ih[1][3]+
h1u[3];
277 iaddr =
ia(jx,jy,jz,jt+1);
284#pragma omp parallel sections
288 FILE *id_out = fopen(
"id_out",
"w");
289 for(
int i=0;i<
kvol;i++)
290 fprintf(id_out,
"%i\t%i\t%i\t%i\n",
id[i*
ndim],
id[i*
ndim+1],
id[i*
ndim+2],
id[i*
ndim+3]);
295 FILE *iu_out = fopen(
"iu_out",
"w");
296 for(
int i=0;i<
kvol;i++)
297 fprintf(iu_out,
"%i\t%i\t%i\t%i\n",iu[i*
ndim],iu[i*
ndim+1],iu[i*
ndim+2],iu[i*
ndim+3]);
307inline int ia(
int x,
int y,
int z,
int t){
323 const char *funcname =
"ia";
334int Check_addr(
unsigned int *table,
int lns,
int lnt,
int imin,
int imax){
349 const char *funcname =
"Check_addr";
351 int ntable = lns*lns*lns*lnt;
354 for(
int j=0; j<ntable*
ndim; j++){
356 if((iaddr<imin) || (iaddr>= imax)){
357 fprintf(stderr,
"Error %i in %s: %i is out of the bounds of (%i,%i)\n"\
358 "for a table of size %i^3 *%i.\nExiting...\n\n",\
359 BOUNDERROR,funcname,iaddr,imin,imax,lns,lnt);
361 MPI_Abort(comm,BOUNDERROR);
393 const char *funcname =
"Index2lcoord";
430 const char *funcname =
"Index2gcoord";
436 coord[3] = index%
nt; index/=
nt;
437 coord[2] = index%
nz; index/=
nz;
438 coord[1] = index%
ny; index/=
ny;
461 const char *funcname =
"Coord2gindex";
487 const char *funcname =
"Coord2gindex";
493 return ix+
nx*(iy+
ny*(iz+
nz*it));
516 const char *funcname =
"Testlcoord";
518 int coord[4], index, index2;
519 for(index =0; index<cap; index++){
521 printf(
"Coordinates for %i are (x,y,z,t):[%i,%i,%i,%i].\n", index,\
522 coord[0], coord[1], coord[2], coord[3]);
524 if(!(index==index2)){
525 fprintf(stderr,
"Error %i in %s: Converted index %i does not match "
526 "original index %i.\nExiting...\n\n",\
527 INDTOCOORD, funcname, index2, index);
529 MPI_Abort(comm,INDTOCOORD);
560 const char *funcname =
"Testgcoord";
561 int coord[4], index, index2;
562#pragma omp parallel for private(coord, index, index2)
563 for(index=0; index<cap; index++){
566 printf(
"Coordinates for %i are (x,y,z,t):[%i,%i,%i,%i].\n", index,\
567 coord[0], coord[1], coord[2], coord[3]);
569 if(!(index==index2)){
570 fprintf(stderr,
"Error %i in %s: Converted index %i does not match "\
571 "original index %i.\nExiting...\n\n",\
572 INDTOCOORD, funcname, index2, index);
574 MPI_Abort(comm,INDTOCOORD);
unsigned int * halosize
Array containing the size of the halo in each direction.
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)
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.
unsigned int * h1u
Up halo starting element.
int Testlcoord(int cap)
Tests if the local coordinate transformation functions are working.
unsigned int * hd
Down halo indices.
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,...
unsigned int * h1d
Down halo starting element.
int Testgcoord(int cap)
This is completely new and missing from the original code.
unsigned int * hu
Up halo indices.
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.
Header for routines related to lattice sites.
This header is intended to be a useful reference for error codes and their meanings.
Defines the constants of the code and other parameters for loop dimensions. Each subroutine includes ...
#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 nx
Lattice x extent.
#define ksizet
Sublattice t extent.
#define kvol
Sublattice volume.
#define ksize
Sublattice spatial extent for a cubic lattice.
#define halo
Total Halo size.
#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.