Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DdtrModule.cpp
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 #include "cheetah/utils/TaskConfigurationSetter.h"
25 
26 namespace ska {
27 namespace cheetah {
28 namespace ddtr {
29 namespace detail {
30 
31 template<typename T, typename DdtrTraits>
33 {
34  template<typename DdtrAlgoFactory>
35  static inline T create(DdtrAlgoFactory& algo_factory)
36  {
37  return T(algo_factory._config);
38  }
39 };
40 
41 template<typename DdtrTraits>
42 struct CreateHelper<cpu::Ddtr<DdtrTraits>, DdtrTraits>
43 {
44  template<typename DdtrAlgoFactory>
45  static inline cpu::Ddtr<DdtrTraits> create(DdtrAlgoFactory& algo_factory)
46  {
47  return cpu::Ddtr<DdtrTraits>(algo_factory._config);
48  }
49 };
50 
51 template<typename DdtrTraits>
53 {
54  private:
55  template<typename, typename>
56  friend struct CreateHelper;
57  typedef typename DdtrTraits::Config ConfigType;
58 
59  public:
60  DdtrAlgoFactory(ConfigType const& config)
61  : _config(config)
62  {}
63 
64  void none_selected() {
65  PANDA_LOG_WARN << "ddtr:: no algorithm has been activated. Please set at least one ddtr algorithm to active.";
66  }
67 
68  template<typename T> T create() const
69  {
71  }
72 
73  template<typename Algo>
74  bool active() const
75  {
76  return _config.template config<typename Algo::Config>().active();
77  }
78 
79  private:
80  ConfigType const& _config;
81 };
82 
83 } // namespace detail
84 
85 template<typename DdtrTraits, template<typename> class... DdtrAlgorithms>
86 template<typename Handler>
87 DdtrModule<DdtrTraits, DdtrAlgorithms...>::DdtrModule(ConfigType const& config, Handler&& handler)
88  : _task(config.pool(), std::forward<Handler>(handler), _plan_setter)
89  , _buffer([this](typename DdtrTraits::BufferType&& buffer)
90  {
91  if(buffer.composition().empty())
92  {
93  PANDA_LOG_WARN << "received an empty buffer";
94  return;
95  }
96  _task.submit(std::move(buffer));
97  }
98  , ExtendedDedispersionPlan(config, _task)
99  , config.dedispersion_samples()
100  )
101 {
102  detail::DdtrAlgoFactory<DdtrTraits> factory(config);
103  utils::TaskConfigurationSetter<DdtrAlgorithms<DdtrTraits>...>::configure(_task, factory);
104 }
105 
106 } // namespace ddtr
107 } // namespace cheetah
108 } // namespace ska
generate code for integration of DdtrAlgorithms
Definition: DdtrModule.h:41
Some limits and constants for FLDO.
Definition: Brdz.h:35
DDTR module top level API.
Definition: Ddtr.h:68