Skip to content

Commit 39e0d0c

Browse files
committed
delete the memory allocate in the ft
1 parent 965d627 commit 39e0d0c

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

source/module_basis/module_pw/fft.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ void FFT::initfft(int nx_in, int ny_in, int nz_in, int lixy_in, int rixy_in, int
9292
int maxgrids = (nsz > nrxx) ? nsz : nrxx;
9393
if (!this->mpifft)
9494
{
95-
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * maxgrids);
96-
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * maxgrids);
97-
ModuleBase::Memory::record("FFT::grid", 2 * sizeof(fftw_complex) * maxgrids);
98-
d_rspace = (double*)z_auxg;
95+
// z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * maxgrids);
96+
// z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * maxgrids);
97+
// ModuleBase::Memory::record("FFT::grid", 2 * sizeof(fftw_complex) * maxgrids);
98+
// d_rspace = (double*)z_auxg;
9999
// auxr_3d = static_cast<std::complex<double> *>(
100100
// fftw_malloc(sizeof(fftw_complex) * (this->nx * this->ny * this->nz)));
101101
#if defined(__CUDA) || defined(__ROCM)
@@ -105,15 +105,15 @@ void FFT::initfft(int nx_in, int ny_in, int nz_in, int lixy_in, int rixy_in, int
105105
resmem_zd_op()(gpu_ctx, this->z_auxr_3d, this->nx * this->ny * this->nz);
106106
}
107107
#endif // defined(__CUDA) || defined(__ROCM)
108-
#if defined(__ENABLE_FLOAT_FFTW)
109-
if (this->precision == "single")
110-
{
111-
c_auxg = (std::complex<float>*)fftw_malloc(sizeof(fftwf_complex) * maxgrids);
112-
c_auxr = (std::complex<float>*)fftw_malloc(sizeof(fftwf_complex) * maxgrids);
113-
ModuleBase::Memory::record("FFT::grid_s", 2 * sizeof(fftwf_complex) * maxgrids);
114-
s_rspace = (float*)c_auxg;
115-
}
116-
#endif // defined(__ENABLE_FLOAT_FFTW)
108+
// #if defined(__ENABLE_FLOAT_FFTW)
109+
// if (this->precision == "single")
110+
// {
111+
// c_auxg = (std::complex<float>*)fftw_malloc(sizeof(fftwf_complex) * maxgrids);
112+
// c_auxr = (std::complex<float>*)fftw_malloc(sizeof(fftwf_complex) * maxgrids);
113+
// ModuleBase::Memory::record("FFT::grid_s", 2 * sizeof(fftwf_complex) * maxgrids);
114+
// s_rspace = (float*)c_auxg;
115+
// }
116+
// #endif // defined(__ENABLE_FLOAT_FFTW)
117117
}
118118
else
119119
{

source/module_basis/module_pw/test/test1-4.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ TEST_F(PWTEST,test1_4)
156156
{
157157
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].real(),rhor[ixy*nplane+iz].real(),1e-6);
158158
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].imag(),rhor[ixy*nplane+iz].imag(),1e-6);
159-
// EXPECT_NEAR(tmp[ixy * nz + startiz + iz].real(),rhogr[ixy*nplane+iz].real(),1e-6);
160-
// EXPECT_NEAR(tmp[ixy * nz + startiz + iz].imag(),rhogr[ixy*nplane+iz].imag(),1e-6);
159+
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].real(),rhogr[ixy*nplane+iz].real(),1e-6);
160+
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].imag(),rhogr[ixy*nplane+iz].imag(),1e-6);
161161
#ifdef __ENABLE_FLOAT_FFTW
162162
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].real(),rhofr[ixy*nplane+iz].real(),1e-4);
163163
EXPECT_NEAR(tmp[ixy * nz + startiz + iz].imag(),rhofr[ixy*nplane+iz].imag(),1e-4);
@@ -178,10 +178,10 @@ TEST_F(PWTEST,test1_4)
178178

179179
for(int ig = 0 ; ig < npwk ; ++ig)
180180
{
181-
// EXPECT_NEAR(rhog[ig].real(),rhogout[ig].real(),1e-6);
182-
// EXPECT_NEAR(rhog[ig].imag(),rhogout[ig].imag(),1e-6);
183-
// EXPECT_NEAR(rhog[ig].real(),rhogr[ig].real(),1e-6);
184-
// EXPECT_NEAR(rhog[ig].imag(),rhogr[ig].imag(),1e-6);
181+
EXPECT_NEAR(rhog[ig].real(),rhogout[ig].real(),1e-6);
182+
EXPECT_NEAR(rhog[ig].imag(),rhogout[ig].imag(),1e-6);
183+
EXPECT_NEAR(rhog[ig].real(),rhogr[ig].real(),1e-6);
184+
EXPECT_NEAR(rhog[ig].imag(),rhogr[ig].imag(),1e-6);
185185
#ifdef __ENABLE_FLOAT_FFTW
186186
EXPECT_NEAR(rhofg[ig].real(),rhofgout[ig].real(),1e-4);
187187
EXPECT_NEAR(rhofg[ig].imag(),rhofgout[ig].imag(),1e-4);

source/module_elecstate/module_charge/charge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,10 @@ void Charge::atomic_rho(const int spin_number_need,
644644
double sumrea = 0.0;
645645
for (int ir = 0; ir < this->rhopw->nrxx; ir++)
646646
{
647-
rea = this->rhopw->ft.get_auxr_data<double>()[ir].real();
647+
rea = this->rhopw->ft1.get_auxr_data<double>()[ir].real();
648648
sumrea += rea;
649649
neg += std::min(0.0, rea);
650-
ima += std::abs(this->rhopw->ft.get_auxr_data<double>()[ir].imag());
650+
ima += std::abs(this->rhopw->ft1.get_auxr_data<double>()[ir].imag());
651651
}
652652

653653
#ifdef __MPI

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ void Charge::set_rho_core(
260260
double rhoneg = 0.0;
261261
for (int ir = 0; ir < this->rhopw->nrxx; ir++)
262262
{
263-
rhoneg += std::min(0.0, this->rhopw->ft.get_auxr_data<double>()[ir].real());
264-
rhoima += std::abs(this->rhopw->ft.get_auxr_data<double>()[ir].imag());
263+
rhoneg += std::min(0.0, this->rhopw->ft1.get_auxr_data<double>()[ir].real());
264+
rhoima += std::abs(this->rhopw->ft1.get_auxr_data<double>()[ir].imag());
265265
// NOTE: Core charge is computed in reciprocal space and brought to real
266266
// space by FFT. For non smooth core charges (or insufficient cut-off)
267267
// this may result in negative values in some grid points.

source/module_esolver/esolver_fp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void ESolver_FP::before_all_runners(const Input_para& inp, UnitCell& cell)
8282

8383
this->pw_rho->initparameters(false, 4.0 * inp.ecutwfc);
8484
this->pw_rho->ft.fft_mode = inp.fft_mode;
85-
this->pw_rho->ft.fft_mode = inp.fft_mode;
85+
this->pw_rho->ft1.initfftmode(inp.fft_mode);
8686
this->pw_rho->setuptransform();
8787
this->pw_rho->collect_local_pw();
8888
this->pw_rho->collect_uniqgg();

0 commit comments

Comments
 (0)