3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * GROningen Mixture of Alchemy and Childrens' Stories
45 void testfft(FILE *fp
,t_complex
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
49 static zomplex
*coeff
;
51 static complex *coeff
;
56 real
*gptr
,*fqqq
,fg
,fac
;
57 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
67 fqqq
= &(grid
[0][0][0].re
);
71 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
73 coeff
= zfft3di(nx
,ny
,nz
,NULL
);
75 coeff
= cfft3di(nx
,ny
,nz
,NULL
);
82 zfft3d(1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
84 cfft3d(1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
87 fourn(fqqq
-1,ndim
,3,1);
92 zfft3d(-1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
94 cfft3d(-1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
97 fourn(fqqq
-1,ndim
,3,-1);
101 void testrft(FILE *fp
,real
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
105 static double *coeff
;
112 real
*gptr
,*fqqq
,fg
,fac
;
113 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
123 fqqq
= &(grid
[0][0][0]);
127 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
129 coeff
= dfft3di(nx
,ny
,nz
,NULL
);
131 coeff
= sfft3di(nx
,ny
,nz
,NULL
);
139 dzfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
141 scfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
144 fourn(fqqq
-1,ndim
,3,1);
151 zdfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
153 csfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
156 fourn(fqqq
-1,ndim
,3,-1);
160 int main(int argc
,char *argv
[])
163 int nnn
[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40,
164 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 };
165 #define NNN asize(nnn)
167 int i
,j
,n
,nit
,ntot
,n3
;
177 for(i
=0; (i
<NNN
); i
++) {
179 fprintf(stderr
,"\rReal %d ",n
);
190 h
= mk_rgrid(n
+2,n
,n
);
192 for(j
=0; (j
<nit
); j
++) {
193 testrft(stdout
,h
,n
,n
,n
,(j
==0));
199 fprintf(stderr
,"\rComplex %d ",n
);
202 for(j
=0; (j
<nit
); j
++) {
203 testfft(stdout
,g
,n
,n
,n
,(j
==0));
209 fprintf(stderr
,"\n");
210 fp
=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)");
211 for(i
=0; (i
<NNN
); i
++) {
212 n3
= 2*niter
[i
]*nnn
[i
]*nnn
[i
]*nnn
[i
];
213 fprintf(fp
,"%10d %10g %10g\n",nnn
[i
],rt
[i
]/n3
,ct
[i
]/n3
);