Skip to content

Commit 9b200a2

Browse files
committed
modify the fft name and add comments
1 parent da26acc commit 9b200a2

File tree

11 files changed

+132
-132
lines changed

11 files changed

+132
-132
lines changed

source/module_basis/module_pw/module_fft/fft_cpu.cpp

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -87,69 +87,69 @@ void FFT_CPU<double>::setupFFT()
8787
default:
8888
break;
8989
}
90-
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
91-
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
92-
d_rspace = (double*)z_auxg;
93-
this->planzfor = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
94-
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_FORWARD, flag);
90+
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
91+
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
92+
d_rspace = (double*)z_auxg;
93+
this->planzfor = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
94+
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_FORWARD, flag);
9595

96-
this->planzbac = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
97-
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_BACKWARD, flag);
96+
this->planzbac = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
97+
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_BACKWARD, flag);
9898

99-
//---------------------------------------------------------
100-
// 2 D - XY
101-
//---------------------------------------------------------
102-
// 1D+1D is much faster than 2D FFT!
103-
// in-place fft is better for c2c and out-of-place fft is better for c2r
104-
int* embed = nullptr;
105-
int npy = this->nplane * this->ny;
106-
if (this->xprime)
99+
//---------------------------------------------------------
100+
// 2 D - XY
101+
//---------------------------------------------------------
102+
// 1D+1D is much faster than 2D FFT!
103+
// in-place fft is better for c2c and out-of-place fft is better for c2r
104+
int* embed = nullptr;
105+
int npy = this->nplane * this->ny;
106+
if (this->xprime)
107+
{
108+
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
109+
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_FORWARD, flag);
110+
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
111+
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_BACKWARD, flag);
112+
if (this->gamma_only)
113+
{
114+
this->planxr2c = fftw_plan_many_dft_r2c(1, &this->nx, npy, d_rspace, embed, npy, 1, (fftw_complex*)z_auxr,
115+
embed, npy, 1, flag);
116+
this->planxc2r = fftw_plan_many_dft_c2r(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1, d_rspace,
117+
embed, npy, 1, flag);
118+
}
119+
else
107120
{
108-
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
109-
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_FORWARD, flag);
110-
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
111-
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_BACKWARD, flag);
112-
if (this->gamma_only)
113-
{
114-
this->planxr2c = fftw_plan_many_dft_r2c(1, &this->nx, npy, d_rspace, embed, npy, 1, (fftw_complex*)z_auxr,
115-
embed, npy, 1, flag);
116-
this->planxc2r = fftw_plan_many_dft_c2r(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1, d_rspace,
117-
embed, npy, 1, flag);
118-
}
119-
else
120-
{
121-
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
122-
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
123-
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
124-
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
125-
}
121+
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
122+
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
123+
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
124+
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
125+
}
126+
}
127+
else
128+
{
129+
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
130+
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
131+
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
132+
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
133+
if (this->gamma_only)
134+
{
135+
this->planyr2c = fftw_plan_many_dft_r2c(1, &this->ny, this->nplane, d_rspace, embed, this->nplane, 1,
136+
(fftw_complex*)z_auxr, embed, this->nplane, 1, flag);
137+
this->planyc2r = fftw_plan_many_dft_c2r(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,
138+
this->nplane, 1, d_rspace, embed, this->nplane, 1, flag);
126139
}
127140
else
128141
{
129-
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
130-
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
131-
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
132-
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
133-
if (this->gamma_only)
134-
{
135-
this->planyr2c = fftw_plan_many_dft_r2c(1, &this->ny, this->nplane, d_rspace, embed, this->nplane, 1,
136-
(fftw_complex*)z_auxr, embed, this->nplane, 1, flag);
137-
this->planyc2r = fftw_plan_many_dft_c2r(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,
138-
this->nplane, 1, d_rspace, embed, this->nplane, 1, flag);
139-
}
140-
else
141-
{
142142

143-
this->planxfor2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
144-
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
145-
this->planxbac2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
146-
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
147-
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
148-
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_FORWARD, flag);
149-
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
150-
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
151-
}
143+
this->planxfor2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
144+
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
145+
this->planxbac2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
146+
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
147+
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
148+
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_FORWARD, flag);
149+
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
150+
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
152151
}
152+
}
153153
return;
154154
}
155155

