Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Tdas.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/tdas/Tdas.h"
25 #include "panda/Error.h"
26 #include "panda/Log.h"
27 
28 namespace ska {
29 namespace cheetah {
30 namespace tdas {
31 
32 template <typename T>
34  : _config(config)
35  , _implementations(cuda::Tdas<T>(_config.cuda_config(),_config))
36 {
37 }
38 
39 template <typename T>
40 template <typename Arch, typename... Args>
41 std::shared_ptr<data::Ccl> TdasBase<T>::process(panda::PoolResource<Arch>& resource,
42  DmTimeSliceType const& data,
43  Args&&... args)
44 {
45  auto& algo = _implementations.template get<Arch>();
46  return algo.process(resource, data, std::forward<Args>(args)...);
47 }
48 
49 template <typename T>
51 {
52 }
53 
54 
55 template <typename T, typename Handler>
56 Tdas<T,Handler>::Tdas(ConfigType const& config, Handler& handler)
57  : TdasBase<T>(config)
58  , _config(config)
59  , _task(_config.pool(), handler)
60 {
61  if(_config.cuda_config().active()) {
67  #ifdef ENABLE_CUDA
68  PANDA_LOG << "tdas::cuda algorithm activated";
69  _task.template set_algorithms<cuda::Tdas<T>>(cuda::Tdas<T>(_config.cuda_config(),_config));
70  #else
71  throw panda::Error("tdas::cuda algorithm requested on ENABLE_CUDA=False build");
72  #endif //ENABLE_CUDA
73  }
74  else
75  {
76  PANDA_LOG_WARN << "No Time Domain Accelerated Search algorithm has been specified";
77  }
78 }
79 
80 template <typename T, typename Handler>
82 {
83 }
84 
85 template <typename T, typename Handler>
86 void Tdas<T,Handler>::operator()(std::shared_ptr<DmTimeType> const& data)
87 {
88  PANDA_LOG_DEBUG << "Tdas::operator() invoked"
89  << "Num blocks in DmTime object: " << (data->blocks()).size();
90 
91  for (auto it = data->begin(_config.dm_trials_per_task()); it < data->end(); ++it)
92  {
93  std::shared_ptr<DmTimeSliceType> slice = *it;
94  PANDA_LOG_DEBUG << "First DM in slice: " << (*(slice->cbegin())).dm();
95  _task.submit(slice);
96  PANDA_LOG_DEBUG << "Tdas::operator() " << _config.dm_trials_per_task() << " DM trials submitted for processing";
97  }
98 }
99 
100 
101 } // namespace tdas
102 } // namespace cheetah
103 } // namespace ska
Top-level synchronous interface for the Tdas module.
Definition: Tdas.h:57
Class that wraps a subset of DMs from a DmTime object.
Definition: DmTimeSlice.h:54
Async + Sync mixed interface for Tdas.
Definition: Tdas.h:107
Some limits and constants for FLDO.
Definition: Brdz.h:35
std::shared_ptr< data::Ccl > process(panda::PoolResource< Arch > &resource, DmTimeSliceType const &data, Args &&... args)
Process a DmTimeSlice in search of significant periodic signals over a range of acceleration values...
Definition: Tdas.cpp:41
Tdas(ConfigType const &config, Handler &handler)
Construct a new Tdas instance.
Definition: Tdas.cpp:56
TdasBase(Config const &config)
Construct a new TdasBase instance.
Definition: Tdas.cpp:33
CUDA/Thrust implementation of the Tdas module.
Definition: Tdas.cuh:34