4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * For more info, check our website at http://www.gromacs.org
34 * GROningen Mixture of Alchemy and Childrens' Stories
46 void testfft(FILE *fp
,t_complex
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
50 static zomplex
*coeff
;
52 static complex *coeff
;
57 real
*gptr
,*fqqq
,fg
,fac
;
58 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
68 fqqq
= &(grid
[0][0][0].re
);
72 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
74 coeff
= zfft3di(nx
,ny
,nz
,NULL
);
76 coeff
= cfft3di(nx
,ny
,nz
,NULL
);
83 zfft3d(1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
85 cfft3d(1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
88 fourn(fqqq
-1,ndim
,3,1);
93 zfft3d(-1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
95 cfft3d(-1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
98 fourn(fqqq
-1,ndim
,3,-1);
102 void testrft(FILE *fp
,real
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
106 static double *coeff
;
113 real
*gptr
,*fqqq
,fg
,fac
;
114 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
124 fqqq
= &(grid
[0][0][0]);
128 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
130 coeff
= dfft3di(nx
,ny
,nz
,NULL
);
132 coeff
= sfft3di(nx
,ny
,nz
,NULL
);
140 dzfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
142 scfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
145 fourn(fqqq
-1,ndim
,3,1);
152 zdfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
154 csfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
157 fourn(fqqq
-1,ndim
,3,-1);
161 int main(int argc
,char *argv
[])
164 int nnn
[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40,
165 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 };
166 #define NNN asize(nnn)
168 int i
,j
,n
,nit
,ntot
,n3
;
178 for(i
=0; (i
<NNN
); i
++) {
180 fprintf(stderr
,"\rReal %d ",n
);
191 h
= mk_rgrid(n
+2,n
,n
);
193 for(j
=0; (j
<nit
); j
++) {
194 testrft(stdout
,h
,n
,n
,n
,(j
==0));
200 fprintf(stderr
,"\rComplex %d ",n
);
203 for(j
=0; (j
<nit
); j
++) {
204 testfft(stdout
,g
,n
,n
,n
,(j
==0));
210 fprintf(stderr
,"\n");
211 fp
=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)");
212 for(i
=0; (i
<NNN
); i
++) {
213 n3
= 2*niter
[i
]*nnn
[i
]*nnn
[i
]*nnn
[i
];
214 fprintf(fp
,"%10d %10g %10g\n",nnn
[i
],rt
[i
]/n3
,ct
[i
]/n3
);