1 #include "cheetah/hrms/cuda/Hrms.cuh" 2 #include "cheetah/data/Units.h" 3 #include "cheetah/cuda_utils/cuda_thrust.h" 4 #include "cheetah/cuda_utils/cuda_errorhandling.h" 5 #include "cheetah/cuda_utils/nvtx.h" 6 #include "panda/Error.h" 26 template <
typename T,
unsigned max_harms>
42 inline __host__ __device__
50 template <
typename T,
unsigned max_harms>
62 template <
typename T,
unsigned max_harms>
65 unsigned int ii, jj, harm;
70 for (jj=0; jj<max_harms; jj++)
76 for (ii=1;ii<harm;ii+=2)
78 float factor = ii*fharm;
79 val += _input[(
unsigned int) (idx*factor + 0.5f)];
81 _output[jj][idx] = val;
88 template <
typename T,
typename Alloc>
105 PUSH_NVTX_RANGE(
"cuda_Hrms_process",0);
106 PANDA_LOG_DEBUG <<
"GPU ID: "<<gpu.device_id();
108 PUSH_NVTX_RANGE(
"cuda_Hrms_process_prepare",1);
110 thrust::host_vector<T*> output_ptrs_host(output.size());
112 for (
int idx=0; idx<output.size(); ++idx)
114 auto& series = output[idx];
115 double hnum = (double)(1<<(idx+1));
117 series.resize(input.
size());
123 series.frequency_step((input.
frequency_step().value()/hnum) * data::hz);
126 output_ptrs_host[idx] = thrust::raw_pointer_cast(series.data());
130 thrust::device_vector<T*> output_ptrs_device = output_ptrs_host;
131 auto input_ptr = thrust::raw_pointer_cast(input.data());
132 auto output_ptrs = thrust::raw_pointer_cast(output_ptrs_device.data());
133 thrust::counting_iterator<unsigned> begin(0);
134 thrust::counting_iterator<unsigned> end = begin + input.
size();
137 PUSH_NVTX_RANGE(
"cuda_Hrms_process_execute_kernels",2);
142 switch (output.size())
160 panda::Error(
"Invalid number of sums requested of Hrms.");
FourierFrequencyType const & frequency_step() const
Retrieve the frequency step of the series.
void process(ResourceType &gpu, data::PowerSeries< cheetah::Cuda, T, Alloc > const &input, std::vector< data::PowerSeries< cheetah::Cuda, T, Alloc >> &output)
Perform harmonic summing of a PowerSeries object.
A thrust functor for harmonic summing.
Some limits and constants for FLDO.
__host__ __device__ void operator()(unsigned idx) const
Class for power series (detected FrequencySeries).
std::size_t size() const
the size of the series
double degrees_of_freedom() const
Retreive the (assumed) degrees of freedom of the data distribution.
HarmonicSumFunctor(T const *input, T **output)
Construct a new instance.