Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Sps.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 
25 #ifndef SKA_CHEETAH_SPS_ASTROACCELERATE_SPS_H
26 #define SKA_CHEETAH_SPS_ASTROACCELERATE_SPS_H
27 
28 #include "cheetah/sps/astroaccelerate/Config.h"
29 #include "cheetah/sps/Config.h"
30 #include "cheetah/utils/Mock.h"
31 #include "cheetah/data/TimeFrequency.h"
32 
33 #ifdef ENABLE_ASTROACCELERATE
34 
35 #include "cheetah/sps/astroaccelerate/detail/SpsCuda.h"
36 #include "cheetah/sps/detail/CommonTypes.h"
37 #include "cheetah/utils/Architectures.h"
38 #include "cheetah/utils/AlgorithmBase.h"
39 #include "cheetah/data/Units.h"
40 #include "cheetah/data/DmTime.h"
41 #include "panda/arch/nvidia/DeviceCapability.h"
42 #include <memory>
43 #include <map>
44 #include <type_traits>
45 
46 namespace ska {
47 namespace cheetah {
48 namespace sps {
49 namespace astroaccelerate {
50 
56 template<class SpsTraits, typename Enable=void>
57 class Sps
58 {
59  public:
60  typedef cheetah::Cpu Architecture;
61 
62  public:
63  Sps(sps::Config const&) {};
64 
65  template<typename DmHandler, typename SpHandler, typename BufferType>
66  void operator()(panda::PoolResource<cheetah::Cpu>&, BufferType&, DmHandler&, SpHandler&);
67 };
68 
69 
70 // 8-bit only supported
71 template<class SpsTraits>
72 using EnableIfIsUint8T = typename std::enable_if<std::is_same<uint8_t, typename SpsTraits::value_type>::value
73  ||std::is_same<uint16_t, typename SpsTraits::value_type>::value // ugly hack for uint16_t
74  >::type;
75 static_assert(std::is_same<void, EnableIfIsUint8T<sps::CommonTypes<sps::Config, uint8_t>>>::value, "expecting to recognise uint8_t");
76 
77 template<class SpsTraits>
78 class Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>> : private utils::AlgorithmBase<Config, sps::Config>
79 {
80  private:
81  typedef utils::AlgorithmBase<Config, sps::Config> BaseT;
82  typedef sps::CommonTypes<sps::Config, uint8_t> Common;
83 
84  public:
85  // mark the architecture this algo is designed for
86  typedef cheetah::Cuda Architecture;
87  typedef panda::nvidia::DeviceCapability<3, 5, panda::nvidia::giga> ArchitectureCapability;
88 
89  private:
90  typedef uint8_t DataType;
91 
92  public:
93  typedef data::TimeFrequency<Cpu, uint8_t> TimeFrequencyType;
94 
95  private:
96  typedef typename Common::BufferType BufferType;
97 
98  public:
99  Sps(sps::Config const& config);
100  Sps(Sps&&) = default;
101  Sps(Sps const&) = delete;
102 
106  template<typename DmHandler, typename SpHandler>
107  void operator()(panda::PoolResource<cheetah::Cuda>&, BufferType&, DmHandler&, SpHandler&);
108 
109  /*
110  * catch non uint8_t data
111  */
112  template<typename DmHandler, typename SpHandler, typename OtherBufferType>
113  void operator()(panda::PoolResource<cheetah::Cuda>&, OtherBufferType&, DmHandler&, SpHandler&);
114 
119  std::size_t set_dedispersion_strategy(std::size_t min_gpu_memory, TimeFrequencyType const&);
120 
125  std::size_t buffer_overlap() const;
126 
127  protected:
128  std::size_t set_dedispersion_strategy(std::size_t min_gpu_memory, TimeFrequencyType const&, unsigned device_id);
129 
130  private:
131  std::map<unsigned, SpsCuda> _cuda_runner;
132 };
133 
134 
135 } // namespace astroaccelerate
136 } // namespace sps
137 } // namespace cheetah
138 } // namespace ska
139 
140 #else // ENABLE_ASTROACCELERATE
141 
142 namespace ska {
143 namespace cheetah {
144 namespace sps {
145 namespace astroaccelerate {
146 
147 template<class SpsTraits>
148 class Sps : public utils::Mock<cheetah::Cuda, sps::Config const&>
149 {
150 
152 
153  public:
155 
156  std::size_t set_dedispersion_strategy(std::size_t, TimeFrequencyType const&) { return 0; }
157 };
158 
159 } // namespace astroaccelerate
160 } // namespace sps
161 } // namespace cheetah
162 } // namespace ska
163 
164 #endif // ENABLE_ASTROACCELERATE
165 
166 #include "cheetah/sps/astroaccelerate/detail/Sps.cpp"
167 #endif // SKA_CHEETAH_SPS_ASTROACCELERATE_SPS_H
Some limits and constants for FLDO.
Definition: Brdz.h:35