13MPI_Comm comm = MPI_COMM_WORLD;
26 const char funcname[] =
"Par_begin";
29 if(MPI_Init(&argc, &argv)){
30 fprintf(stderr,
"Error %i in %s: Failed to initialise MPI\nExiting\n\n",
NO_MPI_INIT, funcname);
35 if(MPI_Comm_rank(comm, &
rank)){
36 fprintf(stderr,
"Error %i in %s: Failed to find rank.\nExiting...\n\n",
NO_MPI_RANK, funcname);
39 if(MPI_Comm_size(comm, &
size)){
40 fprintf(stderr,
"Error %i in %s: Failed to find size\nExiting...\n\n",
NO_MPI_SIZE, funcname);
48 fprintf(stderr,
"Error %i in %s: For process %i, size %i is not equal to nproc %i.\n"
57 int gsize[4], lsize[4];
58 gsize[0]=
nx; gsize[1]=
ny; gsize[2]=
nz; gsize[3]=
nt;
62 int cartsize[
ndim] __attribute__((aligned(
AVX)));
63 cartsize[0]=
npx; cartsize[1]=
npy; cartsize[2]=
npz; cartsize[3]=
npt;
68 int periods[
ndim] __attribute__((aligned(
AVX)));
70 for(
int i=0; i<
ndim; i++)
77 MPI_Cart_create(comm,
ndim, cartsize, periods, reorder, &commcart);
83 for(
int i= 0; i<
ndim; i++)
84 MPI_Cart_shift(commcart, i, 1, &
pd[i], &
pu[i]);
90 for(
int iproc = 0; iproc<
nproc; iproc++){
92#pragma omp simd aligned(pcoord:AVX)
93 for(
int idim = 0; idim<
ndim; idim++){
95 pstop[idim][iproc] =
pstart[idim][iproc] + lsize[idim];
100 for(
int idim = 0; idim<
ndim; idim++){
102 pstop[idim][0] = lsize[idim];
107 printf(
"Running on %i processors.\nGrid layout is %ix%ix%ix%i\n",
109 printf(
"Rank: %i pu: %i %i %i %i pd: %i %i %i %i\n",
rank,
pu[0],
pu[1],
pu[2],
pu[3],
114int Par_sread(
const int iread,
const float beta,
const float fmu,
const float akappa,
const Complex_f ajq,\
116 const char funcname[] =
"Par_sread";
120 MPI_Datatype MPI_SEED_TYPE = (
sizeof(
seed)==
sizeof(int)) ? MPI_INT:MPI_LONG;
129 char gauge_file[
FILELEN]=
"config.";
130 int buffer;
char buff2[7];
132 buffer = (int)round(100*beta);
133 sprintf(buff2,
"b%03d",buffer);
134 strcat(gauge_file,buff2);
136 buffer = (int)round(10000*akappa);
137 sprintf(buff2,
"k%04d",buffer);
138 strcat(gauge_file,buff2);
140 buffer = (int)round(1000*fmu);
141 sprintf(buff2,
"mu%04d",buffer);
142 strcat(gauge_file,buff2);
144 buffer = (int)round(1000*
creal(ajq));
145 sprintf(buff2,
"j%03d",buffer);
146 strcat(gauge_file,buff2);
149 buffer = (int)round(100*c_sw);
150 sprintf(buff2,
"c%02d",buffer);
151 strcat(gauge_file,buff2);
154 sprintf(buff2,
"s%02d",
nx);
155 strcat(gauge_file,buff2);
157 sprintf(buff2,
"t%02d",
nt);
158 strcat(gauge_file,buff2);
161 sprintf(c,
".%06d", iread);
162 strcat(gauge_file, c);
165 printf(
"Opening gauge file on processor: %i\n",
rank);
167 if(!(con = fopen(gauge_file, fileop))){
168 fprintf(stderr,
"Error %i in %s: Failed to open %s for %s.\
169 \nExiting...\n\n",
OPENERROR, funcname, gauge_file, fileop);
179 fread(&old_nproc,
sizeof(
int), 1, con);
181 fprintf(stderr,
"Warning %i in %s: Previous run was done on %i processors, current run uses %i.\n",\
189 unsigned long *seed_array=(
unsigned long*)calloc(
nproc,
sizeof(
seed));
190#elif defined __USE_MKL__ && !defined USE_RAN2
191 int *seed_array=(
int *)calloc(
nproc,
sizeof(
seed));
193 long *seed_array=(
long*)calloc(
nproc,
sizeof(
seed));
195 for(
int i=0; i<fmin(old_nproc,
nproc);i++)
196 fread(seed_array+i,
sizeof(
seed), 1, con);
199 for(
int i=old_nproc; i<
nproc; i++)
200 seed_array[i] = seed_array[0]*(1.0f+8.0f*(
float)i/(
float)(
size-1));
204 for(
int iproc = 1; iproc<
nproc; iproc++)
205 if(MPI_Send(&seed_array[iproc], 1, MPI_SEED_TYPE,iproc, 1, comm)){
206 fprintf(stderr,
"Error %i in %s: Failed to send seed to process %i.\nExiting...\n\n",
212 for(
int iproc = 0; iproc <
nproc; iproc++)
213 for(
int idim = 0; idim <
ndim; idim++){
220 for(
int it=
pstart[3][iproc]; it<
pstop[3][iproc]; it++)
221 for(
int iz=
pstart[2][iproc]; iz<
pstop[2][iproc]; iz++)
222 for(
int iy=
pstart[1][iproc]; iy<
pstop[1][iproc]; iy++)
223 for(
int ix=
pstart[0][iproc]; ix<
pstop[0][iproc]; ix++){
228 u1buff[i]=u11Read[idim*
gvol+j];
229 u2buff[i]=u12Read[idim*
gvol+j];
234 fprintf(stderr,
"Error %i in %s: Number of elements %i is not equal to\
235 kvol %i.\nExiting...\n\n",
NUMELEM, funcname, i,
kvol);
244 cudaMemcpy(u11+idim*
kvol,u1buff,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
245 cudaMemcpy(u12+idim*
kvol,u2buff,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
255 if(MPI_Send(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX,iproc, 2*idim, comm)){
256 fprintf(stderr,
"Error %i in %s: Failed to send ubuff to process %i.\nExiting...\n\n",
264 if(MPI_Send(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX,iproc, 2*idim+1, comm)){
265 fprintf(stderr,
"Error %i in %s: Failed to send ubuff to process %i.\nExiting...\n\n",
276 free(u11Read); free(u12Read);
281 if(MPI_Recv(&
seed, 1, MPI_SEED_TYPE,
masterproc, 1, comm, &status)){
282 fprintf(stderr,
"Error %i in %s: Falied to receive seed on process %i.\nExiting...\n\n",
290 for(
int idim = 0; idim<
ndim; idim++){
292 if(MPI_Recv(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim, comm, &status)){
293 fprintf(stderr,
"Error %i in %s: Falied to receive u11 on process %i.\nExiting...\n\n",
297 if(MPI_Recv(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim+1, comm, &status)){
298 fprintf(stderr,
"Error %i in %s: Falied to receive u12 on process %i.\nExiting...\n\n",
303 cudaMemcpy(u11+idim*
kvol,u1buff,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
304 cudaMemcpy(u12+idim*
kvol,u2buff,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
312 free(u1buff); free(u2buff);
313 for(
unsigned short mu=0;mu<
ndim;mu++){
324int Par_swrite(
const int itraj,
const int icheck,
const float beta,
const float fmu,
const float akappa,
326 const char funcname[] =
"par_swrite";
330 MPI_Datatype MPI_SEED_TYPE = (
sizeof(
seed)==
sizeof(int)) ? MPI_INT:MPI_LONG;
335 char dump_prefix[
FILELEN]=
"u11.";
337 sprintf(dump_buff,
"r%01d_c%06d",
rank,itraj);
338 strcat(dump_prefix,dump_buff);
339 FILE *gauge_dump=fopen(dump_prefix,
"wb");
351 unsigned long *seed_array=(
unsigned long*)calloc(
nproc,
sizeof(
seed));
352#elif defined __USE_MKL__ && !defined USE_RAN2
353 int *seed_array=(
int *)calloc(
nproc,
sizeof(
seed));
355 long *seed_array=(
long*)calloc(
nproc,
sizeof(
seed));
359 for(
int iproc = 1; iproc<
nproc; iproc++)
360 if(MPI_Recv(&seed_array[iproc], 1, MPI_SEED_TYPE,iproc, 1, comm, &status)){
361 fprintf(stderr,
"Error %i in %s: Failed to receive seed from process %i.\nExiting...\n\n",
369 for(
int iproc=0;iproc<
nproc;iproc++)
370 for(
int idim=0;idim<
ndim;idim++){
373 if(MPI_Recv(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX, iproc, 2*idim, comm, &status)){
374 fprintf(stderr,
"Error %i in %s: Falied to receive u11 from process %i.\nExiting...\n\n",
378 if(MPI_Recv(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX, iproc, 2*idim+1, comm, &status)){
379 fprintf(stderr,
"Error %i in %s: Falied to receive u12 from process %i.\nExiting...\n\n",
389 cudaMemcpy(u1buff,u11+idim*
kvol,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
390 cudaMemcpy(u2buff,u12+idim*
kvol,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
397 strcat(part_dump,dump_prefix);
398 sprintf(dump_buff,
"_d%d",idim);
399 strcat(part_dump,dump_buff);
400 FILE *pdump=fopen(part_dump,
"wb");
408 for(
int it=
pstart[3][iproc]; it<
pstop[3][iproc]; it++)
409 for(
int iz=
pstart[2][iproc]; iz<
pstop[2][iproc]; iz++)
410 for(
int iy=
pstart[1][iproc]; iy<
pstop[1][iproc]; iy++)
411 for(
int ix=
pstart[0][iproc]; ix<
pstop[0][iproc]; ix++){
414 u11Write[idim*
gvol+j] = u1buff[i];
415 u12Write[idim*
gvol+j] = u2buff[i];
420 fprintf(stderr,
"Error %i in %s: Number of elements %i is not equal to\
421 kvol %i.\nExiting...\n\n",
NUMELEM, funcname, i,
kvol);
429 free(u1buff); free(u2buff);
431 char gauge_title[
FILELEN]=
"config.";
432 int buffer;
char buff2[7];
434 buffer = (int)round(100*beta);
435 sprintf(buff2,
"b%03d",buffer);
436 strcat(gauge_title,buff2);
438 buffer = (int)round(10000*akappa);
439 sprintf(buff2,
"k%04d",buffer);
440 strcat(gauge_title,buff2);
442 buffer = (int)round(1000*fmu);
443 sprintf(buff2,
"mu%04d",buffer);
444 strcat(gauge_title,buff2);
446 buffer = (int)round(1000*
creal(ajq));
447 sprintf(buff2,
"j%03d",buffer);
448 strcat(gauge_title,buff2);
451 buffer = (int)round(100*c_sw);
452 sprintf(buff2,
"c%02d",buffer);
453 strcat(gauge_title,buff2);
456 sprintf(buff2,
"s%02d",
nx);
457 strcat(gauge_title,buff2);
459 sprintf(buff2,
"t%02d",
nt);
460 strcat(gauge_title,buff2);
463 strcpy(gauge_file,gauge_title);
465 sprintf(c,
".%06d", itraj);
466 strcat(gauge_file, c);
467 printf(
"Gauge file name is %s\n", gauge_file);
468 printf(
"Writing the gauge file on processor %i.\n",
rank);
471 if(!(con=fopen(gauge_file, fileop))){
472 fprintf(stderr,
"Error %i in %s: Failed to open %s for %s.\
473 \nExiting...\n\n",
OPENERROR, funcname, gauge_file, fileop);
485 fwrite(&
size,
sizeof(
int),1,con);
490 fwrite(seed_array,
nproc*
sizeof(
seed), 1, con);
492 free(u11Write); free(u12Write);
498 fprintf(stderr,
"Error %i in %s: Falied to send u11 from process %i.\nExiting...\n\n",
502 for(
int idim = 0; idim<
ndim; idim++){
504 cudaMemcpy(u1buff,u11+idim*
kvol,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
505 cudaMemcpy(u2buff,u12+idim*
kvol,
kvol*
sizeof(
Complex),cudaMemcpyDefault);
512 strcat(part_dump,dump_prefix);
513 sprintf(dump_buff,
"_d%d",idim);
514 strcat(part_dump,dump_buff);
515 FILE *pdump=fopen(part_dump,
"wb");
520 if(MPI_Send(u1buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim, comm)){
521 fprintf(stderr,
"Error %i in %s: Falied to send u11 from process %i.\nExiting...\n\n",
525 if(MPI_Send(u2buff,
kvol, MPI_C_DOUBLE_COMPLEX,
masterproc, 2*idim+1, comm)){
526 fprintf(stderr,
"Error %i in %s: Falied to send u12 from process %i.\nExiting...\n\n",
531 free(u1buff); free(u2buff);
540 const char funcname[] =
"Par_isum";
544 if(MPI_Allreduce(ival, itmp, 1, MPI_INTEGER, MPI_SUM, comm)){
545 fprintf(stderr,
"Error %i in %s: Couldn't complete reduction for %i.\nExiting...\n\n",
REDUCERR, funcname, *ival);
551 const char funcname[] =
"Par_dsum";
555 if(MPI_Allreduce(dval, &dtmp, 1, MPI_DOUBLE, MPI_SUM, comm)){
556 fprintf(stderr,
"Error %i in %s: Couldn't complete reduction for %f.\nExiting...\n\n",
REDUCERR, funcname, *dval);
563 const char funcname[] =
"far_dsum";
567 if(MPI_Allreduce(fval, &ftmp, 1, MPI_FLOAT, MPI_SUM, comm)){
568 fprintf(stderr,
"Error %i in %s: Couldn't complete reduction for %f.\nExiting...\n\n",
REDUCERR, funcname, *fval);
575 const char funcname[] =
"Par_csum";
579 if(MPI_Allreduce(cval, &ctmp, 1, MPI_C_FLOAT_COMPLEX, MPI_SUM, comm)){
581 fprintf(stderr,
"Error %i in %s: Couldn't complete reduction for %f+%f i.\nExiting...\n\n",
590 const char funcname[] =
"Par_zsum";
594 if(MPI_Allreduce(zval, &ztmp, 1, MPI_C_DOUBLE_COMPLEX, MPI_SUM, comm)){
596 fprintf(stderr,
"Error %i in %s: Couldn't complete reduction for %f+%f i.\nExiting...\n\n",
605 const char funcname[] =
"Par_icopy";
606 if(MPI_Bcast(ival,1,MPI_INT,
masterproc,comm)){
607 fprintf(stderr,
"Error %i in %s: Failed to broadcast %i from %i.\nExiting...\n\n",
614 const char funcname[] =
"Par_dcopy";
615 if(MPI_Bcast(dval,1,MPI_DOUBLE,
masterproc,comm)){
616 fprintf(stderr,
"Error %i in %s: Failed to broadcast %f from %i.\nExiting...\n\n",
623 const char funcname[] =
"Par_dfopy";
624 if(MPI_Bcast(fval,1,MPI_FLOAT,
masterproc,comm)){
625 fprintf(stderr,
"Error %i in %s: Failed to broadcast %f from %i.\nExiting...\n\n",
632 const char funcname[] =
"Par_ccopy";
633 if(MPI_Bcast(cval,1,MPI_C_FLOAT_COMPLEX,
masterproc,comm)){
635 fprintf(stderr,
"Error %i in %s: Failed to broadcast %f+i%f from %i.\nExiting...\n\n",
643 const char funcname[] =
"Par_zcopy";
644 if(MPI_Bcast(zval,1,MPI_C_DOUBLE_COMPLEX,
masterproc,comm)){
646 fprintf(stderr,
"Error %i in %s: Failed to broadcast %f+i%f from %i.\nExiting...\n\n",
663 const char funcname[] =
"ZHalo_swap_all";
690 const char funcname[] =
"ZHalo_swap_dir";
691 if(layer!=
DOWN && layer!=
UP){
692 fprintf(stderr,
"Error %i in %s: Cannot swap in the direction given by %i.\nExiting...\n\n",
698 for(
unsigned short icpt=0;icpt<ncpt;icpt++){
700 printf(
"Rank %d: Function %s: dir: %d icpt= %d of %d\n",
rank, funcname, idir, icpt,ncpt);
702 MPI_Request req; MPI_Status stat;
707 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
708 "a memory leak on rank %i.\nExiting...\n\n"
712#pragma omp simd aligned(sendbuff,z:AVX)
714 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
717 if(MPI_Isend(sendbuff,
halosize[idir], MPI_C_DOUBLE_COMPLEX,
pd[idir], icpt, comm, &req)){
718 fprintf(stderr,
"Error %i in %s: Failed to send off the down halo from rank %i to rank %i.\nExiting...\n"
722 if(MPI_Recv(z+
h1u[idir]+
kvolHalo*icpt,
halosize[idir], MPI_C_DOUBLE_COMPLEX,
pu[idir], icpt, comm, &stat)){
723 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into up halo from rank %i.\nExiting...\n",
730 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
731 "a memory leak on rank %i.\nExiting...\n\n"
735#pragma omp simd aligned(sendbuff,z:AVX)
737 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
740 if(MPI_Isend(sendbuff,
halosize[idir], MPI_C_DOUBLE_COMPLEX,
pu[idir], icpt, comm, &req)){
741 fprintf(stderr,
"Error %i in %s: Failed to send off the up halo from rank %i to rank %i.\nExiting...\n",
745 if(MPI_Recv(z+
h1d[idir]+
kvolHalo*icpt,
halosize[idir], MPI_C_DOUBLE_COMPLEX,
pd[idir], icpt, comm, &stat)){
746 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into doww halo from rank %i.\nExiting...\n",
752 MPI_Wait(&req, &stat);
758 const char funcname[] =
"CHalo_swap_all";
785 const char funcname[] =
"CHalo_swap_dir";
786 if(layer!=
DOWN && layer!=
UP){
787 fprintf(stderr,
"Error %i in %s: Cannot swap in the direction given by %i.\nExiting...\n\n",
792 for(
unsigned short icpt=0;icpt<ncpt;icpt++){
794 printf(
"Rank %d: Function %s: dir: %d icpt= %d of %d\n",
rank, funcname, idir, icpt,ncpt);
796 MPI_Request req; MPI_Status stat;
801 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
802 "a memory leak on rank %i.\nExiting...\n\n"
807#pragma omp simd aligned(sendbuff,c:AVX)
808 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
811 if(MPI_Isend(sendbuff,
halosize[idir], MPI_C_FLOAT_COMPLEX,
pd[idir], icpt, comm, &req)){
812 fprintf(stderr,
"Error %i in %s: Failed to send off the down halo from rank %i to rank %i.\nExiting...\n"
816 if(MPI_Recv(c+
h1u[idir]+
kvolHalo*icpt,
halosize[idir], MPI_C_FLOAT_COMPLEX,
pu[idir], icpt, comm, &stat)){
817 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into up halo from rank %i.\nExiting...\n",
824 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
825 "a memory leak on rank %i.\nExiting...\n\n"
829#pragma omp simd aligned(sendbuff,c:AVX)
830 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
833 if(MPI_Isend(sendbuff,
halosize[idir], MPI_C_FLOAT_COMPLEX,
pu[idir], icpt, comm, &req)){
834 fprintf(stderr,
"Error %i in %s: Failed to send off the up halo from rank %i to rank %i.\nExiting...\n",
838 if(MPI_Recv(c+
h1d[idir]+
kvolHalo*icpt,
halosize[idir], MPI_C_FLOAT_COMPLEX,
pd[idir], icpt, comm, &stat)){
839 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into doww halo from rank %i.\nExiting...\n",
845 MPI_Wait(&req, &stat);
851 const char funcname[] =
"DHalo_swap_all";
878 const char funcname[] =
"DHalo_swap_dir";
880 if(layer!=
DOWN && layer!=
UP){
881 fprintf(stderr,
"Error %i in %s: Cannot swap in the direction given by %i.\nExiting...\n\n",
886 for(
unsigned short icpt=0;icpt<ncpt;icpt++){
888 printf(
"Rank %d: Function %s: dir: %d icpt= %d of %d\n",
rank, funcname, idir, icpt,ncpt);
891 MPI_Request req; MPI_Status stat;
892 double *sendbuff = (
double *)aligned_alloc(
AVX,
halosize[idir]*
sizeof(
double));
896 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
897 "a memory leak on rank %i.\nExiting...\n\n"
902#pragma omp simd aligned(sendbuff,d:AVX)
903 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
906 if(MPI_Isend(sendbuff,
halosize[idir], MPI_DOUBLE,
pd[idir], icpt, comm, &req)){
907 fprintf(stderr,
"Error %i in %s: Failed to send off the down halo from rank %i to rank %i.\nExiting...\n\n",
912 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into up halo from rank %i.\nExiting...\n\n",
919 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
920 "a memory leak on rank %i.\nExiting...\n\n"
924#pragma omp simd aligned(sendbuff,d:AVX)
926 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
929 if(MPI_Isend(sendbuff,
halosize[idir], MPI_DOUBLE,
pu[idir], icpt, comm, &req)){
930 fprintf(stderr,
"Error %i in %s: Failed to send off the up halo from rank %i to rank %i.\nExiting...\n\n",
935 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into doww halo from rank %i.\nExiting...\n\n",
941 MPI_Wait(&req, &stat);
947 const char funcname[] =
"SHalo_swap_all";
974 const char funcname[] =
"SHalo_swap_dir";
976 if(layer!=
DOWN && layer!=
UP){
977 fprintf(stderr,
"Error %i in %s: Cannot swap in the direction given by %i.\nExiting...\n\n",
982 for(
unsigned short icpt=0;icpt<ncpt;icpt++){
984 printf(
"Rank %d: Function %s: dir: %d icpt= %d of %d\n",
rank, funcname, idir, icpt,ncpt);
987 MPI_Request req; MPI_Status stat;
988 float *sendbuff = (
float *)aligned_alloc(
AVX,
halosize[idir]*
sizeof(
float));
992 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
993 "a memory leak on rank %i.\nExiting...\n\n"
998#pragma omp simd aligned(sendbuff,d:AVX)
999 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
1002 if(MPI_Isend(sendbuff,
halosize[idir], MPI_FLOAT,
pd[idir], icpt, comm, &req)){
1003 fprintf(stderr,
"Error %i in %s: Failed to send off the down halo from rank %i to rank %i.\nExiting...\n\n",
1008 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into up halo from rank %i.\nExiting...\n\n",
1015 fprintf(stderr,
"Error %i in %s: Writing a message of size %i to flattened index %i will cause "\
1016 "a memory leak on rank %i.\nExiting...\n\n"
1020#pragma omp simd aligned(sendbuff,d:AVX)
1022 for(
int ihalo = 0; ihalo <
halosize[idir]; ihalo++)
1025 if(MPI_Isend(sendbuff,
halosize[idir], MPI_FLOAT,
pu[idir], icpt, comm, &req)){
1026 fprintf(stderr,
"Error %i in %s: Failed to send off the up halo from rank %i to rank %i.\nExiting...\n\n",
1031 fprintf(stderr,
"Error %i in %s: Rank %i failed to receive into doww halo from rank %i.\nExiting...\n\n",
1037 MPI_Wait(&req, &stat);
1050 const char *funchame =
"Trial_Exchange";
1055 cudaGetDevice(&device);
1058 cudaMallocManaged((
void **)&z,
kvolHalo*
sizeof(
Complex),cudaMemAttachGlobal);
1068 for(
int mu=0;mu<
ndim;mu++){
1116#error Par_tmul is not yet implimented in CUDA as Sigma12 in Polyakov is device only memory
1119 const char funcname[] =
"Par_tmul";
1134 if(!
rank) printf(
"Sending between halos in the time direction. For rank %i pu[3]=%i and pd[3] = %i\n",
1137 for(itime=1;itime<
npt; itime++){
1141 if(!
rank) printf(
"t11 and t12 assigned. Getting ready to send to other processes.\n");
1147 if(MPI_Isend(t11,
kvol3, MPI_C_FLOAT_COMPLEX,
pd[3],
tag, comm, &request)){
1148 fprintf(stderr,
"Error %i in %s: Failed to send t11 to process %i.\nExiting...\n\n",
1153 printf(
"Sent t11 from rank %i to the down halo on rank %i\n",
rank,
pd[3]);
1155 if(MPI_Recv(a11,
kvol3, MPI_C_FLOAT_COMPLEX,
pu[3],
tag, comm, &status)){
1156 fprintf(stderr,
"Error %i in %s: Failed to receive a11 from process %i.\nExiting...\n\n",
1161 printf(
"Received t11 from rank %i in the up halo on rank %i\n",
pu[3],
rank);
1163 MPI_Wait(&request, &status);
1164 if(MPI_Isend(t12,
kvol3, MPI_C_FLOAT_COMPLEX,
pd[3],
tag, comm, &request)){
1165 fprintf(stderr,
"Error %i in %s: Failed to send t12 to process %i.\nExiting...\n\n",
1169 if(MPI_Recv(a12,
kvol3, MPI_C_FLOAT_COMPLEX,
pu[3],
tag, comm, &status)){
1170 fprintf(stderr,
"Error %i in %s: Failed to receive a12 from process %i.\nExiting...\n\n",
1175 printf(
"Finished sending and receiving on rank %i\n",
rank);
1177 MPI_Wait(&request, &status);
1181#pragma omp parallel for simd aligned(a11,a12,t11,t12,z11,z12:AVX)
1182 for(i=0;i<
kvol3;i++){
1183 t11[i]=z11[i]*a11[i]-z12[i]*
conj(a12[i]);
1184 t12[i]=z11[i]*a12[i]+z12[i]*
conj(a11[i]);
1189 free(a11); free(a12); free(t11); free(t12);
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 NO_MPI_SIZE
Failed to get the number of ranks.
#define NUMELEM
Failed to evaluate the number of elements.
#define BROADERR
Couldn't broadcast to the processes.
#define REDUCERR
Couldn't carry out a reduction operation.
#define SIZEPROC
Communicator size does not match expected size.
#define NO_MPI_RANK
Failed to get the rank of the process.
#define LAYERROR
brief Can't access a layer of a halo
#define BOUNDERROR
Accessing out of bounds element.
#define DIFNPROC
Continuation run on different grid size.
#define OPENERROR
Error opening file.
#define CANTRECV
Couldn't receive from another process.
#define CANTSEND
Couldn't send to another process.
#define NO_MPI_INIT
Failed to initialise MPI.
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
__device__ __forceinline__ T conj(const T &z)
Complex Conjugation.
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 CHalo_swap_all(Complex_f *c, int ncpt)
Calls the functions to send data to both the up and down halos.
int Par_fcopy(float *fval)
Broadcasts a float to the other processes.
int ZHalo_swap_all(Complex *z, int ncpt)
Calls the functions to send data to both the up and down halos.
int Par_fsum(float *dval)
Performs a reduction on a float dval to get a sum which is then distributed to all ranks.
int Par_dcopy(double *dval)
Broadcasts a double to the other processes.
int Par_begin(int argc, char *argv[])
Initialises the MPI configuration.
int Par_swrite(const int itraj, const int icheck, const float beta, const float fmu, const float akappa, const Complex_f ajq, const float c_sw, Complex *u11, Complex *u12)
Copies u11 and u12 into arrays without halos which then get written to output.
int Par_isum(int *ival)
Performs a reduction on an integer ival to get a sum which is then distributed to all ranks.
int Par_icopy(int *ival)
Broadcasts an integer to the other processes.
int ZHalo_swap_dir(Complex *z, int ncpt, int idir, int layer)
Swaps the halos along the axis given by idir in the direction given by layer.
int Par_ccopy(Complex *cval)
Broadcasts a complex float to the other processes.
int Par_zcopy(Complex *zval)
Broadcasts a complex double to the other processes.
int DHalo_swap_all(double *d, int ncpt)
Calls the functions to send data to both the up and down halos.
int SHalo_swap_all(float *d, int ncpt)
Calls the functions to send data to both the up and down halos.
int SHalo_swap_dir(float *d, int ncpt, int idir, int layer)
Swaps the halos along the axis given by idir in the direction given by layer.
int CHalo_swap_dir(Complex_f *c, int ncpt, int idir, int layer)
Swaps the halos along the axis given by idir in the direction given by layer.
int Trial_Exchange(Complex *ut[2], Complex_f *ut_f[2])
Exchanges the trial fields.
int Par_csum(Complex_f *cval)
Performs a reduction on a complex float cval to get a sum which is then distributed to all ranks.
int Par_zsum(Complex *zval)
Performs a reduction on a complex double zval to get a sum which is then distributed to all ranks.
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 pu[ndim]
Processors in the up direction.
#define UP
Flag for send up.
#define DOWN
Flag for send down.
int pd[ndim]
Processors in the down direction.
int size
The number of MPI ranks in total.
int pstop[ndim][nproc]
The final lattice site on each sublattice in a given direction.
#define masterproc
The main rank. Used for serial tasks.
int pstart[ndim][nproc]
The initial lattice site on each sublattice in a given direction.
int * pcoord
The processor grid.
#define tag
default MPI tag
unsigned long seed
RANLUX seed.
gsl_rng * ranlux_instd
RANLUX instance.
#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 npx
Processor grid x extent. This must be a divisor of nx.
#define kvol
Sublattice volume.
#define Complex
Double precision complex number.
#define npz
Processor grid z extent.
#define cudaDeviceSynchronise()
Get rid of that bastardised yankee English.
#define gvol
Lattice volume.
#define FILELEN
Default file name length.
#define kvol3
Sublattice spatial volume.
#define halo
Total Halo size.
#define Complex_f
Single precision complex number.
#define ksizez
Sublattice z extent.
#define npy
Processor grid y extent.
#define npt
Processor grid t extent.
#define kvolHalo
Subvolume + halo size.
#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.
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.
#define cimag(z)
Extract Imaginary Component using C standard notation.