Skip to content

Commit 9029453

Browse files
committed
update the format
1 parent 9c1a22d commit 9029453

File tree

6 files changed

+105
-200
lines changed

6 files changed

+105
-200
lines changed
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
#include "fft_base.h"
22
namespace ModulePW
33
{
4-
// template <typename FPTYPE>
5-
// FFT_BASE<FPTYPE>::FFT_BASE()
6-
// {
7-
// }
8-
// template <typename FPTYPE>
9-
// FFT_BASE<FPTYPE>::~FFT_BASE()
10-
// {
11-
// }
12-
13-
// template FFT_BASE<float>::FFT_BASE();
14-
// template FFT_BASE<double>::FFT_BASE();
15-
// template FFT_BASE<float>::~FFT_BASE();
16-
// template FFT_BASE<double>::~FFT_BASE();
4+
template FFT_BASE<float>::FFT_BASE();
5+
template FFT_BASE<double>::FFT_BASE();
6+
template FFT_BASE<float>::~FFT_BASE();
7+
template FFT_BASE<double>::~FFT_BASE();
178
}

source/module_basis/module_pw/module_fft/fft_base.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,5 @@ class FFT_BASE
159159
int ny=0;
160160
int nz=0;
161161
};
162-
template FFT_BASE<float>::FFT_BASE();
163-
template FFT_BASE<double>::FFT_BASE();
164-
template FFT_BASE<float>::~FFT_BASE();
165-
template FFT_BASE<double>::~FFT_BASE();
166162
}
167163
#endif // FFT_BASE_H

source/module_basis/module_pw/module_fft/fft_bundle.cpp

