1 #include "cheetah/fft/cuda/Fft.cuh" 31 typedef cufftReal RealType;
32 typedef cufftComplex ComplexType;
34 static inline cufftResult r2c(cufftHandle plan, RealType
const* input, ComplexType* output)
36 RealType* input_non_const =
const_cast<RealType*
>(input);
37 return cufftExecR2C(plan, input_non_const, output);
40 static inline cufftResult c2r(cufftHandle plan, ComplexType
const* input, RealType* output)
42 ComplexType* input_non_const =
const_cast<ComplexType*
>(input);
43 return cufftExecC2R(plan, input_non_const, output);
46 static inline cufftResult c2c(cufftHandle plan, ComplexType
const* input, ComplexType* output,
int direction)
48 ComplexType* input_non_const =
const_cast<ComplexType*
>(input);
49 return cufftExecC2C(plan, input_non_const, output, direction);
56 typedef cufftDoubleReal RealType;
57 typedef cufftDoubleComplex ComplexType;
59 static inline cufftResult r2c(cufftHandle plan, RealType
const* input, ComplexType* output)
61 RealType* input_non_const =
const_cast<RealType*
>(input);
62 return cufftExecD2Z(plan, input_non_const, output);
65 static inline cufftResult c2r(cufftHandle plan, ComplexType
const* input, RealType* output)
67 ComplexType* input_non_const =
const_cast<ComplexType*
>(input);
68 return cufftExecZ2D(plan, input_non_const, output);
71 static inline cufftResult c2c(cufftHandle plan, ComplexType
const* input, ComplexType* output,
int direction)
73 ComplexType* input_non_const =
const_cast<ComplexType*
>(input);
74 return cufftExecZ2Z(plan, input_non_const, output, direction);
80 template <
typename T,
typename InputAlloc,
typename OutputAlloc>
86 typedef typename Cufft::RealType RealType;
87 typedef typename Cufft::ComplexType ComplexType;
88 PANDA_LOG_DEBUG <<
"GPU ID: "<<gpu.device_id();
90 output.resize(input.
size()/2 + 1);
93 RealType
const* in = thrust::raw_pointer_cast(input.data());
94 ComplexType* out = (ComplexType*) thrust::raw_pointer_cast(output.data());
95 CUFFT_ERROR_CHECK(Cufft::r2c(_plan.plan<T>(R2C,input.
size(),1), in, out));
98 template <
typename T,
typename InputAlloc,
typename OutputAlloc>
104 typedef typename Cufft::RealType RealType;
105 typedef typename Cufft::ComplexType ComplexType;
106 PANDA_LOG_DEBUG <<
"GPU ID: "<<gpu.device_id();
108 output.
resize(2*(input.size() - 1));
111 ComplexType
const* in = (ComplexType*) thrust::raw_pointer_cast(input.data());
112 RealType* out = thrust::raw_pointer_cast(output.data());
113 CUFFT_ERROR_CHECK(Cufft::c2r(_plan.plan<T>(C2R,input.size(),1), in, out));
116 template <
typename T,
typename InputAlloc,
typename OutputAlloc>
118 data::TimeSeries<cheetah::Cuda, thrust::complex<T>, InputAlloc>
const& input,
122 typedef typename Cufft::ComplexType ComplexType;
123 PANDA_LOG_DEBUG <<
"GPU ID: "<<gpu.device_id();
125 output.resize(input.size());
127 output.frequency_step((1.0f/(input.sampling_interval().value() * input.size())) * data::hz);
128 ComplexType
const* in = (ComplexType*) thrust::raw_pointer_cast(input.data());
129 ComplexType* out = (ComplexType*) thrust::raw_pointer_cast(output.data());
130 CUFFT_ERROR_CHECK(Cufft::c2c(_plan.plan<T>(C2C,input.size(),1), in, out, CUFFT_FORWARD));
133 template <
typename T,
typename InputAlloc,
typename OutputAlloc>
139 typedef typename Cufft::ComplexType ComplexType;
140 PANDA_LOG_DEBUG <<
"GPU ID: "<<gpu.device_id();
142 output.resize(input.size());
144 output.sampling_interval((1.0f/(input.frequency_step().value()*output.size())) * data::seconds);
145 ComplexType
const* in = (ComplexType*) thrust::raw_pointer_cast(input.data());
146 ComplexType* out = (ComplexType*) thrust::raw_pointer_cast(output.data());
147 CUFFT_ERROR_CHECK(Cufft::c2c(_plan.plan<T>(C2C,input.size(),1), in, out, CUFFT_INVERSE));
A helper class for selecting the correct execution calls from cuFFT.
TimeType const & sampling_interval() const
Retrive the sampling interval.
void process(ResourceType &gpu, data::TimeSeries< cheetah::Cuda, T, InputAlloc > const &input, data::FrequencySeries< cheetah::Cuda, typename data::ComplexTypeTraits< cheetah::Cuda, T >::type, OutputAlloc > &output)
Perform a real-to-complex 1D FFT.
A helper class to determine the type of complex data for different architectures. ...
A container of Fourier series data.
Some limits and constants for FLDO.
Class for time series data.
void resize(std::size_t size)
resize the data
std::size_t size() const
the size of the series