Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Sps.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/sps/astroaccelerate/Sps.h"
25 #include "cheetah/cuda_utils/cuda_errorhandling.h"
26 #include "cheetah/data/DmTrialsMetadata.h"
27 #include "cheetah/data/DmTrials.h"
28 #include "cheetah/data/SpCcl.h"
29 #include "cheetah/data/TimeFrequency.h"
30 #include "cheetah/data/Units.h"
31 #include "cheetah/data/DedispersionMeasure.h"
32 #include "cheetah/cuda_utils/nvtx.h"
33 #include "panda/Resource.h"
34 #include "panda/Log.h"
35 #include "panda/Error.h"
36 #include <vector>
37 #include <memory>
38 #include <algorithm>
39 #include <iostream>
40 
41 namespace ska {
42 namespace cheetah {
43 namespace sps {
44 namespace astroaccelerate {
45 
46 
47 #ifdef ENABLE_ASTROACCELERATE
48 template<class SpsTraits, typename Enable>
49 template<typename DmHandler, typename SpHandler, typename OtherBufferType>
50 void Sps<SpsTraits, Enable>::operator()(panda::PoolResource<cheetah::Cpu>&
51  , OtherBufferType&
52  , DmHandler&
53  , SpHandler&
54  )
55 {
56  throw panda::Error("astroaccelerate::Sps can only handle uint8_t - please deactivate this algorithm in your config");
57 }
58 
59  // --------------- 8bit implemantation ----------------------
60 template<class SpsTraits>
61 template<typename DmHandler, typename SpHandler>
62 void Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::operator()(panda::PoolResource<panda::nvidia::Cuda>& gpu
63  , BufferType& agg_buf
64  , DmHandler& dm_handler
65  , SpHandler& sp_handler
66  )
67 {
68  auto it = this->_cuda_runner.find(gpu.device_id());
69  if(it==this->_cuda_runner.end()) {
70  TimeFrequencyType const& data=*(agg_buf.composition().front());
71  set_dedispersion_strategy(this->_cuda_runner.at(0U).dedispersion_strategy().get_gpu_memory(), data, gpu.device_id());
72  it=this->_cuda_runner.find(gpu.device_id());
73  }
74  (*it).second(gpu, agg_buf, dm_handler, sp_handler);
75 }
76 
77 template<class SpsTraits>
78 template<typename DmHandler, typename SpHandler, typename OtherBufferType>
79 void Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::operator()(panda::PoolResource<cheetah::Cuda>&
80  , OtherBufferType&
81  , DmHandler&
82  , SpHandler&
83  )
84 {
85  throw panda::Error("astroaccelerate::Sps can only handle uint8_t - please deactivate this algorithm in your config");
86 }
87 
88 template<class SpsTraits>
89 Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::Sps(sps::Config const& config)
90  : BaseT(config.astroaccelerate_config(), config)
91 {
92 }
93 
94 template<class SpsTraits>
95 std::size_t Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::buffer_overlap() const
96 {
97  return _cuda_runner.at(0U).buffer_overlap();
98 }
99 
100 template<class SpsTraits>
101 std::size_t Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::set_dedispersion_strategy(std::size_t min_gpu_memory, TimeFrequencyType const& tf_data)
102 {
103  _cuda_runner.clear();
104  return set_dedispersion_strategy(min_gpu_memory, tf_data, 0); // use 0 as the reference dedispersion object
105 }
106 
107 template<class SpsTraits>
108 std::size_t Sps<SpsTraits, EnableIfIsUint8T<SpsTraits>>::set_dedispersion_strategy(std::size_t min_gpu_memory, TimeFrequencyType const& tf_data, unsigned device_id)
109 {
110  if(_cuda_runner.count(device_id) == 0) {
111  _cuda_runner.insert(std::make_pair(device_id, SpsCuda(_algo_config)));
112  }
113  return _cuda_runner.at(device_id).set_dedispersion_strategy(min_gpu_memory, tf_data);
114 }
115 
116 
117 #endif // ENABLE_ASTROACCELERATE
118 
119 } // namespace astroaccelerate
120 } // namespace sps
121 } // namespace cheetah
122 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35