Lines changed: 92 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,12 @@ std::unique_ptr<FFT_BASE> make_unique(Args &&... args)
1616
}
1717
namespace ModulePW
1818
{
19-
FFT_Bundle::FFT_Bundle()
20-
{
21-
}
22-
FFT_Bundle::FFT_Bundle(std::string device_in,std::string precision_in)
23-
{
24-
assert(device_in=="cpu" || device_in=="gpu");
25-
assert(precision_in=="single" || precision_in=="double" || precision_in=="mixing");
26-
this->device = device_in;
27-
this->precision = precision_in;
28-
}
29-
30-
FFT_Bundle::~FFT_Bundle()
31-
{
32-
}
33-
34-
void FFT_Bundle::set_device(std::string device_in)
35-
{
36-
this->device = device_in;
37-
}
38-
39-
void FFT_Bundle::set_precision(std::string precision_in)
40-
{
41-
this->precision = precision_in;
42-
}
4319
void FFT_Bundle::setfft(std::string device_in,std::string precision_in)
4420
{
45-
assert(device_in=="cpu" || device_in=="gpu");
46-
assert(precision_in=="single" || precision_in=="double" || precision_in=="mixing");
4721
this->device = device_in;
4822
this->precision = precision_in;
49-
5023
}
24+
5125
void FFT_Bundle::initfft(int nx_in,
5226
int ny_in,
5327
int nz_in,
@@ -60,6 +34,9 @@ void FFT_Bundle::initfft(int nx_in,
6034
bool xprime_in ,
6135
bool mpifft_in)
6236
{
37+
assert(this->device=="cpu" || this->device=="gpu");
38+
assert(this->precision=="single" || this->precision=="double" || this->precision=="mixing");
39+
6340
if (this->precision=="single")
6441
{
6542
#ifndef __ENABLE_FLOAT_FFTW
@@ -116,174 +93,120 @@ void FFT_Bundle::initfft(int nx_in,
11693
}
11794

11895
}
119-
void FFT_Bundle::initfftmode(int fft_mode_in)
120-
{
121-
this->fft_mode = fft_mode_in;
122-
}
12396

12497
void FFT_Bundle::setupFFT()
12598
{
126-
if (double_flag)
127-
{
128-
fft_double->setupFFT();
129-
}
130-
if (float_flag)
131-
{
132-
fft_float->setupFFT();
133-
}
99+
if (double_flag){fft_double->setupFFT();}
100+
if (float_flag) {fft_float->setupFFT();}
134101
}
135102

136103
void FFT_Bundle::clearFFT()
137104
{
138-
if (double_flag)
139-
{
140-
fft_double->cleanFFT();
141-
}
142-
if (float_flag)
143-
{
144-
fft_float->cleanFFT();
145-
}
105+
if (double_flag){fft_double->cleanFFT();}
106+
if (float_flag) {fft_float->cleanFFT();}
146107
}
147108
void FFT_Bundle::clear()
148109
{
149110
this->clearFFT();
150-
if (float_flag)
151-
{
152-
fft_float->clear();
153-
}
154-
if (double_flag)
155-
{
156-
fft_double->clear();
157-
}
158-
}
159-
160-
161-
template <>
162-
void FFT_Bundle::fftxyfor(std::complex<float>* in,
163-
std::complex<float>* out) const
164-
{
165-
fft_float->fftxyfor(in,out);
166-
}
167-
168-
template <>
169-
void FFT_Bundle::fftxyfor(std::complex<double>* in,
170-
std::complex<double>* out) const
171-
{
172-
fft_double->fftxyfor(in,out);
173-
}
174-
175-
template <>
176-
void FFT_Bundle::fftzfor(std::complex<float>* in,
177-
std::complex<float>* out) const
178-
{
179-
fft_float->fftzfor(in,out);
180-
}
181-
template <>
182-
void FFT_Bundle::fftzfor(std::complex<double>* in,
183-
std::complex<double>* out) const
184-
{
185-
fft_double->fftzfor(in,out);
186-
}
187-
188-
template <>
189-
void FFT_Bundle::fftxybac(std::complex<float>* in,
190-
std::complex<float>* out) const
191-
{
192-
fft_float->fftxybac(in,out);
193-
}
194-
template <>
195-
void FFT_Bundle::fftxybac(std::complex<double>* in,
196-
std::complex<double>* out) const
197-
{
198-
fft_double->fftxybac(in,out);
199-
}
200-
201-
template <>
202-
void FFT_Bundle::fftzbac(std::complex<float>* in,
203-
std::complex<float>* out) const
204-
{
205-
fft_float->fftzbac(in,out);
206-
}
207-
template <>
208-
void FFT_Bundle::fftzbac(std::complex<double>* in,
209-
std::complex<double>* out) const
210-
{
211-
fft_double->fftzbac(in,out);
212-
}
213-
template <>
214-
void FFT_Bundle::fftxyr2c(float* in,
215-
std::complex<float>* out) const
216-
{
217-
fft_float->fftxyr2c(in,out);
218-
}
219-
template <>
220-
void FFT_Bundle::fftxyr2c(double* in,
221-
std::complex<double>* out) const
222-
{
223-
fft_double->fftxyr2c(in,out);
224-
}
225-
226-
template <>
227-
void FFT_Bundle::fftxyc2r(std::complex<float>* in,
228-
float* out) const
229-
{
230-
fft_float->fftxyc2r(in,out);
231-
}
232-
template <>
233-
void FFT_Bundle::fftxyc2r(std::complex<double>* in,
234-
double* out) const
235-
{
236-
fft_double->fftxyc2r(in,out);
237-
}
238-
239-
template <>
240-
void FFT_Bundle::fft3D_forward(const base_device::DEVICE_GPU* ctx,
111+
if (double_flag){fft_double->clear();}
112+
if (float_flag) {fft_float->clear();}
113+
}
114+
115+
template <> void
116+
FFT_Bundle::fftxyfor(std::complex<float>* in,
117+
std::complex<float>* out)
118+
const {fft_float->fftxyfor(in,out);}
119+
template <> void
120+
FFT_Bundle::fftxyfor(std::complex<double>* in,
121+
std::complex<double>* out)
122+
const {fft_double->fftxyfor(in,out);}
123+
124+
125+
template <> void
126+
FFT_Bundle::fftzfor(std::complex<float>* in,
127+
std::complex<float>* out)
128+
const {fft_float->fftzfor(in,out);}
129+
template <> void
130+
FFT_Bundle::fftzfor(std::complex<double>* in,
131+
std::complex<double>* out)
132+
const {fft_double->fftzfor(in,out);}
133+
134+
template <> void
135+
FFT_Bundle::fftxybac(std::complex<float>* in,
136+
std::complex<float>* out)
137+
const {fft_float->fftxybac(in,out);}
138+
template <> void
139+
FFT_Bundle::fftxybac(std::complex<double>* in,
140+
std::complex<double>* out)
141+
const {fft_double->fftxybac(in,out);}
142+
143+
template <> void
144+
FFT_Bundle::fftzbac(std::complex<float>* in,
145+
std::complex<float>* out)
146+
const {fft_float->fftzbac(in,out);}
147+
template <> void
148+
FFT_Bundle::fftzbac(std::complex<double>* in,
149+
std::complex<double>* out)
150+
const {fft_double->fftzbac(in,out);}
151+
152+
template <> void
153+
FFT_Bundle::fftxyr2c(float* in,
154+
std::complex<float>* out)
155+
const {fft_float->fftxyr2c(in,out);}
156+
template <> void
157+
FFT_Bundle::fftxyr2c(double* in,
158+
std::complex<double>* out)
159+
const {fft_double->fftxyr2c(in,out);}
160+
161+
template <> void
162+
FFT_Bundle::fftxyc2r(std::complex<float>* in,
163+
float* out)
164+
const {fft_float->fftxyc2r(in,out);}
165+
template <> void
166+
FFT_Bundle::fftxyc2r(std::complex<double>* in,
167+
double* out)
168+
const {fft_double->fftxyc2r(in,out);}
169+
170+
template <> void
171+
FFT_Bundle::fft3D_forward(const base_device::DEVICE_GPU* ctx,
241172
std::complex<float>* in,
242-
std::complex<float>* out) const
243-
{
244-
fft_float->fft3D_forward(in, out);
245-
}
246-
247-
template <>
248-
void FFT_Bundle::fft3D_forward(const base_device::DEVICE_GPU* ctx,
249-
std::complex<double>* in,
250-
std::complex<double>* out) const
251-
{
252-
fft_double->fft3D_forward(in, out);
253-
}
254-
template <>
255-
void FFT_Bundle::fft3D_backward(const base_device::DEVICE_GPU* ctx,
173+
std::complex<float>* out)
174+
const {fft_float->fft3D_forward(in, out);}
175+
template <> void
176+
FFT_Bundle::fft3D_forward(const base_device::DEVICE_GPU* ctx,
177+
std::complex<double>* in,
178+
std::complex<double>* out)
179+
const {fft_double->fft3D_forward(in, out);}
180+
181+
template <> void
182+
FFT_Bundle::fft3D_backward(const base_device::DEVICE_GPU* ctx,
256183
std::complex<float>* in,
257-
std::complex<float>* out) const
258-
{
259-
fft_float->fft3D_backward(in, out);
260-
}
261-
template <>
262-
void FFT_Bundle::fft3D_backward(const base_device::DEVICE_GPU* ctx,
184+
std::complex<float>* out)
185+
const {fft_float->fft3D_backward(in, out);}
186+
template <> void
187+
FFT_Bundle::fft3D_backward(const base_device::DEVICE_GPU* ctx,
263188
std::complex<double>* in,
264-
std::complex<double>* out) const
265-
{
266-
fft_double->fft3D_backward(in, out);
267-
}
189+
std::complex<double>* out)
190+
const {fft_double->fft3D_backward(in, out);}
268191

269192
// access the real space data
270193
template <> float*
271-
FFT_Bundle::get_rspace_data() const {return fft_float->get_rspace_data();}
194+
FFT_Bundle::get_rspace_data() const {return fft_float->get_rspace_data();}
272195
template <> double*
273-
FFT_Bundle::get_rspace_data() const {return fft_double->get_rspace_data();}
196+
FFT_Bundle::get_rspace_data() const {return fft_double->get_rspace_data();}
274197

275198
template <> std::complex<float>*
276-
FFT_Bundle::get_auxr_data() const {return fft_float->get_auxr_data();}
199+
FFT_Bundle::get_auxr_data() const {return fft_float->get_auxr_data();}
277200
template <> std::complex<double>*
278-
FFT_Bundle::get_auxr_data() const{return fft_double->get_auxr_data();}
201+
FFT_Bundle::get_auxr_data() const {return fft_double->get_auxr_data();}
279202

280203
template <> std::complex<float>*
281-
FFT_Bundle::get_auxg_data() const{return fft_float->get_auxg_data();}
204+
FFT_Bundle::get_auxg_data() const {return fft_float->get_auxg_data();}
282205
template <> std::complex<double>*
283-
FFT_Bundle::get_auxg_data() const{return fft_double->get_auxg_data();}
206+
FFT_Bundle::get_auxg_data() const {return fft_double->get_auxg_data();}
284207

285208
template <> std::complex<float>*
286-
FFT_Bundle::get_auxr_3d_data() const{return fft_float->get_auxr_3d_data();}
209+
FFT_Bundle::get_auxr_3d_data() const {return fft_float->get_auxr_3d_data();}
287210
template <> std::complex<double>*
288211
FFT_Bundle::get_auxr_3d_data() const {return fft_double->get_auxr_3d_data();}
289212
}

source/module_basis/module_pw/module_fft/fft_bundle.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace ModulePW
88
class FFT_Bundle
99
{
1010
public:
11-
FFT_Bundle();
11+
FFT_Bundle(){};
12+
~FFT_Bundle(){};
1213
/**
1314
* @brief Constructor with device and precision.
1415
* @param device_in device type, cpu or gpu.
@@ -17,9 +18,8 @@ class FFT_Bundle
1718
* the function will check the input device and precision,
1819
* and set the device and precision.
1920
*/
20-
FFT_Bundle(std::string device_in,std::string precision_in);
21-
~FFT_Bundle();
22-
21+
FFT_Bundle(std::string device_in,std::string precision_in):device(device_in),precision(precision_in){};
22+
2323
/**
2424
* @brief Set device and precision.
2525
* @param device_in device type, cpu or gpu.
@@ -68,7 +68,7 @@ class FFT_Bundle
6868
* the function will initialize the fft mode.
6969
*/
7070

71-
void initfftmode(int fft_mode_in);
71+
void initfftmode(int fft_mode_in){this->fft_mode = fft_mode_in;}
7272

7373
void setupFFT();
7474

@@ -197,12 +197,8 @@ class FFT_Bundle
197197
std::complex<FPTYPE>* in,
198198
std::complex<FPTYPE>* out) const;
199199

200-
void set_device(std::string device_in);
201-
202-
void set_precision(std::string precision_in);
203-
204200
private:
205-
int fft_mode = 0; ///< fftw mode 0: estimate, 1: measure, 2: patient, 3: exhaustive
201+
int fft_mode = 0;
206202
bool float_flag=false;
207203
bool float_define=true;
208204
bool double_flag=false;

source/module_basis/module_pw/module_fft/fft_cpu.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ void FFT_CPU<double>::cleanFFT()
319319
clearfft(planyc2r);
320320
}
321321

322-
323322
template <>
324323
void FFT_CPU<double>::clear()
325324
{

0 commit comments

Comments
 (0)