Skip to content

Commit 7a61632

Browse files
committed
< prof >
fft in x-direction are reduced by half
1 parent e893d10 commit 7a61632

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

source/module_pw/fft.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FFT::~FFT()
3636
#endif
3737
}
3838

39-
void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in, int nproc_in, bool gamma_only_in, bool mpifft_in)
39+
void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int lix_in, int rix_in, int ns_in, int nplane_in, int nproc_in, bool gamma_only_in, bool mpifft_in)
4040
{
4141
this->gamma_only = gamma_only_in;
4242
this->nx = nx_in;
@@ -45,6 +45,8 @@ void FFT:: initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in,
4545
else this->ny = this->bigny;
4646
this->nz = nz_in;
4747
this->ns = ns_in;
48+
this->lix = lix_in;
49+
this->rix = rix_in;
4850
this->nplane = nplane_in;
4951
this->nproc = nproc_in;
5052
this->mpifft = mpifft_in;
@@ -330,7 +332,11 @@ void FFT::fftxyfor(std::complex<double>* & in, std::complex<double>* & out)
330332
{
331333
int npy = this->nplane * this-> ny;
332334
fftw_execute_dft( this->planxfor, (fftw_complex *)in, (fftw_complex *)out);
333-
for (int i=0; i<this->nx;++i)
335+
for (int i=0; i<=this->lix;++i)
336+
{
337+
fftw_execute_dft( this->planyfor, (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
338+
}
339+
for (int i=this->rix; i<this->nx;++i)
334340
{
335341
fftw_execute_dft( this->planyfor, (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
336342
}
@@ -341,7 +347,11 @@ void FFT::fftxybac(std::complex<double>* & in, std::complex<double>* & out)
341347
{
342348
int npy = this->nplane * this-> ny;
343349

344-
for (int i=0; i<this->nx;++i)
350+
for (int i=0; i<=this->lix;++i)
351+
{
352+
fftw_execute_dft( this->planybac, (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
353+
}
354+
for (int i=this->rix; i<this->nx;++i)
345355
{
346356
fftw_execute_dft( this->planybac, (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
347357
}

source/module_pw/fft.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class FFT
2727

2828
FFT();
2929
~FFT();
30-
void initfft(int nx_in, int bigny_in, int nz_in, int ns_in, int nplane_in, int nproc_in, bool gamma_only_in, bool mpifft_in = false);
30+
void initfft(int nx_in, int bigny_in, int nz_in, int lix_in, int rix_in, int ns_in, int nplane_in,
31+
int nproc_in, bool gamma_only_in, bool mpifft_in = false);
3132
void setupFFT();
3233
void cleanFFT();
3334

@@ -55,6 +56,7 @@ class FFT
5556
int nxy;
5657
int bigny;
5758
int bignxy;
59+
int lix,rix;// lix: the left edge of the pw ball; rix: the right edge of the pw ball
5860
int ns; //number of sticks
5961
int nplane; //number of x-y planes
6062
int maxgrids; // max between nz * ns and bignxy * nplane

source/module_pw/pw_basis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void PW_Basis::setuptransform()
5454
this->distribute_r();
5555
this->distribute_g();
5656
this->getstartgr();
57-
this->ft.initfft(this->nx,this->bigny,this->nz,this->nst,this->nplane,this->poolnproc,this->gamma_only);
57+
this->ft.initfft(this->nx,this->bigny,this->nz,this->lix,this->rix,this->nst,this->nplane,this->poolnproc,this->gamma_only);
5858
this->ft.setupFFT();
5959
}
6060

source/module_pw/pw_basis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PW_Basis
184184
// FFT dimensions for wave functions.
185185
int nx, ny, nz, nxyz, nxy;
186186
int bigny, bignxyz, bignxy; // Gamma_only: ny = int(bigny/2)-1 , others: ny = bigny
187-
int liy,riy;// liy: the left edge of the pw ball; riy: the right edge of the pw ball
187+
int lix,rix;// lix: the left edge of the pw ball; rix: the right edge of the pw ball
188188
int maxgrids; // max between nz * ns and bignxy * nplane
189189
FFT ft;
190190

source/module_pw/pw_distributeg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void PW_Basis::count_pw_st(
5454
iy_start = 0;
5555
iy_end = this->ny - 1;
5656
}
57+
this->lix = this->rix = 0;
5758
for (int ix = -ibox[0]; ix <= ibox[0]; ++ix)
5859
{
5960
for (int iy = iy_start; iy <= iy_end; ++iy)
@@ -81,6 +82,8 @@ void PW_Basis::count_pw_st(
8182
if (length == 0) st_bottom2D[index] = iz; // length == 0 means this point is the bottom of stick (x, y).
8283
++tot_npw;
8384
++length;
85+
if(ix < this->rix) this->rix = ix;
86+
if(ix > this->lix) this->lix = ix;
8487
}
8588
}
8689
if (length > 0)
@@ -90,6 +93,8 @@ void PW_Basis::count_pw_st(
9093
}
9194
}
9295
}
96+
if(rix <= 0) rix += this->nx;
97+
std::cout<<"lix "<<lix<<" ; rix "<<rix<<std::endl;
9398
return;
9499
}
95100

source/module_pw/pw_distributeg_method1.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ void PW_Basis::distribution_method1()
156156
#ifdef __MPI
157157
MPI_Bcast(&tot_npw, 1, MPI_INT, 0, POOL_WORLD);
158158
MPI_Bcast(&this->nstot, 1, MPI_INT, 0, POOL_WORLD);
159+
MPI_Bcast(&lix, 1, MPI_INT, 0, POOL_WORLD);
160+
MPI_Bcast(&rix, 1, MPI_INT, 0, POOL_WORLD);
159161
if (this->poolrank != 0)
160162
{
161163
st_bottom2D = new int[this->nxy]; // minimum z of stick.
@@ -224,7 +226,6 @@ void PW_Basis::collect_st(
224226
iy_start = 0;
225227
iy_end = this->ny - 1;
226228
}
227-
this->liy = this->riy = 0;
228229
for (int ix = -ibox[0]; ix <= ibox[0]; ++ix)
229230
{
230231
for (int iy = iy_start; iy <= iy_end; ++iy)
@@ -259,17 +260,13 @@ void PW_Basis::collect_st(
259260
temp_st_i[is] = x;
260261
temp_st_j[is] = y;
261262
temp_st_length[is] = static_cast<double>(st_length2D[index]);
262-
if(iy < this->riy) this->riy = iy;
263-
if(iy > this->liy) this->liy = iy;
264263
++is;
265264
std::cout << "is " << is << '\n';
266265
}
267266
}
268267
}
269268
}
270269
assert(is == this->nstot);
271-
if(riy <= 0) riy += this->ny;
272-
std::cout<<"liy "<<liy<<" ; riy "<<riy<<std::endl;
273270
std::cout<<"collect sticks done\n";
274271

275272
// As we will distribute the longest sticks preferentially in Step(3), we rearrange st_* in the order of length decreasing.

source/module_pw/pw_distributeg_method2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ void PW_Basis::distribution_method2()
105105
#ifdef __MPI
106106
MPI_Bcast(&tot_npw, 1, MPI_INT, 0, POOL_WORLD);
107107
MPI_Bcast(&this->nstot, 1, MPI_INT, 0, POOL_WORLD);
108+
MPI_Bcast(&lix, 1, MPI_INT, 0, POOL_WORLD);
109+
MPI_Bcast(&rix, 1, MPI_INT, 0, POOL_WORLD);
108110
MPI_Bcast(this->nst_per, this->poolnproc, MPI_INT, 0 , POOL_WORLD);
109111
if (this->poolrank != 0)
110112
{

0 commit comments

Comments
 (0)