2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
48 void testfft(FILE *fp,t_complex ***grid,int nx,int ny,int nz,gmx_bool bFirst)
52 static zomplex *coeff;
54 static complex *coeff;
59 real *gptr,*fqqq,fg,fac;
60 int ntot,i,j,k,m,n,ndim[4];
70 fqqq = &(grid[0][0][0].re);
74 fprintf(fp,"Going to use SGI optimized FFT routines.\n");
76 coeff = zfft3di(nx,ny,nz,NULL);
78 coeff = cfft3di(nx,ny,nz,NULL);
85 zfft3d(1,nx,ny,nz,(zomplex *)cptr,la1,la2,coeff);
87 cfft3d(1,nx,ny,nz,(complex *)cptr,la1,la2,coeff);
90 fourn(fqqq-1,ndim,3,1);
95 zfft3d(-1,nx,ny,nz,(zomplex *)cptr,la1,la2,coeff);
97 cfft3d(-1,nx,ny,nz,(complex *)cptr,la1,la2,coeff);
100 fourn(fqqq-1,ndim,3,-1);
104 void testrft(FILE *fp,real ***grid,int nx,int ny,int nz,gmx_bool bFirst)
108 static double *coeff;
115 real *gptr,*fqqq,fg,fac;
116 int ntot,i,j,k,m,n,ndim[4];
126 fqqq = &(grid[0][0][0]);
130 fprintf(fp,"Going to use SGI optimized FFT routines.\n");
132 coeff = dfft3di(nx,ny,nz,NULL);
134 coeff = sfft3di(nx,ny,nz,NULL);
142 dzfft3d(job,nx,ny,nz,cptr,la1,la2,coeff);
144 scfft3d(job,nx,ny,nz,cptr,la1,la2,coeff);
147 fourn(fqqq-1,ndim,3,1);
154 zdfft3d(job,nx,ny,nz,cptr,la1,la2,coeff);
156 csfft3d(job,nx,ny,nz,cptr,la1,la2,coeff);
159 fourn(fqqq-1,ndim,3,-1);
163 int main(int argc,char *argv[])
166 int nnn[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40,
167 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 };
168 #define NNN asize(nnn)
170 int i,j,n,nit,ntot,n3;
180 for(i=0; (i<NNN); i++) {
182 fprintf(stderr,"\rReal %d ",n);
193 h = mk_rgrid(n+2,n,n);
195 for(j=0; (j<nit); j++) {
196 testrft(stdout,h,n,n,n,(j==0));
202 fprintf(stderr,"\rComplex %d ",n);
205 for(j=0; (j<nit); j++) {
206 testfft(stdout,g,n,n,n,(j==0));
212 fprintf(stderr,"\n");
213 fp=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)");
214 for(i=0; (i<NNN); i++) {
215 n3 = 2*niter[i]*nnn[i]*nnn[i]*nnn[i];
216 fprintf(fp,"%10d %10g %10g\n",nnn[i],rt[i]/n3,ct[i]/n3);