Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Brdz.cu
1 #include "cheetah/brdz/cuda/Brdz.h"
2 #include "cheetah/cuda_utils/cuda_thrust.h"
3 #include "panda/Log.h"
4 
5 namespace ska {
6 namespace cheetah {
7 namespace brdz {
8 namespace cuda {
9 namespace detail {
10 
16 template <typename T>
17 struct ZapFunctor
18 {
19  typedef typename data::ComplexTypeTraits<cheetah::Cuda,T>::type ComplexType;
20  ComplexType* _ptr;
21  ZapFunctor(ComplexType* ptr);
22  inline __host__ __device__ void operator()(unsigned bin);
23 };
24 
25 
26 template <typename T>
27 ZapFunctor<T>::ZapFunctor(ComplexType* ptr)
28  : _ptr(ptr)
29 {
30 }
31 
32 template <typename T>
33 inline __host__ __device__ void ZapFunctor<T>::operator()(unsigned bin)
34 {
35  _ptr[bin] = ComplexType(0.0,0.0);
36 }
37 
38 } // namespace detail
39 
40 template <typename T, typename Alloc>
41 void Brdz::process(ResourceType& gpu,
42  data::FrequencySeries<Architecture,typename data::ComplexTypeTraits<Architecture,T>::type,Alloc>& input)
43 {
44  typedef typename data::ComplexTypeTraits<Architecture,T>::type ComplexType;
45  PANDA_LOG_DEBUG << "GPU ID: "<<gpu.device_id();
46  thrust::device_vector<unsigned> bins;
47  auto const& birdies = _algo_config.birdies();
48  for (auto& birdie: birdies)
49  {
50  std::size_t upper_bin = input.frequency_to_bin(birdie.frequency()+birdie.width() / 2.0);
51  std::size_t lower_bin = input.frequency_to_bin(birdie.frequency()-birdie.width() / 2.0);
52  upper_bin = std::min(upper_bin, input.size());
53  lower_bin = std::max(std::size_t(0), lower_bin);
54  for (std::size_t bin=lower_bin; bin<upper_bin; ++bin)
55  bins.push_back((unsigned)bin);
56  }
57  ComplexType* ptr = thrust::raw_pointer_cast(input.data());
58  thrust::for_each(thrust::cuda::par, bins.begin(), bins.end(), detail::ZapFunctor<T>(ptr));
59 }
60 
61 } // namespace cuda
62 } // namespace brdz
63 } // namespace cheetah
64 } // namespace ska
void process(ResourceType &gpu, data::FrequencySeries< Architecture, typename data::ComplexTypeTraits< Architecture, T >::type, Alloc > &input)
Set to zero frequencies marked as birdies.
Definition: Brdz.cu:41
A container of Fourier series data.
A helper class to determine the type of complex data for different architectures. ...
Some limits and constants for FLDO.
Definition: Brdz.h:35
A functor for setting complex data to 0+0j.
Definition: Brdz.cu:17