void solve_pppm(FILE *fp,t_commrec *cr, t_fftgrid *grid,real ***ghat,rvec box, bool bVerbose,t_nrnb *nrnb) { int ntot,npppm; /* if (bVerbose) print_fftgrid(fp,"Q-Real",grid,grid->nxyz,"qreal.pdb",box,TRUE);*/ gmxfft3D(grid,FFTW_FORWARD,cr); /* if (bVerbose) { print_fftgrid(fp,"Q-k",grid,1.0,"qk-re.pdb",box,TRUE); print_fftgrid(fp,"Q-k",grid,1.0,"qk-im.pdb",box,FALSE); fprintf(stderr,"Doing convolution\n"); }*/ convolution(fp,bVerbose,grid,ghat,cr); if (bVerbose) /* print_fftgrid(fp,"Convolution",grid,1.0, "convolute.pdb",box,TRUE);*/ gmxfft3D(grid,FFTW_BACKWARD,cr); /* if (bVerbose) print_fftgrid(fp,"Potential",grid,1.0,"pot.pdb",box,TRUE);*/ ntot = grid->nxyz; npppm = ntot*log((real)ntot)/log(2.0); inc_nrnb(nrnb,eNR_FFT,2*npppm); inc_nrnb(nrnb,eNR_CONV,ntot); }
int main(int argc,char *argv[]) { int mmm[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 }; int nnn[] = { 24, 32, 48, 60, 72, 84, 96 }; #define NNN asize(nnn) FILE *fp,*fplog; int *niter; int i,j,n,nit,ntot,n3,rsize; double t,nflop,start; double *rt,*ct; t_fftgrid *g; t_commrec *cr; static gmx_bool bReproducible = FALSE; static int nnode = 1; static int nitfac = 1; t_pargs pa[] = { { "-reproducible", FALSE, etBOOL, {&bReproducible}, "Request binary reproducible results" }, { "-np", FALSE, etINT, {&nnode}, "Number of NODEs" }, { "-itfac", FALSE, etINT, {&nitfac}, "Multiply number of iterations by this" } }; static t_filenm fnm[] = { { efLOG, "-g", "fft", ffWRITE }, { efXVG, "-o", "fft", ffWRITE } }; #define NFILE asize(fnm) cr = init_par(&argc,&argv); if (MASTER(cr)) CopyRight(stdout,argv[0]); parse_common_args(&argc,argv, PCA_CAN_SET_DEFFNM | (MASTER(cr) ? 0 : PCA_QUIET), NFILE,fnm,asize(pa),pa,0,NULL,0,NULL); gmx_log_open(ftp2fn(efLOG,NFILE,fnm),cr,1,0,&fplog); snew(niter,NNN); snew(ct,NNN); snew(rt,NNN); rsize = sizeof(real); for(i=0; (i<NNN); i++) { n = nnn[i]; if (n < 16) niter[i] = 50; else if (n < 26) niter[i] = 20; else if (n < 51) niter[i] = 10; else niter[i] = 5; niter[i] *= nitfac; nit = niter[i]; if (MASTER(cr)) fprintf(stderr,"\r3D FFT (%s precision) %3d^3, niter %3d ", (rsize == 8) ? "Double" : "Single",n,nit); g = mk_fftgrid(n,n,n,NULL,NULL,cr,bReproducible); if (PAR(cr)) start = time(NULL); else start_time(); for(j=0; (j<nit); j++) { gmxfft3D(g,GMX_FFT_REAL_TO_COMPLEX,cr); gmxfft3D(g,GMX_FFT_COMPLEX_TO_REAL,cr); } if (PAR(cr)) rt[i] = time(NULL)-start; else { update_time(); rt[i] = node_time(); } done_fftgrid(g); sfree(g); } if (MASTER(cr)) { fprintf(stderr,"\n"); fp=xvgropen(ftp2fn(efXVG,NFILE,fnm), "FFT timings","n^3","t (s)"); for(i=0; (i<NNN); i++) { n3 = 2*niter[i]*nnn[i]*nnn[i]*nnn[i]; fprintf(fp,"%10d %10g\n",nnn[i],rt[i]/(2*niter[i])); } gmx_fio_fclose(fp); } return 0; }