24 const char funcname[] =
"Q_allocate";
29 cudaMallocManaged((
void **)x2_f,
kferm2*
sizeof(
Complex_f),cudaMemAttachGlobal);
31 cudaMallocManaged((
void **)r_f,
kferm2*
sizeof(
Complex_f),cudaMemAttachGlobal);
32 cudaMallocManaged((
void **)X1_f,
kferm2*
sizeof(
Complex_f),cudaMemAttachGlobal);
65 const char funcname[] =
"Q_allocate";
68 cudaMallocManaged((
void **)&clover[0], 6*
kvol*
sizeof(
Complex),cudaMemAttachGlobal);
69 cudaMallocManaged((
void **)&clover[1], 6*
kvol*
sizeof(
Complex),cudaMemAttachGlobal);
72 cudaMallocManaged((
void **)x2,
kferm2*
sizeof(
Complex),cudaMemAttachGlobal);
107 cudaMallocManaged((
void **)r_f,
kferm*
sizeof(
Complex_f),cudaMemAttachGlobal);
109 cudaMallocManaged((
void **)x2_f,
kferm*
sizeof(
Complex_f),cudaMemAttachGlobal);
110 cudaMallocManaged((
void **)xi_f,
kferm*
sizeof(
Complex_f),cudaMemAttachGlobal);
143 cudaMallocManaged((
void **)&clover[0], 6*
kvol*
sizeof(
Complex),cudaMemAttachGlobal);
144 cudaMallocManaged((
void **)&clover[1], 6*
kvol*
sizeof(
Complex),cudaMemAttachGlobal);
145 cudaMallocManaged((
void **)p,
kfermHalo*
sizeof(
Complex), cudaMemAttachGlobal);
146 cudaMallocManaged((
void **)r,
kferm*
sizeof(
Complex), cudaMemAttachGlobal);
147 cudaMallocManaged((
void **)x1,
kfermHalo*
sizeof(
Complex), cudaMemAttachGlobal);
148 cudaMallocManaged((
void **)x2,
kferm*
sizeof(
Complex), cudaMemAttachGlobal);
182 const char funcname[] =
"Q_free";
186 cudaFree(*x1_f);cudaFree(*x2_f); cudaFree(*p_f);
187 cudaFree(*r_f); cudaFree(*X1_f);
195 free(*x1_f); free(*x2_f); free(*p_f); free(*r_f);free(*X1_f);
212 const char funcname[] =
"Qree";
216 cudaFree(*x1);cudaFree(*x2); cudaFree(*p);
217 cudaFree(clover[0]); cudaFree(clover[1]);
220 cudaFreeAsync(clover[0],
streams[0]); cudaFreeAsync(clover[1],
streams[1]);
225 free(*x1);free(*x2); free(*p);
226 free(clover[0]); free(clover[1]);
245 cudaFree(*p_f); cudaFree(*r_f);cudaFree(*x1_f); cudaFree(*x2_f); cudaFree(*xi_f);
247 free(*p_f); free(*r_f); free(*x1_f); free(*x2_f); free(*xi_f);
266 cudaFree(clover[0]); cudaFree(clover[1]);
267 cudaFree(*p);cudaFree(*r);cudaFree(*x1); cudaFree(*x2);
269 cudaFreeAsync(clover[0],
streams[0]); cudaFreeAsync(clover[1],
streams[1]);
273 free(*p); free(*r); free(*x1); free(*x2);
274 free(clover[0]); free(clover[1]);
279 unsigned int *iu,
unsigned int *
id,
Complex gamval[20],
Complex_f gamval_f[20],
const unsigned short gamin[16],
280 Complex *sigval,
Complex_f *sigval_f,
unsigned short *sigin,
double *dk[2],
float *dk_f[2],
281 Complex_f jqq,
float akappa,
float c_sw,
int *itercg){
282 const char funcname[] =
"Congradq";
284 const double resid = res*res;
286#warning "CG Debugging"
287 char *endline =
"\n";
289 char *endline =
"\r";
294 const float d_prec=1.0f/256.0f;
297 alignas(16)
const Complex_f fac_f =
conj(jqq)*jqq*akappa*akappa;
300 alignas(16)
double alphan=1;
305 alignas(16)
double betad = 1.0;
alignas(8)
Complex_f alphad=0;
alignas(16)
Complex alpha = 1;
308 Complex_f *p_f, *x1_f, *x2_f, *r_f, *X1_f;
309 Complex *p, *x1, *x2, *clover[2];
325 for(
unsigned short j=0;j<
nc*
ndirac;j++)
341 for(
unsigned int j=0;j<
nc*
ndirac;j++)
349#pragma omp parallel for simd aligned(X1_f,r_f,X1,r:AVX)
350 for(
unsigned int j=0;j<
nc*
ndirac;j++)
355 alignas(16)
double betan=1;
double beta_max=FLT_MAX;
bool do_dp=
true;
356 for(*itercg=0; *itercg<
niterc; (*itercg)++){
360 printf(
"Going to double precision on iteration %d. betan %e\talpha %e.\n",
361 *itercg,betan,
creal(alpha));
364 printf(
"\nGoing to double precision on iteration %d. betan %e\talpha %e.\n",
365 *itercg,betan,
creal(alpha));
378#pragma omp parallel for simd collapse(2) aligned(X1,X1_f:AVX)
379 for(
unsigned short j=0;j<
nc*
ndirac;j++)
380 for(
unsigned int i=0;i<
kvol;i++){
385 Hdslash(x1,X1,ud,iu,
id,gamval,gamin,dk,akappa);
387 HbyClover(x1,X1,clover,sigval,akappa,sigin,
false);
388 Hdslashd(x2,x1,ud,iu,
id,gamval,gamin,dk,akappa);
390 HbyClover(x2,x1,clover,sigval,akappa,sigin,
true);
394 alignas(16)
Complex m_one=-1.0;
395 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&m_one,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)r,1);
399 for(
unsigned short j=0;j<
nc*
ndirac;j++)
402 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&m_fac,(cuDoubleComplex *)X1,1,(cuDoubleComplex *)r,1);
406 const double fac_d=crealf(fac_f);
407#pragma omp parallel for simd collapse(2)
408 for(
unsigned short j=0;j<
nc*
ndirac;j++)
409 for(
unsigned int i=0;i<
kvol;i++)
415 Hdslash(x1,p,ud,iu,
id,gamval,gamin,dk,akappa);
418 HbyClover(x1,p,clover,sigval,akappa,sigin,
false);
419 Hdslashd(x2,x1,ud,iu,
id,gamval,gamin,dk,akappa);
422 HbyClover(x2,x1,clover,sigval,akappa,sigin,
true);
431 for(
unsigned short j=0;j<
nc*
ndirac;j++)
435 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&fac,(cuDoubleComplex *)p,1,(cuDoubleComplex *)x2,1);
437#elif defined USE_BLAS
438 for(
unsigned short j=0;j<
nc*
ndirac;j++)
441#pragma omp parallel for simd collapse(2) aligned(p,x2:AVX)
442 for(
unsigned short j=0;j<
nc*
ndirac;j++)
443 for(
unsigned int i=0; i<
kvol; i++)
453 for(
unsigned short j=0;j<
nc*
ndirac;j++){
459 cublasZdotc(
cublas_handle,
kferm2,(cuDoubleComplex *)p,1,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)&alpha);
461#elif defined USE_BLAS
462 for(
unsigned short j=0;j<
nc*
ndirac;j++){
465 alpha+=
creal(alpha_t);
468#pragma omp parallel for simd collapse(2) aligned(p,x2:AVX) reduction(+:alpha)
469 for(
unsigned short j=0;j<
nc*
ndirac;j++)
470 for(
unsigned int i=0; i<
kvol; i++)
479 alpha=alphan/
creal(alpha);
483 for(
unsigned short j=0;j<
nc*
ndirac;j++)
486 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&alpha,(cuDoubleComplex *)p,1,(cuDoubleComplex *)X1,1);
488#elif defined USE_BLAS
489 for(
unsigned short j=0;j<
nc*
ndirac;j++)
492#pragma omp parallel for simd collapse(2) aligned(p,X1:AVX)
493 for(
unsigned short j=0;j<
nc*
ndirac;j++)
494 for(
unsigned int i=0; i<
kvol; i++)
501 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&alpha_m,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)r,1);
502 alignas(16)
double betan_d;
504 betan=betan_d*betan_d;
505#elif defined USE_BLAS
507 cblas_zaxpy(
kferm2, &alpha_m, x2, 1, r, 1);
509 double betan_d = cblas_dznrm2(
kferm2, r,1);
511 betan = betan_d*betan_d;
514#pragma omp parallel for simd aligned(r_f,x2_f:AVX) reduction(+:betan)
515 for(
unsigned int i=0; i<
kferm2; i++){
517 betan +=
conj(r[i])*r[i];
519 alignas(16)
double betan_d=sqrt(betan);
529 if(!
rank) printf(
"DP Iter(CG)=%i\tbeta_n=%e\talpha=%e\n", *itercg, betan,
creal(alpha));
532 alignas(16)
const Complex beta = (*itercg) ? betan/betad : 0;
533 betad=betan; alphan=betan;
539 for(
unsigned short j=0;j<
nc*
ndirac;j++){
546 cublasZaxpy(
cublas_handle,
kferm2,(cuDoubleComplex *)&alpha_m,(cuDoubleComplex *)r,1,(cuDoubleComplex *)p,1);
548#elif (defined __USE_MKL__||defined OPENBLAS||defined AMD_BLAS)
553 for(
unsigned short j=0;j<
nc*
ndirac;j++)
558 for(
unsigned short j=0;j<
nc*
ndirac;j++){
564#pragma omp parallel for simd collapse(2) aligned(r,p:AVX)
565 for(
unsigned short j=0;j<
nc*
ndirac;j++)
566 for(
unsigned int i=0; i<
kvol; i++)
572 if(!
rank) printf(
"Double precision. Iter(CG)=%i\tbeta_n=%e\talpha=%e\n", *itercg, betan,
creal(alpha));
578 if(!
rank) printf(
"\nIter(CG)=%i\tResidue: %e\tTolerance: %e\n", *itercg, betan, resid);
588 Hdslash_f(x1_f,p_f,ut,iu,
id,gamval_f,gamin,dk_f,akappa);
591 HbyClover_f(x1_f,p_f,clover_f,sigval_f,akappa,sigin,
false);
592 Hdslashd_f(x2_f,x1_f,ut,iu,
id,gamval_f,gamin,dk_f,akappa);
595 HbyClover_f(x2_f,x1_f,clover_f,sigval_f,akappa,sigin,
true);
605 for(
unsigned short j=0;j<
nc*
ndirac;j++)
609 cublasCaxpy(
cublas_handle,
kferm2,(cuComplex *)&fac_f,(cuComplex *)p_f,1,(cuComplex *)x2_f,1);
611#elif defined USE_BLAS
612 for(
unsigned short j=0;j<
nc*
ndirac;j++)
615#pragma omp parallel for simd collapse(2) aligned(p_f,x2_f:AVX)
616 for(
unsigned short j=0;j<
nc*
ndirac;j++)
617 for(
unsigned int i=0; i<
kvol; i++)
627 for(
unsigned short j=0;j<
nc*
ndirac;j++){
633 cublasCdotc(
cublas_handle,
kferm2,(cuComplex *)p_f,1,(cuComplex *)x2_f,1,(cuComplex *)&alphad);
635#elif defined USE_BLAS
636 for(
unsigned short j=0;j<
nc*
ndirac;j++){
639 alphad+=
creal(alpha_t);
642#pragma omp parallel for simd aligned(p_f,x2_f:AVX) reduction(alphad:+)
643 for(
unsigned short j=0;j<
nc*
ndirac;j++)
644 for(
unsigned int i=0; i<
kvol; i++)
653 alpha=alphan/
creal(alphad);
658 for(
unsigned short j=0;j<
nc*
ndirac;j++)
661 cublasCaxpy(
cublas_handle,
kferm2,(cuComplex *)&alpha_f,(cuComplex *)p_f,1,(cuComplex *)X1_f,1);
663#elif defined USE_BLAS
665 for(
unsigned short j=0;j<
nc*
ndirac;j++)
668#pragma omp parallel for simd collapse(2) aligned(X1_f,p_f:AVX)
669 for(
unsigned short j=0;j<
nc*
ndirac;j++)
670 for(
unsigned int i=0; i<
kvol; i++)
678 cublasCaxpy(
cublas_handle,
kferm2,(cuComplex *)&alpha_m,(cuComplex *)x2_f,1,(cuComplex *)r_f,1);
679 alignas(8)
float betan_f;
681 betan = betan_f*betan_f;
682#elif defined USE_BLAS
684 cblas_caxpy(
kferm2, &alpha_m, x2_f, 1, r_f, 1);
686 float betan_f = cblas_scnrm2(
kferm2, r_f,1);
688 betan = betan_f*betan_f;
691#pragma omp parallel for simd aligned(r_f,x2_f:AVX) reduction(+:betan)
692 for(
unsigned int i=0; i<
kferm2; i++){
693 r_f[i]-=alpha*x2_f[i];
694 betan +=
conj(r_f[i])*r_f[i];
696 alignas(8)
float betan_f=sqrt(betan);
704 beta_max = (betan_f>beta_max) ?betan_f : beta_max;
707 if(!
rank) printf(
"Iter(CG)=%i\tbeta_n=%e\talpha=%e%s", *itercg, betan,
creal(alpha),endline);
710 if(betan_f<beta_max*d_prec){
713 printf(
"\nResidue %e is less than %e times %e.%s",betan_f,d_prec,beta_max,endline);
717 else if(betan<resid){
720 printf(
"\nBetan %e is less than target residue %e.\n",betan,resid);
725 else if(*itercg==
niterc-1){
726 if(!
rank) fprintf(stderr,
"\nWarning %i in %s: Exceeded iteration limit %i beta_n=%e\n",\
727 ITERLIM, funcname, *itercg, betan);
733 Complex beta = (*itercg) ? betan/betad : 0;
734 betad=betan; alphan=betan;
741 for(
unsigned short j=0;j<
nc*
ndirac;j++){
747 cublasCaxpy(
cublas_handle,
kferm2,(cuComplex *)&alpha_m,(cuComplex *)r_f,1,(cuComplex *)p_f,1);
749#elif (defined __USE_MKL__||defined OPENBLAS||defined AMD_BLAS)
754 for(
unsigned short j=0;j<
nc*
ndirac;j++)
756#elif defined USE_BLAS
759 for(
unsigned short j=0;j<
nc*
ndirac;j++){
764#pragma omp parallel for simd collapse(2) aligned(p_f,r_f:AVX)
765 for(
unsigned short j=0;j<
nc*
ndirac;j++)
766 for(
unsigned int i=0; i<
kvol; i++)
771 Q_free_f(&p_f,&x1_f,&x2_f,&r_f,&X1_f);
772 Q_free(&p,&x1,&x2,clover);
781 unsigned int *iu,
unsigned int *
id,
Complex gamval[20],
Complex_f gamval_f[20],
const unsigned short gamin[16],
782 Complex *sigval,
Complex_f *sigval_f,
unsigned short *sigin,
double *dk[2],
float *dk_f[2],
783 Complex_f jqq,
float akappa,
float c_sw,
int *itercg){
784 const char funcname[] =
"Congradp";
787 const double resid = res*res;
789#warning "CG Debugging"
790 char *endline =
"\n";
792 char *endline =
"\r";
797 const float d_prec=1.0f/256.0f;
800 alignas(8)
double alphan=1.0;
804 alignas(8)
double betad = 1.0;
alignas(8)
Complex_f alphad=0;
alignas(16)
Complex alpha = 1;
806 Complex_f *p_f, *r_f, *x1_f, *x2_f, *xi_f;
823 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
835 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
841 double betan=1;
double beta_max=FLT_MAX;
bool do_dp=
true;
842 for((*itercg)=0; (*itercg)<
niterc; (*itercg)++){
847 printf(
"Going to double precision on iteration %d. %sbetan %e\talpha %e. %s",
848 *itercg,endline,betan,
creal(alpha),endline);
851 printf(
"\nGoing to double precision on iteration %d. %sbetan %e\talpha %e.\n",
852 *itercg,endline,betan,
creal(alpha));
865#pragma omp parallel for simd aligned(xi,xi_f:AVX)
866 for(
unsigned int i=0;i<
kferm;i++)
885 Dslash(x1,xh,ud,iu,
id,gamval,gamin,dk,jqq,akappa);
887 ByClover(x1,xh,clover,sigval,akappa,sigin,
false);
888 Dslashd(x2,x1,ud,iu,
id,gamval,gamin,dk,jqq,akappa);
890 ByClover(x2,x1,clover,sigval,akappa,sigin,
true);
897 alignas(16)
Complex m_one=-1.0;
898 cublasZaxpy(
cublas_handle,
kferm,(cuDoubleComplex *)&m_one,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)r,1);
903#pragma omp parallel for simd
904 for(
unsigned int i=0;i<
kferm;i++)
905 r[i]=Phi[i+na*
kferm]-x2[i];
910 Dslash(x1,p,ud,iu,
id,gamval,gamin,dk,jqq,akappa);
912 ByClover(x1,p,clover,sigval,akappa,sigin,
false);
913 Dslashd(x2,x1,ud,iu,
id,gamval,gamin,dk,jqq,akappa);
915 ByClover(x2,x1,clover,sigval,akappa,sigin,
true);
925 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
931 cublasZdotc(
cublas_handle,
kferm,(cuDoubleComplex *)p,1,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)&alpha);
933#elif defined USE_BLAS
934 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
940#pragma omp parallel for simd collapse(2) aligned(p,x2:AVX) reduction(+:alpha)
942 for(
unsigned int i=0; i<
kvol; i++)
951 alpha=alphan/
creal(alpha);
958 cublasZaxpy(
cublas_handle,
kferm,(cuDoubleComplex *)&alpha,(cuDoubleComplex *)p,1,(cuDoubleComplex *)xi,1);
960#elif defined USE_BLAS
964#pragma omp parallel for simd collapse(2) aligned(p,xi:AVX)
966 for(
unsigned int i=0; i<
kvol; i++)
973 cublasZaxpy(
cublas_handle,
kferm,(cuDoubleComplex *)&alpha_m,(cuDoubleComplex *)x2,1,(cuDoubleComplex *)r,1);
976 betan=betan_d*betan_d;
977#elif defined USE_BLAS
979 cblas_zaxpy(
kferm, &alpha_m, x2, 1, r, 1);
981 double betan_d = cblas_dznrm2(
kferm, r,1);
983 betan = betan_d*betan_d;
986#pragma omp parallel for simd aligned(r,x2:AVX) reduction(+:betan)
987 for(
unsigned int i=0; i<
kferm; i++){
989 betan +=
conj(r[i])*r[i];
991 double betan_d=sqrt(betan);
1001 if(!
rank) printf(
"DP Iter(CG)=%i\tbeta_n=%e\talpha=%e\n", *itercg, betan,
creal(alpha));
1004 alignas(16)
const Complex beta = (*itercg) ? betan/betad : 0;
1005 betad=betan; alphan=betan;
1010 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1016 cublasZaxpy(
cublas_handle,
kferm,(cuDoubleComplex *)&alpha_m,(cuDoubleComplex *)r,1,(cuDoubleComplex *)p,1);
1019#elif (defined __USE_MKL__||defined OPENBLAS||defined AMD_BLAS)
1024 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1026#elif defined USE_BLAS
1029 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1035#pragma omp parallel for simd collapse(2) aligned(r,p:AVX)
1036 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1037 for(
unsigned int i=0; i<
kvol; i++)
1043 if(!
rank) printf(
"Double precision. Iter(CG)=%i\tbeta_n=%e\talpha=%e\n", *itercg, betan,
creal(alpha));
1049 if(!
rank) printf(
"\nIter(CG)=%i\tResidue: %e\tTolerance: %e\n", *itercg, betan, resid);
1058 Dslash_f(x1_f,p_f,ut,iu,
id,gamval_f,gamin,dk_f,jqq,akappa);
1060 ByClover_f(x1_f,p_f,clover_f,sigval_f,akappa,sigin,
false);
1061 Dslashd_f(x2_f,x1_f,ut,iu,
id,gamval_f,gamin,dk_f,jqq,akappa);
1063 ByClover_f(x2_f,x1_f,clover_f,sigval_f,akappa,sigin,
true);
1073 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1079 cublasCdotc(
cublas_handle,
kferm,(cuComplex *)p_f,1,(cuComplex *)x2_f,1,(cuComplex *)&alphad);
1082 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1088#pragma omp parallel for simd collapse(2) aligned(p_f,x2_f:AVX) reduction(+:alphad)
1089 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1090 for(
unsigned int i = 0; i<
kvol; i++)
1097 alpha=alphan/
creal(alphad);
1101 alignas(8)
Complex_f alpha_f=(
float)alpha;
1104 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1107 cublasCaxpy(
cublas_handle,
kferm,(cuComplex*) &alpha_f,(cuComplex*) p_f,1,(cuComplex*) xi_f,1);
1110 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1114#pragma omp parallel for simd collapse(2) aligned(xi_f,p_f:AVX)
1115 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1116 for(
unsigned int i = 0; i<
kvol; i++)
1122 alignas(8)
float betan_f=0;
1126 cublasCaxpy(
cublas_handle,
kferm, (cuComplex *)&alpha_m,(cuComplex *) x2_f, 1,(cuComplex *) r_f, 1);
1136 betan=betan_f*betan_f;
1142#pragma omp parallel for simd aligned(x2_f,r_f:AVX) reduction(+:betan)
1143 for(
unsigned int i = 0; i<
kferm;i++){
1144 r_f[i]-=alpha*x2_f[i];
1145 betan+=
conj(r_f[i])*r_f[i];
1147 betan_f=sqrt(betan);
1154 betan_f=sqrt(betan);
1155 beta_max = (betan_f>beta_max) ?betan_f : beta_max;
1157 if(!
rank) printf(
"Iter (CG) = %i beta_n= %e alpha= %e%s", *itercg, betan,
creal(alpha),endline);
1159 if(betan_f<beta_max*d_prec){
1162 printf(
"Residue %e is less than %e times %e. %s",betan_f,d_prec,beta_max,endline);
1166 else if(betan<resid){
1170 if(!
rank) printf(
"\nIter (CG) = %i resid = %e toler = %e\n", *itercg, betan, resid);
1175 else if(*itercg==
niterc-1){
1176 if(!
rank) fprintf(stderr,
"Warning %i in %s: Exceeded iteration limit %i beta_n=%e\n",
1181 alignas(8)
Complex beta = (*itercg) ? betan/betad : 0;
1182 betad=betan; alphan=betan;
1191 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1197 cublasCaxpy(
cublas_handle,
kferm,(cuComplex *)&a,(cuComplex *)r_f,1,(cuComplex *)p_f,1);
1200#elif (defined __USE_MKL__||defined OPENBLAS||defined AMD_BLAS)
1201 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1204 for(
unsigned short j=0;j<
nc*
ngorkov;j++){
1210#pragma omp parallel for simd aligned(r_f,p_f:AVX)
1211 for(
unsigned short j=0;j<
nc*
ngorkov;j++)
1212 for(
unsigned int i=0; i<
kvol; i++)
1220 P_free_f(&p_f,&r_f,&x1_f,&x2_f,&xi_f);
1221 P_free(&p,&r,&x1,&x2,clover);
Routines needed for Clover improved wilson fermions.
#define ITERLIM
Exceeded max number of iterations.
void HbyClover(Complex *phi, Complex *r, Complex *clover[2], Complex *sigval, const float akappa, unsigned short *sigin, bool dag)
Clover analogue of the Dslash operation. This version acts on all flavours similar to Dslash and Dsla...
void ByClover(Complex *phi, Complex *r, Complex *clover[2], Complex *sigval, const float akappa, unsigned short *sigin, bool dag)
Clover analogue of the Dslash operation. This version acts on all flavours similar to Dslash and Dsla...
void ByClover_f(Complex_f *phi, Complex_f *r, Complex_f *clover[2], Complex_f *sigval, const float akappa, unsigned short *sigin, bool dag)
Clover analogue of the Dslash operation. This version acts on all flavours similar to Dslash and Dsla...
void HbyClover_f(Complex_f *phi, Complex_f *r, Complex_f *clover[2], Complex_f *sigval, const float akappa, unsigned short *sigin, bool dag)
Clover analogue of the Dslash operation. This version acts on all flavours similar to Dslash and Dsla...
int Dslash_f(Complex_f *phi, Complex_f *r, Complex_f *ut[nc], unsigned int *iu, unsigned int *id, Complex_f gamval[20], const unsigned short gamin[16], float *dk[nc], Complex_f jqq, float akappa)
Evaluates in single precision.
int Dslashd_f(Complex_f *phi, Complex_f *r, Complex_f *ut[nc], unsigned int *iu, unsigned int *id, Complex_f gamval[20], const unsigned short gamin[16], float *dk[nc], Complex_f jqq, float akappa)
Evaluates in single precision.
int Hdslashd_f(Complex_f *phi, Complex_f *r, Complex_f *ut[nc], unsigned int *iu, unsigned int *id, Complex_f gamval[20], const unsigned short gamin[16], float *dk[nc], float akappa)
Evaluates in single precision.
int Hdslashd(Complex *phi, Complex *r, Complex *ut[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], const unsigned short gamin[16], double *dk[nc], float akappa)
Evaluates in double precision.
int Hdslash(Complex *phi, Complex *r, Complex *ut[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], const unsigned short gamin[16], double *dk[nc], float akappa)
Evaluates in double precision.
int Dslashd(Complex *phi, Complex *r, Complex *ut[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], const unsigned short gamin[16], double *dk[nc], Complex_f jqq, float akappa)
Evaluates in double precision.
int Hdslash_f(Complex_f *phi, Complex_f *r, Complex_f *ut[nc], unsigned int *iu, unsigned int *id, Complex_f gamval[20], const unsigned short gamin[16], float *dk[nc], float akappa)
Evaluates in single precision.
int Dslash(Complex *phi, Complex *r, Complex *ut[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], const unsigned short gamin[16], double *dk[nc], Complex_f jqq, float akappa)
Evaluates in double precision.
void Q_allocate_f(Complex_f **p_f, Complex_f **x1_f, Complex_f **x2_f, Complex_f **r_f, Complex_f **X1_f)
Allocates memory needed for Congradq. Just to improve readability Note that since C does not modify i...
void Q_allocate(Complex **p, Complex **x1, Complex **x2, Complex *clover[2])
Allocates double precision memory needed for Congradq. Just to improve readability Note that since C ...
void P_allocate(Complex **p, Complex **r, Complex **x1, Complex **x2, Complex *clover[2])
Allocates double precision memory needed for Congradp. Just to improve readability Note that since C ...
void Q_free(Complex **p, Complex **x1, Complex **x2, Complex *clover[2])
Frees double precision memory needed for Congradq. Just to improve readability Note that since C does...
void P_free(Complex **p, Complex **r, Complex **x1, Complex **x2, Complex *clover[2])
Frees memory needed for Congradp. Just to improve readability Note that since C does not modify it's ...
void Q_free_f(Complex_f **p_f, Complex_f **x1_f, Complex_f **x2_f, Complex_f **r_f, Complex_f **X1_f)
Frees memory needed for Congradq. Just to improve readability Note that since C does not modify it's ...
void P_allocate_f(Complex_f **p_f, Complex_f **r_f, Complex_f **x1_f, Complex_f **x2_f, Complex_f **xi_f)
Allocates memory needed for Congradp. Just to improve readability Note that since C does not modify i...
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.
void cuMixed_Sumto(double *d, float *f, const unsigned int n, const dim3 dimGrid, const dim3 dimBlock)
Add a single to a double value, and save the output in the double array For complex valued arrays,...
void P_free_f(Complex_f **p_f, Complex_f **r_f, Complex_f **x1_f, Complex_f **x2_f, Complex_f **xi_f)
Frees memory needed for Congradp. Just to improve readability Note that since C does not modify it's ...
int Congradp(int na, double res, Complex *Phi, Complex *xi, Complex *ud[2], Complex_f *ut[2], Complex_f *clover_f[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, double *dk[2], float *dk_f[2], Complex_f jqq, float akappa, float c_sw, int *itercg)
Matrix Inversion via Conjugate Gradient (no up/down flavour partitioning). Solves The matrix multipl...
int Congradq(int na, double res, Complex *X1, Complex *r, Complex *ud[2], Complex_f *ut[2], Complex_f *clover_f[nc], unsigned int *iu, unsigned int *id, Complex gamval[20], Complex_f gamval_f[20], const unsigned short gamin[16], Complex *sigval, Complex_f *sigval_f, unsigned short *sigin, double *dk[2], float *dk_f[2], Complex_f jqq, float akappa, float c_sw, int *itercg)
Matrix Inversion via Conjugate Gradient (up/down flavour partitioning). Solves Implements up/down pa...
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_dsum(double *dval)
Performs a reduction on a double dval to get a sum which is then distributed to all ranks.
Matrix multiplication and related declarations.
#define AVX
Alignment of arrays. 64 for AVX-512, 32 for AVX/AVX2. 16 for SSE. Since AVX is standard on modern x86...
#define ngorkov
Gor'kov indices.
#define kferm2Halo
Dirac lattice and halo.
#define niterc
Hard limit for runaway trajectories in Conjugate gradient.
#define kvol
Sublattice volume.
#define Complex
Double precision complex number.
#define kferm
sublattice size including Gor'kov indices
#define ndirac
Dirac indices.
#define cudaDeviceSynchronise()
Get rid of that bastardised yankee English.
cublasHandle_t cublas_handle
Handle for cuBLAS.
#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 kferm2
sublattice size including Dirac indices
#define kvolHalo
Subvolume + halo size.
#define kfermHalo
Gor'kov lattice and halo.
dim3 dimBlock
Default block size. Usually 128.
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.