source/module_basis/module_pw/pw_basis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PW_Basis::PW_Basis(std::string device_, std::string precision_) : device(std::mo
1717
classname="PW_Basis";
1818
this->ft.set_device(this->device);
1919
this->ft.set_precision(this->precision);
20-
this->ft1.setfft("cpu",this->precision);
20+
this->fft_bundle.setfft("cpu",this->precision);
2121
}
2222

2323
PW_Basis:: ~PW_Basis()
@@ -58,19 +58,19 @@ void PW_Basis::setuptransform()
5858
this->distribute_g();
5959
this->getstartgr();
6060
this->ft.clear();
61-
this->ft1.clear();
61+
this->fft_bundle.clear();
6262
if(this->xprime)
6363
{
6464
this->ft.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
65-
this->ft1.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
65+
this->fft_bundle.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
6666
}
6767
else
6868
{
6969
this->ft.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
70-
this->ft1.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
70+
this->fft_bundle.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
7171
}
7272
this->ft.setupFFT();
73-
this->ft1.setupFFT();
73+
this->fft_bundle.setupFFT();
7474
ModuleBase::timer::tick(this->classname, "setuptransform");
7575
}
7676

source/module_basis/module_pw/pw_basis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class PW_Basis
243243
int nmaxgr=0; // Gamma_only: max between npw and (nrxx+1)/2, others: max between npw and nrxx
244244
// Thus complex<double>[nmaxgr] is able to contain either reciprocal or real data
245245
FFT ft;
246-
FFT_Bundle ft1;
246+
FFT_Bundle fft_bundle;
247247
//The position of pointer in and out can be equal(in-place transform) or different(out-of-place transform).
248248

249249
template <typename FPTYPE>

source/module_basis/module_pw/pw_basis_k.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ModulePW
1212
PW_Basis_K::PW_Basis_K()
1313
{
1414
classname="PW_Basis_K";
15-
this->ft1.setfft("cpu",this->precision);
15+
this->fft_bundle.setfft("cpu",this->precision);
1616
}
1717
PW_Basis_K::~PW_Basis_K()
1818
{
@@ -181,16 +181,16 @@ void PW_Basis_K::setuptransform()
181181
this->getstartgr();
182182
this->setupIndGk();
183183
this->ft.clear();
184-
this->ft1.clear();
184+
this->fft_bundle.clear();
185185
if(this->xprime){
186186
this->ft.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
187-
this->ft1.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
187+
this->fft_bundle.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
188188
}else{
189189
this->ft.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
190-
this->ft1.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
190+
this->fft_bundle.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
191191
}
192192
this->ft.setupFFT();
193-
this->ft1.setupFFT();
193+
this->fft_bundle.setupFFT();
194194
ModuleBase::timer::tick(this->classname, "setuptransform");
195195
}
196196

source/module_basis/module_pw/pw_basis_sup.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
2020
this->distribute_g(pw_rho);
2121
this->getstartgr();
2222
this->ft.clear();
23-
this->ft1.clear();
23+
this->fft_bundle.clear();
2424
if (this->xprime)
2525
{
2626
this->ft.initfft(this->nx,
@@ -33,7 +33,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
3333
this->poolnproc,
3434
this->gamma_only,
3535
this->xprime);
36-
this->ft1.initfft(this->nx,
36+
this->fft_bundle.initfft(this->nx,
3737
this->ny,
3838
this->nz,
3939
this->lix,
@@ -56,7 +56,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
5656
this->poolnproc,
5757
this->gamma_only,
5858
this->xprime);
59-
this->ft1.initfft(this->nx,
59+
this->fft_bundle.initfft(this->nx,
6060
this->ny,
6161
this->nz,
6262
this->liy,
@@ -68,7 +68,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
6868
this->xprime);
6969
}
7070
this->ft.setupFFT();
71-
this->ft1.setupFFT();
71+
this->fft_bundle.setupFFT();
7272
ModuleBase::timer::tick(this->classname, "setuptransform");
7373
}
7474

0 commit comments

Comments
 (0)