Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
SpsTask.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef SKA_CHEETAH_SPS_DETAIL_SPSTASK_H
25 #define SKA_CHEETAH_SPS_DETAIL_SPSTASK_H
26 
27 #include "cheetah/sps/emulator/Sps.h"
28 #include "cheetah/data/DmTime.h"
29 #include "panda/AlgorithmTuple.h"
30 #include "panda/arch/nvidia/Nvidia.h"
31 #include "panda/FinishTask.h"
32 #include <memory>
33 
34 // astroacceelrate is dangerous - include last or suffer the consequences
35 #include "cheetah/sps/astroaccelerate/Sps.h"
36 
37 namespace ska {
38 namespace cheetah {
39 namespace sps {
40 
46 template<typename DmHandler, typename SpHandler, typename CommonTraits>
47 class SpsTask : public std::enable_shared_from_this<SpsTask<DmHandler, SpHandler, CommonTraits>>
48 {
49  private:
50  // to extend to different architectures add the alorithm inside this tuple
52  typedef panda::AlgorithmTuple<astroaccelerate::Sps<CommonTraits>, EmulatorType> ImplementationsType;
53 
54  protected:
55  typedef typename CommonTraits::BufferType BufferType;
56  typedef typename CommonTraits::BufferFillerType BufferFillerType;
57  typedef typename CommonTraits::TimeFrequencyType TimeFrequencyType;
58 
59  public:
60  typedef typename ImplementationsType::Architectures Architectures;
61 
62  public:
63  SpsTask(DmHandler dm_handler, SpHandler sm_handler);
64  SpsTask(SpsTask const&) = delete;
65  virtual ~SpsTask();
66 
67  virtual std::shared_ptr<panda::ResourceJob> submit(BufferType buffer);
68 
69  virtual void finish(BufferFillerType& buffer_filler);
70 
74  template<typename DataType>
75  void call_dm_handler(DataType&& d) const;
76 
80  template<typename DataType>
81  void call_sp_handler(DataType&& d) const;
82 
83  virtual std::size_t buffer_overlap() const;
84 
85  virtual std::size_t set_dedispersion_strategy(
86  std::size_t memory_min
87  ,TimeFrequencyType const& data
88  );
89 
90  protected:
91  //ImplementationsType _algos;
92  DmHandler _dm_handler;
93  SpHandler _sp_handler;
94 };
95 
96 template<typename DmHandler, typename SpHandler, typename CommonTraits
97  ,typename PoolType, typename... Algos>
98 class SpecificSpsTask : public SpsTask<DmHandler, SpHandler, CommonTraits>
99 {
101  typedef panda::AlgorithmTuple<Algos...> ImplementationsType;
102  typedef typename BaseT::BufferType BufferType;
103  typedef typename BaseT::BufferFillerType BufferFillerType;
104  typedef typename BaseT::TimeFrequencyType TimeFrequencyType;
105 
106  public:
107  typedef typename ImplementationsType::Architectures Architectures;
108 
109  public:
110  SpecificSpsTask( DmHandler dm_handler
111  , SpHandler sm_handler
112  , PoolType& pool
113  , Algos&&... algos);
114  SpecificSpsTask(SpecificSpsTask const&) = delete;
115 
116  virtual std::shared_ptr<panda::ResourceJob> submit(BufferType buffer) override;
117 
121  template<typename Arch>
122  void operator()(panda::PoolResource<Arch>&, BufferType buffer);
123 
129  std::size_t buffer_overlap() const override;
130 
135  std::size_t set_dedispersion_strategy(
136  std::size_t memory_min
137  ,TimeFrequencyType const& data
138  ) override;
139 
140 
144  void finish(BufferFillerType& buffer_filler) override;
145 
149  std::shared_ptr<SpecificSpsTask> shared_from_this()
150  {
151  return std::static_pointer_cast<SpecificSpsTask>(BaseT::shared_from_this());
152  }
153 
154  private:
155  ImplementationsType _algos;
156  PoolType* _pool;
157 };
158 
159 } // namespace sps
160 } // namespace cheetah
161 } // namespace ska
162 
163 #include "cheetah/sps/detail/SpsTask.cpp"
164 #endif // SKA_CHEETAH_SPS_DETAIL_SPSTASK_H
void call_dm_handler(DataType &&d) const
call the dm handler directly with the provided data
Definition: SpsTask.cpp:48
Single pulse search asynchronous task.
Definition: SpsTask.h:47
Produces a stream of random SpCandidate&#39;s.
Definition: Sps.h:44
Some limits and constants for FLDO.
Definition: Brdz.h:35
void call_sp_handler(DataType &&d) const
call the sp handler directly with the provided data
Definition: SpsTask.cpp:55
std::shared_ptr< SpecificSpsTask > shared_from_this()
get the correct shred_from_this type
Definition: SpsTask.h:149