Commit 71b7796d by Francois Gygi

Added single transform test


git-svn-id: http://qboxcode.org/svn/qb/trunk@236 cba15fb0-1239-40c8-b417-11db7ca47a34
parent c998b955
......@@ -20,25 +20,25 @@ extern "C" {
int main(int argc, char**argv)
{
const int niter = 10;
const int np2_ = atoi(argv[1]);
const int nvec_ = atoi(argv[2]);
const int ldz = np2_ + 1;
const int np = atoi(argv[1]);
const int nvec = atoi(argv[2]);
const int ldz = np + 1;
fftw_plan fwplan2, bwplan2;
fftw_plan fwplan, bwplan;
// resize array zvec holding columns
valarray<complex<double> > zvec_(nvec_ * ldz);
valarray<complex<double> > zvec(nvec * ldz);
// initialization of FFT libs
#if FFTWMEASURE
// FFTWMEASURE
fwplan2 = fftw_create_plan(np2_,FFTW_FORWARD,FFTW_MEASURE|FFTW_IN_PLACE);
bwplan2 = fftw_create_plan(np2_,FFTW_BACKWARD,FFTW_MEASURE|FFTW_IN_PLACE);
fwplan = fftw_create_plan(np,FFTW_FORWARD,FFTW_MEASURE|FFTW_IN_PLACE);
bwplan = fftw_create_plan(np,FFTW_BACKWARD,FFTW_MEASURE|FFTW_IN_PLACE);
#else
// FFTW_ESTIMATE
fwplan2 = fftw_create_plan(np2_,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_IN_PLACE);
bwplan2 = fftw_create_plan(np2_,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_IN_PLACE);
fwplan = fftw_create_plan(np,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_IN_PLACE);
bwplan = fftw_create_plan(np,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_IN_PLACE);
#endif
Timer t_fwd,t_bwd;
......@@ -52,10 +52,10 @@ int main(int argc, char**argv)
* FFTW_COMPLEX *in, int istride, int idist,
* FFTW_COMPLEX *out, int ostride, int odist);
*/
int ntrans = nvec_;
int ntrans = nvec;
int inc1 = 1;
int inc2 = ldz;
fftw(bwplan2,ntrans,(FFTW_COMPLEX*)&zvec_[0],inc1,inc2,
fftw(bwplan,ntrans,(FFTW_COMPLEX*)&zvec[0],inc1,inc2,
(FFTW_COMPLEX*)0,0,0);
t_bwd.stop();
......@@ -68,27 +68,74 @@ int main(int argc, char**argv)
* FFTW_COMPLEX *out, int ostride, int odist);
*/
t_fwd.start();
fftw(fwplan2,ntrans,(FFTW_COMPLEX*)&zvec_[0],inc1,inc2,
fftw(fwplan,ntrans,(FFTW_COMPLEX*)&zvec[0],inc1,inc2,
(FFTW_COMPLEX*)0,0,0);
t_fwd.stop();
int len = zvec_.size();
int len = zvec.size();
double fac = 3.14;
zdscal_(&len,&fac,&zvec_[0],&inc1);
zdscal_(&len,&fac,&zvec[0],&inc1);
}
fftw_destroy_plan(fwplan2);
fftw_destroy_plan(bwplan2);
fftw_destroy_plan(fwplan);
fftw_destroy_plan(bwplan);
cout << " fwd: " << t_fwd.real()/niter << endl;
cout << " fwd: time per transform (microseconds): "
<< 1.e6*t_fwd.real()/(niter*nvec_)
<< 1.e6*t_fwd.real()/(niter*nvec)
<< endl;
cout << " bwd: " << t_bwd.real()/niter << endl;
cout << " bwd: time per transform (microseconds): "
<< 1.e6*t_bwd.real()/(niter*nvec_)
<< 1.e6*t_bwd.real()/(niter*nvec)
<< endl;
#if 1
// Use out-of-place, specific plan
valarray<complex<double> > zvec_out(zvec.size());
t_bwd.reset();
t_fwd.reset();
fwplan = fftw_create_plan_specific(np,
FFTW_FORWARD,FFTW_ESTIMATE|FFTW_OUT_OF_PLACE,
(FFTW_COMPLEX*)&zvec[0],1,(FFTW_COMPLEX*)&zvec_out[0],1);
bwplan = fftw_create_plan_specific(np,
FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_OUT_OF_PLACE,
(FFTW_COMPLEX*)&zvec[0],1,(FFTW_COMPLEX*)&zvec_out[0],1);
for ( int iter = 0; iter < niter; iter++ )
{
int ntrans = nvec;
int inc1 = 1;
int inc2 = ldz;
t_bwd.start();
fftw(bwplan,ntrans,(FFTW_COMPLEX*)&zvec[0],inc1,inc2,
(FFTW_COMPLEX*)&zvec_out[0],inc1,inc2);
t_bwd.stop();
t_fwd.start();
fftw(fwplan,ntrans,(FFTW_COMPLEX*)&zvec[0],inc1,inc2,
(FFTW_COMPLEX*)&zvec_out[0],inc1,inc2);
t_fwd.stop();
int len = zvec.size();
double fac = 3.14;
zdscal_(&len,&fac,&zvec[0],&inc1);
}
fftw_destroy_plan(fwplan);
fftw_destroy_plan(bwplan);
cout << " fwd: " << t_fwd.real()/niter << endl;
cout << " fwd: time per transform (microseconds): "
<< 1.e6*t_fwd.real()/(niter*nvec)
<< endl;
cout << " bwd: " << t_bwd.real()/niter << endl;
cout << " bwd: time per transform (microseconds): "
<< 1.e6*t_bwd.real()/(niter*nvec)
<< endl;
#endif
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment