Skip to content

Commit

Permalink
modify the fft name and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
A-006 committed Nov 8, 2024
1 parent da26acc commit 9b200a2
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 132 deletions.
110 changes: 55 additions & 55 deletions source/module_basis/module_pw/module_fft/fft_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,69 +87,69 @@ void FFT_CPU<double>::setupFFT()
default:
break;
}
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
d_rspace = (double*)z_auxg;
this->planzfor = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_FORWARD, flag);
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
d_rspace = (double*)z_auxg;
this->planzfor = fftw_plan_many_dft(1, &this->nz, this->ns, (fftw_complex*)z_auxg, &this->nz, 1, this->nz,
(fftw_complex*)z_auxg, &this->nz, 1, this->nz, FFTW_FORWARD, flag);

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

//---------------------------------------------------------
// 2 D - XY
//---------------------------------------------------------
// 1D+1D is much faster than 2D FFT!
// in-place fft is better for c2c and out-of-place fft is better for c2r
int* embed = nullptr;
int npy = this->nplane * this->ny;
if (this->xprime)
//---------------------------------------------------------
// 2 D - XY
//---------------------------------------------------------
// 1D+1D is much faster than 2D FFT!
// in-place fft is better for c2c and out-of-place fft is better for c2r
int* embed = nullptr;
int npy = this->nplane * this->ny;
if (this->xprime)
{
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_FORWARD, flag);
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_BACKWARD, flag);
if (this->gamma_only)
{
this->planxr2c = fftw_plan_many_dft_r2c(1, &this->nx, npy, d_rspace, embed, npy, 1, (fftw_complex*)z_auxr,
embed, npy, 1, flag);
this->planxc2r = fftw_plan_many_dft_c2r(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1, d_rspace,
embed, npy, 1, flag);
}
else
{
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_FORWARD, flag);
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,this->nplane, 1,
(fftw_complex*)z_auxr, embed,this->nplane, 1, FFTW_BACKWARD, flag);
if (this->gamma_only)
{
this->planxr2c = fftw_plan_many_dft_r2c(1, &this->nx, npy, d_rspace, embed, npy, 1, (fftw_complex*)z_auxr,
embed, npy, 1, flag);
this->planxc2r = fftw_plan_many_dft_c2r(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1, d_rspace,
embed, npy, 1, flag);
}
else
{
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
}
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, npy, (fftw_complex*)z_auxr, embed, npy, 1,
(fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
}
}
else
{
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
if (this->gamma_only)
{
this->planyr2c = fftw_plan_many_dft_r2c(1, &this->ny, this->nplane, d_rspace, embed, this->nplane, 1,
(fftw_complex*)z_auxr, embed, this->nplane, 1, flag);
this->planyc2r = fftw_plan_many_dft_c2r(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,
this->nplane, 1, d_rspace, embed, this->nplane, 1, flag);
}
else
{
this->planxfor1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac1 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->lixy + 1), (fftw_complex*)z_auxr, embed, npy,
1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
if (this->gamma_only)
{
this->planyr2c = fftw_plan_many_dft_r2c(1, &this->ny, this->nplane, d_rspace, embed, this->nplane, 1,
(fftw_complex*)z_auxr, embed, this->nplane, 1, flag);
this->planyc2r = fftw_plan_many_dft_c2r(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed,
this->nplane, 1, d_rspace, embed, this->nplane, 1, flag);
}
else
{

this->planxfor2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_FORWARD, flag);
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
}
this->planxfor2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_FORWARD, flag);
this->planxbac2 = fftw_plan_many_dft(1, &this->nx, this->nplane * (this->ny - this->rixy), (fftw_complex*)z_auxr, embed,
npy, 1, (fftw_complex*)z_auxr, embed, npy, 1, FFTW_BACKWARD, flag);
this->planyfor = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_FORWARD, flag);
this->planybac = fftw_plan_many_dft(1, &this->ny, this->nplane, (fftw_complex*)z_auxr, embed, this->nplane,
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
}
}
return;
}

Expand Down
10 changes: 5 additions & 5 deletions source/module_basis/module_pw/pw_basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PW_Basis::PW_Basis(std::string device_, std::string precision_) : device(std::mo
classname="PW_Basis";
this->ft.set_device(this->device);
this->ft.set_precision(this->precision);
this->ft1.setfft("cpu",this->precision);
this->fft_bundle.setfft("cpu",this->precision);
}

PW_Basis:: ~PW_Basis()
Expand Down Expand Up @@ -58,19 +58,19 @@ void PW_Basis::setuptransform()
this->distribute_g();
this->getstartgr();
this->ft.clear();
this->ft1.clear();
this->fft_bundle.clear();
if(this->xprime)
{
this->ft.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
this->ft1.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
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);
}
else
{
this->ft.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
this->ft1.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
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);
}
this->ft.setupFFT();
this->ft1.setupFFT();
this->fft_bundle.setupFFT();
ModuleBase::timer::tick(this->classname, "setuptransform");
}

Expand Down
2 changes: 1 addition & 1 deletion source/module_basis/module_pw/pw_basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class PW_Basis
int nmaxgr=0; // Gamma_only: max between npw and (nrxx+1)/2, others: max between npw and nrxx
// Thus complex<double>[nmaxgr] is able to contain either reciprocal or real data
FFT ft;
FFT_Bundle ft1;
FFT_Bundle fft_bundle;
//The position of pointer in and out can be equal(in-place transform) or different(out-of-place transform).

template <typename FPTYPE>
Expand Down
10 changes: 5 additions & 5 deletions source/module_basis/module_pw/pw_basis_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ModulePW
PW_Basis_K::PW_Basis_K()
{
classname="PW_Basis_K";
this->ft1.setfft("cpu",this->precision);
this->fft_bundle.setfft("cpu",this->precision);
}
PW_Basis_K::~PW_Basis_K()
{
Expand Down Expand Up @@ -181,16 +181,16 @@ void PW_Basis_K::setuptransform()
this->getstartgr();
this->setupIndGk();
this->ft.clear();
this->ft1.clear();
this->fft_bundle.clear();
if(this->xprime){
this->ft.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
this->ft1.initfft(this->nx,this->ny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
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);
}else{
this->ft.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
this->ft1.initfft(this->nx,this->ny,this->nz,this->liy,this->riy,this->nst,this->nplane,this->poolnproc,this->gamma_only, this->xprime);
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);
}
this->ft.setupFFT();
this->ft1.setupFFT();
this->fft_bundle.setupFFT();
ModuleBase::timer::tick(this->classname, "setuptransform");
}

Expand Down
8 changes: 4 additions & 4 deletions source/module_basis/module_pw/pw_basis_sup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
this->distribute_g(pw_rho);
this->getstartgr();
this->ft.clear();
this->ft1.clear();
this->fft_bundle.clear();
if (this->xprime)
{
this->ft.initfft(this->nx,
Expand All @@ -33,7 +33,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
this->poolnproc,
this->gamma_only,
this->xprime);
this->ft1.initfft(this->nx,
this->fft_bundle.initfft(this->nx,
this->ny,
this->nz,
this->lix,
Expand All @@ -56,7 +56,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
this->poolnproc,
this->gamma_only,
this->xprime);
this->ft1.initfft(this->nx,
this->fft_bundle.initfft(this->nx,
this->ny,
this->nz,
this->liy,
Expand All @@ -68,7 +68,7 @@ void PW_Basis_Sup::setuptransform(const ModulePW::PW_Basis* pw_rho)
this->xprime);
}
this->ft.setupFFT();
this->ft1.setupFFT();
this->fft_bundle.setupFFT();
ModuleBase::timer::tick(this->classname, "setuptransform");
}

Expand Down
Loading

0 comments on commit 9b200a2

Please sign in to comment.