int main(int argc,char *argv[]) { FILE *fp; int nnn[] = { 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 }; #define NNN asize(nnn) int *niter; int i,j,n,nit,ntot,n3; double t,nflop; double *rt,*ct; t_complex ***g; real ***h; snew(rt,NNN); snew(ct,NNN); snew(niter,NNN); for(i=0; (i<NNN); i++) { n = nnn[i]; fprintf(stderr,"\rReal %d ",n); if (n < 16) niter[i] = 100; else if (n < 26) niter[i] = 50; else if (n < 51) niter[i] = 10; else niter[i] = 5; nit = niter[i]; h = mk_rgrid(n+2,n,n); start_time(); for(j=0; (j<nit); j++) { testrft(stdout,h,n,n,n,(j==0)); } update_time(); rt[i] = node_time(); free_rgrid(h,n,n); fprintf(stderr,"\rComplex %d ",n); g = mk_cgrid(n,n,n); start_time(); for(j=0; (j<nit); j++) { testfft(stdout,g,n,n,n,(j==0)); } update_time(); ct[i] = node_time(); free_cgrid(g,n,n); } fprintf(stderr,"\n"); fp=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)"); for(i=0; (i<NNN); i++) { n3 = 2*niter[i]*nnn[i]*nnn[i]*nnn[i]; fprintf(fp,"%10d %10g %10g\n",nnn[i],rt[i]/n3,ct[i]/n3); } gmx_fio_fclose(fp); return 0; }
real do_opt_pppm(FILE *log, bool bVerbose, t_inputrec *ir, int natoms, rvec x[], rvec f[], real charge[], rvec box, real phi[], t_commrec *cr, t_nrnb *nrnb, rvec beta, t_fftgrid *grid, bool bOld) { real ***ghat; int nx,ny,nz; real ener; ener = 0.0; fprintf(log,"Generating Ghat function\n"); nx = ir->nkx; ny = ir->nky; nz = ir->nkz; ghat = mk_rgrid(nx,ny,nz); mk_ghat(NULL,nx,ny,nz,ghat,box,ir->rcoulomb_switch,ir->rcoulomb,TRUE,bOld); /* pr_scalar_gk("generghat.xvg",nx,ny,nz,box,ghat); */ /* Now start the actual PPPM procedure. * First step: spreading the charges over the grid. */ /* Make the grid empty */ clear_fftgrid(grid); spread_q(log,bVerbose,0,natoms,x,charge,box,grid,nrnb); /* Second step: solving the poisson equation in Fourier space */ solve_pppm(log,cr,grid,ghat,box,bVerbose,nrnb); /* Third and last step: gather the forces, energies and potential * from the grid. */ ener=gather_f(log,bVerbose,0,natoms,x,f,charge,box,phi,grid,beta,nrnb); free_rgrid(ghat,nx,ny); return ener; }