Skip to content

Commit 2d0b5f3

Browse files
committed
fix complie bug and change the fftwf logic
1 parent 6cc4bac commit 2d0b5f3

File tree

4 files changed

+10
-51
lines changed

4 files changed

+10
-51
lines changed

source/module_basis/module_pw/module_fft/fft_bundle.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,10 @@ FFT_Bundle::FFT_Bundle(std::string device_in,std::string precision_in)
2626
assert(precision_in=="single" || precision_in=="double" || precision_in=="mixing");
2727
this->device = device_in;
2828
this->precision = precision_in;
29-
if (device=="cpu")
30-
{
31-
fft_float = make_unique<FFT_CPU<float>>();
32-
fft_double = make_unique<FFT_CPU<double>>();
33-
}
34-
// else if (device=="gpu")
35-
// {
36-
// #if defined(__ROCM)
37-
// fft_float = new FFT_RCOM<float>();
38-
// fft_double = new FFT_RCOM<double>();
39-
// #elif defined(__CUDA)
40-
// fft_float = new FFT_CUDA<float>();
41-
// fft_double = new FFT_CUDA<double>();
42-
// #endif
29+
// if (device=="cpu")
30+
// {
31+
// fft_float = make_unique<FFT_CPU<float>>();
32+
// fft_double = make_unique<FFT_CPU<double>>();
4333
// }
4434
}
4535

@@ -143,18 +133,6 @@ void FFT_Bundle::clear()
143133
{
144134
fft_double->clear();
145135
}
146-
// if (fft_float!=nullptr)
147-
// {
148-
// delete fft_float;
149-
// fft_float=nullptr;
150-
// float_flag = false;
151-
// }
152-
// if (fft_double!=nullptr)
153-
// {
154-
// delete fft_double;
155-
// fft_double=nullptr;
156-
// double_flag = false;
157-
// }
158136
}
159137
// access the real space data
160138
template <>

source/module_basis/module_pw/module_fft/fft_cpu.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ void FFT_CPU<double>::setupFFT()
8484
default:
8585
break;
8686
}
87-
// if (!this->mpifft)
88-
// {
8987
z_auxg = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
9088
z_auxr = (std::complex<double>*)fftw_malloc(sizeof(fftw_complex) * this->maxgrids);
9189
d_rspace = (double*)z_auxg;
@@ -149,7 +147,6 @@ void FFT_CPU<double>::setupFFT()
149147
1, (fftw_complex*)z_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
150148
}
151149
}
152-
// }
153150
return;
154151
}
155152

source/module_basis/module_pw/module_fft/fft_cpu_float.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include "fft_cpu.h"
22

3-
// #include "fftw3f.h"
4-
// #if defined(__FFTW3_MPI) && defined(__MPI)
5-
// #include "fftw3f-mpi.h"
6-
// //#include "fftw3-mpi_mkl.h"
73
namespace ModulePW
84
{
95
template <>
@@ -56,8 +52,8 @@ void FFT_CPU<float>::setupFFT()
5652
default:
5753
break;
5854
}
59-
if (!this->mpifft)
60-
{
55+
// if (!this->mpifft)
56+
// {
6157
c_auxg = (std::complex<float>*)fftwf_malloc(sizeof(fftwf_complex) * this->maxgrids);
6258
c_auxr = (std::complex<float>*)fftwf_malloc(sizeof(fftwf_complex) * this->maxgrids);
6359
s_rspace = (float*)c_auxg;
@@ -131,16 +127,6 @@ void FFT_CPU<float>::setupFFT()
131127
(fftwf_complex*)c_auxr, embed, this->nplane, 1, FFTW_BACKWARD, flag);
132128
}
133129
}
134-
}
135-
#if defined(__FFTW3_MPI) && defined(__MPI)
136-
else
137-
{
138-
// this->initplan_mpi();
139-
// if (this->precision == "single") {
140-
// this->initplanf_mpi();
141-
// }
142-
}
143-
#endif
144130
return;
145131
}
146132

@@ -308,14 +294,12 @@ void FFT_CPU<float>::fftxyc2r(std::complex<float>* in, float* out) const
308294
}
309295
else
310296
{
311-
fftwf_execute_dft(this->planfxfor1, (fftwf_complex*)in, (fftwf_complex*)in);
297+
fftwf_execute_dft(this->planfxbac1, (fftwf_complex*)in, (fftwf_complex*)in);
312298

313299
for (int i = 0; i < this->nx; ++i)
314300
{
315-
fftwf_execute_dft(this->planfybac, (fftwf_complex*)&in[i * npy], (fftwf_complex*)&in[i * npy]);
301+
fftwf_execute_dft_c2r(this->planfyc2r, (fftwf_complex*)&in[i * npy], &out[i * npy]);
316302
}
317-
318-
fftwf_execute_dft_c2r(this->planfyc2r, (fftwf_complex*)in, out);
319303
}
320304
}
321305
}

source/module_hamilt_general/module_xc/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ AddTest(
3939
../../../module_base/libm/sincos.cpp
4040
../../../module_base/blas_connector.cpp
4141
../../../module_basis/module_pw/module_fft/fft_base.cpp
42-
../../../module_basis/module_pw/module_fft/fft_temp.cpp
42+
../../../module_basis/module_pw/module_fft/fft_bundle.cpp
4343
../../../module_basis/module_pw/module_fft/fft_cpu.cpp
4444
)
4545

@@ -77,6 +77,6 @@ AddTest(
7777
../../../module_base/libm/branred.cpp
7878
../../../module_base/libm/sincos.cpp
7979
../../../module_basis/module_pw/module_fft/fft_base.cpp
80-
../../../module_basis/module_pw/module_fft/fft_temp.cpp
80+
../../../module_basis/module_pw/module_fft/fft_bundle.cpp
8181
../../../module_basis/module_pw/module_fft/fft_cpu.cpp
8282
)

0 commit comments

Comments
 (0)