Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
SpsCuda.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_SPSCUDA_H
26 #define SKA_CHEETAH_SPS_ASTROACCELERATE_SPSCUDA_H
27 
28 #include "cheetah/sps/astroaccelerate/Config.h"
29 #include "cheetah/sps/Config.h"
30 #include "cheetah/utils/Mock.h"
31 
32 #ifdef ENABLE_ASTROACCELERATE //Note: This should probably be ENABLE_ASTROACCELERATE
33 
34 #include "cheetah/ddtr/DedispersionConfig.h"
35 #include "cheetah/utils/Architectures.h"
36 #include "cheetah/utils/AlgorithmBase.h"
37 #include "cheetah/data/Units.h"
38 #include "cheetah/data/DmTime.h"
39 #include "cheetah/data/TimeFrequency.h"
40 #include "cheetah/data/DmTrialsMetadata.h"
41 #include "panda/AggregationBufferFiller.h"
42 #include "panda/arch/nvidia/DeviceCapability.h"
43 #include "astro-accelerate/astro-accelerate/DedispersionStrategy.h"
44 #include "astro-accelerate/astro-accelerate/AstroAccelerate.h"
45 #include <tuple>
46 #include <vector>
47 #include <functional>
48 #include <memory>
49 
50 namespace ska {
51 namespace cheetah {
52 namespace sps {
53 namespace astroaccelerate {
54 
60 class SpsCuda : private utils::AlgorithmBase<Config, sps::Config>
61 {
62  private:
63  typedef utils::AlgorithmBase<Config, sps::Config> BaseT;
64 
65  public:
66  // mark the architecture this algo is designed for
67  typedef cheetah::Cuda Architecture;
68  typedef panda::nvidia::DeviceCapability<3, 5, panda::nvidia::giga> ArchitectureCapability;
69 
70  private:
71  typedef uint8_t DataType;
72 
73  public:
74  typedef data::TimeFrequency<Cpu, uint8_t> TimeFrequencyType;
75  typedef boost::units::quantity<data::MegaHertz, double> FrequencyType;
76  typedef boost::units::quantity<boost::units::si::time, double> TimeType;
77 
78  private:
79  typedef typename ska::panda::AggregationBufferFiller<TimeFrequencyType>::AggregationBufferType BufferType;
80 
81  public:
82  SpsCuda(sps::Config const& config);
83  SpsCuda(SpsCuda&&) = default;
84  SpsCuda(SpsCuda const&) = delete;
85  ~SpsCuda();
86 
90  template<typename DmHandler, typename SpHandler>
91  void operator()(panda::PoolResource<cheetah::Cuda>&, BufferType&, DmHandler&, SpHandler&);
92 
97  std::size_t set_dedispersion_strategy(std::size_t min_gpu_memory, TimeFrequencyType const&);
98 
102  ::astroaccelerate::DedispersionStrategy const& dedispersion_strategy() const;
103 
108  std::size_t buffer_overlap() const;
109 
110  protected:
111 
112  private:
113  std::size_t calculate_internals(TimeType);
114  std::size_t _samples;
115  std::vector<const ddtr::DedispersionConfig*> _dedisp_configs;
116  float _threshold;
117  std::unique_ptr<::astroaccelerate::DedispersionStrategy> _dedispersion_strategy;
118  std::shared_ptr<::astroaccelerate::DmTime<float>> _dm_time;
119  std::shared_ptr<data::DmTrialsMetadata> _dm_trial_metadata;
120  FrequencyType _chan_high;
121  FrequencyType _chan_low;
122 };
123 
124 
125 } // namespace astroaccelerate
126 } // namespace sps
127 } // namespace cheetah
128 } // namespace ska
129 
130 #else // ENABLE_ASTROACCELERATE
131 
132 namespace ska {
133 namespace cheetah {
134 namespace sps {
135 namespace astroaccelerate {
136 
137 class SpsCuda : public utils::Mock<cheetah::Cuda, sps::Config const&>
138 {
139 
140  public:
142 
143 };
144 
145 } // namespace astroaccelerate
146 } // namespace sps
147 } // namespace cheetah
148 } // namespace ska
149 
150 #endif // ENABLE_ASTROACCELERATE
151 
152 #include "cheetah/sps/astroaccelerate/detail/SpsCuda.cpp"
153 #endif // SKA_CHEETAH_SPS_ASTROACCELERATE_SPSCUDA_H
Some limits and constants for FLDO.
Definition: Brdz.h:35