Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Pwft.cu
1 #include "cheetah/pwft/cuda/Pwft.cuh"
2 #include "panda/Log.h"
3 
4 #define RSQRT2 0.70710678118654746f
5 
6 namespace ska {
7 namespace cheetah {
8 namespace pwft {
9 namespace cuda {
10 namespace detail {
11 
15 template <typename T>
16 struct FormPower: public thrust::unary_function<T,thrust::complex<T> >
17 {
18  inline __host__ __device__
19  T operator()(const thrust::complex<T> &x) const
20  {
21  T val = thrust::abs<T>(x);
22  return val*val;
23  }
24 };
25 
30 template <typename T>
31 struct FormPowerNN: public thrust::binary_function<T, thrust::complex<T>, thrust::complex<T> >
32 {
33  inline __host__ __device__
34  T operator()(const thrust::complex<T> &x, const thrust::complex<T> &y) const
35  {
36  T val = thrust::max<T>(thrust::abs<T>(x-y)*RSQRT2,thrust::abs<T>(x));
37  return val*val;
38  }
39 };
40 
41 } //namespace detail
42 
43 
44 template <typename T, typename InputAlloc, typename OutputAlloc>
45 void Pwft::process_direct(ResourceType& gpu,
46  data::FrequencySeries<Architecture,typename data::ComplexTypeTraits<cheetah::Cuda,T>::type,InputAlloc> const& input,
48 {
49  PANDA_LOG_DEBUG << "GPU ID: "<<gpu.device_id();
50  output.resize(input.size());
51  output.frequency_step(input.frequency_step());
52  output.degrees_of_freedom(2.0);
53  thrust::transform(thrust::cuda::par,
54  input.begin(),
55  input.end(),output.begin(),
57 }
58 
59 template <typename T, typename InputAlloc, typename OutputAlloc>
60 void Pwft::process_nn(ResourceType& gpu,
61  data::FrequencySeries<Architecture,typename data::ComplexTypeTraits<cheetah::Cuda,T>::type,InputAlloc> const& input,
62  data::PowerSeries<Architecture,T,OutputAlloc>& output) //cuda::ExecutionPolicy& policy)
63 {
64  PANDA_LOG_DEBUG << "GPU ID: "<<gpu.device_id();
65  output.resize(input.size());
66  output.frequency_step(input.frequency_step());
67  output.degrees_of_freedom(2.0+RSQRT2);
68  output[0] = 0;
69  thrust::transform(thrust::cuda::par,
70  input.begin()+1, input.end(),
71  input.begin(), output.begin()+1,
73 }
74 
75 } //cuda
76 } //pwft
77 } //cheetah
78 } //ska
void process_direct(ResourceType &gpu, data::FrequencySeries< Architecture, typename data::ComplexTypeTraits< cheetah::Cuda, T >::type, InputAlloc > const &input, data::PowerSeries< Architecture, T, OutputAlloc > &output)
Form power spectrum using absolute squared.
Definition: Pwft.cu:45
FourierFrequencyType const & frequency_step() const
Retrieve the frequency step of the series.
void process_nn(ResourceType &gpu, data::FrequencySeries< Architecture, typename data::ComplexTypeTraits< cheetah::Cuda, T >::type, InputAlloc > const &input, data::PowerSeries< Architecture, T, OutputAlloc > &output)
Form power spectrum using absolute squared with nearest neighbour comparison.
Definition: Pwft.cu:60
A helper class to determine the type of complex data for different architectures. ...
A container of Fourier series data.
Thrust functor for calculating the power of a complex spectrum using nearest neighbours.
Definition: Pwft.cu:31
Thrust functor for calculating the power of a complex spectrum.
Definition: Pwft.cu:16
Some limits and constants for FLDO.
Definition: Brdz.h:35
ConstIterator begin() const
Iterators to device memory.
Definition: Series.cpp:67
Class for power series (detected FrequencySeries).
Definition: PowerSeries.h:58
void resize(std::size_t size)
resize the data
Definition: Series.cpp:115
double degrees_of_freedom() const
Retreive the (assumed) degrees of freedom of the data distribution.
Definition: PowerSeries.cpp:58