@@ -11,16 +11,14 @@ FFT::FFT()
1111 nplane = 1 ;
1212 mpifft = false ;
1313 destroyp = true ;
14- nfftgroup = 1 ;
1514 gamma_only = false ;
1615 c_rspace = c_gspace = NULL ;
16+ c_rspace2 = c_gspace2 = NULL ;
1717 r_rspace = NULL ;
18- // r_gspace = NULL
1918#ifdef __MIX_PRECISION
2019 destroypf = true ;
2120 cf_rspace = cf_gspace = NULL ;
2221 rf_rspace = NULL ;
23- // rf_gspace = NULL
2422#endif
2523}
2624
@@ -29,17 +27,17 @@ FFT::~FFT()
2927 this ->cleanFFT ();
3028 if (c_gspace!=NULL ) fftw_free (c_gspace);
3129 if (c_rspace!=NULL ) fftw_free (c_rspace);
32- // if(r_gspace!=NULL) fftw_free(r_gspace);
30+ if (c_gspace2!=NULL ) fftw_free (c_gspace2);
31+ if (c_rspace2!=NULL ) fftw_free (c_rspace2);
3332 if (r_rspace!=NULL ) fftw_free (r_rspace);
3433#ifdef __MIX_PRECISION
3534 if (cf_gspace!=NULL ) fftw_free (cf_gspace);
3635 if (cf_rspace!=NULL ) fftw_free (cf_rspace);
37- // if(rf_gspace!=NULL) fftw_free(rf_gspace);
3836 if (rf_rspace!=NULL ) fftw_free (rf_rspace);
3937#endif
4038}
4139
42- void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in, int nfftgroup_in, bool gamma_only_in, bool mpifft_in)
40+ void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in, bool gamma_only_in, bool mpifft_in)
4341{
4442 this ->gamma_only = gamma_only_in;
4543 this ->nx = nx_in;
@@ -52,19 +50,22 @@ void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in,
5250 this ->mpifft = mpifft_in;
5351 this ->nxy = this ->nx * this -> ny;
5452 this ->bignxy = this ->nx * this ->bigny ;
55- this ->nfftgroup = nfftgroup_in;
5653 if (!this ->mpifft )
5754 {
55+ // out-of-place fft is faster than in-place fft
5856 c_gspace = (std::complex <double > *) fftw_malloc (sizeof (fftw_complex) * this ->nz * this ->ns );
59- // r_gspace = (double *) fftw_malloc(sizeof(double ) * this->nz * this->ns);
57+ c_gspace2 = (std:: complex < double > *) fftw_malloc (sizeof (fftw_complex ) * this ->nz * this ->ns );
6058 c_rspace = (std::complex <double > *) fftw_malloc (sizeof (fftw_complex) * this ->bignxy * nplane);
6159 if (this ->gamma_only )
6260 {
6361 r_rspace = (double *) fftw_malloc (sizeof (double ) * this ->bignxy * nplane);
6462 }
63+ else
64+ {
65+ c_rspace2 = (std::complex <double > *) fftw_malloc (sizeof (fftw_complex) * this ->bignxy * nplane);
66+ }
6567#ifdef __MIX_PRECISION
6668 cf_gspace = (std::complex <float > *)fftw_malloc (sizeof (fftwf_complex) * this ->nz * this ->ns );
67- // rf_gspace = (float *)fftw_malloc(sizeof(float) * this->nz * this->ns);
6869 cf_rspace = (std::complex <float > *)fftw_malloc (sizeof (fftwf_complex) * this ->bignxy * nplane);
6970 if (this ->gamma_only )
7071 {
@@ -112,19 +113,12 @@ void FFT :: initplan()
112113
113114 this ->plan1for = fftw_plan_many_dft ( 1 , &this ->nz , this ->ns ,
114115 (fftw_complex*) c_gspace, &this ->nz , 1 , this ->nz ,
115- (fftw_complex*) c_gspace , &this ->nz , 1 , this ->nz , FFTW_FORWARD, FFTW_MEASURE);
116+ (fftw_complex*) c_gspace2 , &this ->nz , 1 , this ->nz , FFTW_FORWARD, FFTW_MEASURE);
116117
117118 this ->plan1bac = fftw_plan_many_dft ( 1 , &this ->nz , this ->ns ,
118119 (fftw_complex*) c_gspace, &this ->nz , 1 , this ->nz ,
119- (fftw_complex*) c_gspace , &this ->nz , 1 , this ->nz , FFTW_BACKWARD, FFTW_MEASURE);
120+ (fftw_complex*) c_gspace2 , &this ->nz , 1 , this ->nz , FFTW_BACKWARD, FFTW_MEASURE);
120121
121- // this->plan1r2c = fftw_plan_many_dft_r2c( 1, &this->nz, this->ns,
122- // r_gspace, &this->nz, 1, this->nz,
123- // (fftw_complex*) c_gspace, &this->nz, 1, this->nz, FFTW_MEASURE);
124-
125- // this->plan1c2r = fftw_plan_many_dft_c2r( 1, &this->nz, this->ns,
126- // (fftw_complex*) c_gspace, &this->nz, 1, this->nz,
127- // r_gspace, &this->nz, 1, this->nz, FFTW_MEASURE);
128122
129123 // ---------------------------------------------------------
130124 // 2 D
@@ -134,11 +128,11 @@ void FFT :: initplan()
134128 int *embed = NULL ;
135129 this ->plan2for = fftw_plan_many_dft ( 2 , nrank, this ->nplane ,
136130 (fftw_complex*) c_rspace, embed, this ->nplane , 1 ,
137- (fftw_complex*) c_rspace , embed, this ->nplane , 1 , FFTW_FORWARD, FFTW_MEASURE);
131+ (fftw_complex*) c_rspace2 , embed, this ->nplane , 1 , FFTW_FORWARD, FFTW_MEASURE);
138132
139133 this ->plan2bac = fftw_plan_many_dft ( 2 , nrank, this ->nplane ,
140134 (fftw_complex*) c_rspace, embed, this ->nplane , 1 ,
141- (fftw_complex*) c_rspace , embed, this ->nplane , 1 , FFTW_BACKWARD, FFTW_MEASURE);
135+ (fftw_complex*) c_rspace2 , embed, this ->nplane , 1 , FFTW_BACKWARD, FFTW_MEASURE);
142136
143137 this ->plan2r2c = fftw_plan_many_dft_r2c ( 2 , nrank, this ->nplane ,
144138 r_rspace, embed, this ->nplane , 1 ,
@@ -169,13 +163,6 @@ void FFT :: initplanf()
169163 (fftwf_complex*)c_gspace, &this ->nz , 1 , this ->nz ,
170164 (fftwf_complex*)c_gspace, &this ->nz , 1 , this ->nz , FFTW_BACKWARD, FFTW_MEASURE);
171165
172- // this->planf1r2c = fftwf_plan_many_dft_r2c( 1, &this->nz, this->ns,
173- // r_gspace, &this->nz, 1, this->nz,
174- // (fftwf_complex*)c_gspace, &this->nz, 1, this->nz, FFTW_MEASURE);
175-
176- // this->planf1c2r = fftwf_plan_many_dft_c2r( 1, &this->nz, this->ns,
177- // (fftwf_complex*)c_gspace, &this->nz, 1, this->nz,
178- // r_gspace, &this->nz, 1, this->nz, FFTW_MEASURE);
179166
180167 // ---------------------------------------------------------
181168 // 2 D
@@ -218,8 +205,6 @@ void FFT:: cleanFFT()
218205 if (destroyp==true ) return ;
219206 fftw_destroy_plan (plan1for);
220207 fftw_destroy_plan (plan1bac);
221- // fftw_destroy_plan(plan1r2c);
222- // fftw_destroy_plan(plan1c2r);
223208 fftw_destroy_plan (plan2for);
224209 fftw_destroy_plan (plan2bac);
225210 fftw_destroy_plan (plan2r2c);
@@ -230,8 +215,6 @@ void FFT:: cleanFFT()
230215 if (destroypf==true ) return ;
231216 fftw_destroy_plan (planf1for);
232217 fftw_destroy_plan (planf1bac);
233- // fftw_destroy_plan(planf1r2c);
234- // fftw_destroy_plan(planf1c2r);
235218 fftw_destroy_plan (planf2for);
236219 fftw_destroy_plan (planf2bac);
237220 fftw_destroy_plan (planf2r2c);
@@ -252,12 +235,8 @@ void FFT::executefftw(std::string instr)
252235 fftw_execute (this ->plan1bac );
253236 else if (instr == " 2bac" )
254237 fftw_execute (this ->plan2bac );
255- // else if(instr == "1r2c")
256- // fftw_execute(this->plan1r2c);
257238 else if (instr == " 2r2c" )
258239 fftw_execute (this ->plan2r2c );
259- // else if(instr == "1c2r")
260- // fftw_execute_dft(this->plan1c2r);
261240 else if (instr == " 2c2r" )
262241 fftw_execute (this ->plan2c2r );
263242 else
@@ -277,12 +256,8 @@ void executefftwf(std::string instr)
277256 fftwf_execute (this ->planf1bac );
278257 else if (instr == " 2bac" )
279258 fftwf_execute (this ->planf2bac );
280- // else if(instr == "1r2c")
281- // fftwf_execute(this->planf1r2c);
282259 else if (instr == " 2r2c" )
283260 fftwf_execute (this ->planf2r2c );
284- // else if(instr == "1c2r")
285- // fftwf_execute(this->planf1c2r);
286261 else if (instr == " 2c2r" )
287262 fftwf_execute (this ->planf2c2r );
288263 else
0 commit comments