4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_testfft_c
= "$Id$";
41 void testfft(FILE *fp
,t_complex
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
45 static zomplex
*coeff
;
47 static complex *coeff
;
52 real
*gptr
,*fqqq
,fg
,fac
;
53 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
63 fqqq
= &(grid
[0][0][0].re
);
67 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
69 coeff
= zfft3di(nx
,ny
,nz
,NULL
);
71 coeff
= cfft3di(nx
,ny
,nz
,NULL
);
78 zfft3d(1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
80 cfft3d(1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
83 fourn(fqqq
-1,ndim
,3,1);
88 zfft3d(-1,nx
,ny
,nz
,(zomplex
*)cptr
,la1
,la2
,coeff
);
90 cfft3d(-1,nx
,ny
,nz
,(complex *)cptr
,la1
,la2
,coeff
);
93 fourn(fqqq
-1,ndim
,3,-1);
97 void testrft(FILE *fp
,real
***grid
,int nx
,int ny
,int nz
,bool bFirst
)
101 static double *coeff
;
108 real
*gptr
,*fqqq
,fg
,fac
;
109 int ntot
,i
,j
,k
,m
,n
,ndim
[4];
119 fqqq
= &(grid
[0][0][0]);
123 fprintf(fp
,"Going to use SGI optimized FFT routines.\n");
125 coeff
= dfft3di(nx
,ny
,nz
,NULL
);
127 coeff
= sfft3di(nx
,ny
,nz
,NULL
);
135 dzfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
137 scfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
140 fourn(fqqq
-1,ndim
,3,1);
147 zdfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
149 csfft3d(job
,nx
,ny
,nz
,cptr
,la1
,la2
,coeff
);
152 fourn(fqqq
-1,ndim
,3,-1);
156 int main(int argc
,char *argv
[])
159 int nnn
[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40,
160 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 };
161 #define NNN asize(nnn)
163 int i
,j
,n
,nit
,ntot
,n3
;
173 for(i
=0; (i
<NNN
); i
++) {
175 fprintf(stderr
,"\rReal %d ",n
);
186 h
= mk_rgrid(n
+2,n
,n
);
188 for(j
=0; (j
<nit
); j
++) {
189 testrft(stdout
,h
,n
,n
,n
,(j
==0));
195 fprintf(stderr
,"\rComplex %d ",n
);
198 for(j
=0; (j
<nit
); j
++) {
199 testfft(stdout
,g
,n
,n
,n
,(j
==0));
205 fprintf(stderr
,"\n");
206 fp
=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)");
207 for(i
=0; (i
<NNN
); i
++) {
208 n3
= 2*niter
[i
]*nnn
[i
]*nnn
[i
]*nnn
[i
];
209 fprintf(fp
,"%10d %10g %10g\n",nnn
[i
],rt
[i
]/n3
,ct
[i
]/n3
);