Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DedispersionStrategy.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_DDTR_ASTROACCELERATE_DEDISPERSIONSTRATEGY_H
26 #define SKA_CHEETAH_DDTR_ASTROACCELERATE_DEDISPERSIONSTRATEGY_H
27 
28 #include "cheetah/ddtr/DedispersionTrialPlan.h"
29 #include "cheetah/cuda_utils/cuda_errorhandling.h"
30 #include "cheetah/data/Units.h"
31 #include "cheetah/data/TimeFrequency.h"
32 #include "panda/DataChunk.h"
33 #include "panda/Resource.h"
34 #include "panda/Log.h"
35 #include <memory>
36 #include <algorithm>
37 #include <limits>
38 
39 namespace ska {
40 namespace cheetah {
41 namespace ddtr {
42 namespace astroaccelerate {
43 
44 //still work to do to understand these variables. But as of now I am using the
45 // default values from the astroaccelerate Params.h file.
46 template <typename NumericalRep>
48  public:
49  static constexpr unsigned UNROLLS = 8;
50  static constexpr unsigned SNUMREG = 8;
51  static constexpr unsigned SDIVINT = 14;
52  static constexpr unsigned SDIVINDM = 50;
53  static constexpr float SFDIVINDM = 50.0f;
54  static constexpr unsigned MIN_DMS_PER_SPS_RUN = 64;
55 };
56 
57 template<typename NumericalRep, typename OptimizationParameterT=DedispersionOptimizationParameters<NumericalRep>>
59 {
60  public:
61  typedef boost::units::quantity<data::MegaHertz, double> FrequencyType;
62  typedef data::DedispersionMeasureType<float> Dm;
63  typedef boost::units::quantity<data::dm_constant::s_mhz::Unit, double> DmConstantType;
64  typedef boost::units::quantity<boost::units::si::time, double> TimeType;
65 
66  public:
67  DedispersionStrategy(const data::TimeFrequency<Cpu,NumericalRep>& chunk, const ddtr::DedispersionTrialPlan& plan, std::size_t gpu_memory);
69 
73  std::size_t gpu_memory() const;
74 
78  unsigned int range() const;
79 
83  std::vector<Dm> user_dm_low() const;
87  std::vector<Dm> user_dm_high() const;
91  std::vector<Dm>user_dm_step() const;
92 
96  std::vector<int> in_bin() const;
97  std::vector<int> out_bin() const;
98 
102  unsigned int maxshift() const;
103 
107  std::vector<Dm> dm_low() const;
108 
112  std::vector<Dm> dm_high() const;
113 
117  std::vector<Dm> dm_step() const;
118 
122  std::vector<float> dmshifts() const;
123 
127  std::vector<unsigned int> ndms() const ;
128 
132  unsigned int max_ndms() const;
133 
137  unsigned int total_ndms() const;
138 
142  Dm max_dm() const;
143 
147  std::vector<std::vector<int>> t_processed() const;
148 
152  static constexpr unsigned int nbits();
153 
157  unsigned int nifs() const;
158  void nifs(unsigned int value);
159 
163  TimeType tsamp() const;
164 
168  FrequencyType fch1() const;
169 
173  FrequencyType foff() const;
174 
178  unsigned int nsamp() const;
179 
183  unsigned int nchans() const;
184 
188  unsigned int num_tchunks() const;
189 
190  std::size_t memory_requirement_of_SPS();
191 
192  data::DimensionSize<data::Time> dedispersed_samples()
193  {
194  return data::DimensionSize<data::Time>(_dedispersed_time_samples);
195  }
196 
197  private:
202  void make_strategy(size_t gpu_memory);
203 
204  private:
205  std::size_t _gpu_memory;
206  unsigned int _range;
207  std::vector<Dm> _user_dm_low;
208  std::vector<Dm> _user_dm_high;
209  std::vector<Dm> _user_dm_step;
210  std::vector<int> _in_bin;
211  std::vector<int> _out_bin;
212  unsigned int _maxshift;
213  std::vector<Dm> _dm_low;
214  std::vector<Dm> _dm_high;
215  std::vector<Dm> _dm_step;
216  std::vector<unsigned int> _dmshifts;
217  std::vector<unsigned int> _ndms;
218  unsigned int _num_tchunks;
219  unsigned int _max_ndms;
220  unsigned int _total_ndms;
221  Dm _max_dm;
222  std::vector<std::vector<int>> _t_processed;
223  unsigned int _nifs;
224  TimeType _tsamp;
225  unsigned int _nsamp;
226  unsigned int _nchans;
227  std::vector<float> _bin_frequencies;
228  FrequencyType _fch1;
229  FrequencyType _foff;
230  size_t _SPS_mem_requirement;
231  std::size_t _dedispersed_time_samples;
232  DmConstantType _dm_constant;
233 };
234 
235 
236 
237 }//astroacclerate
238 }//sps
239 }//cheetah
240 }//ska
241 #include "cheetah/ddtr/astroaccelerate/detail/DedispersionStrategy.cpp"
242 
243 #endif // SKA_CHEETAH_DDTR_ASTROACCELERATE_DEDISPERSIONSTRATEGY_H
Configuration module to specify Dedispersion Trials.
Some limits and constants for FLDO.
Definition: Brdz.h:35