Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Series.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/data/Series.h"
25 #include "panda/Copy.h"
26 
27 
28 namespace ska {
29 namespace cheetah {
30 namespace data {
31 
32 
33 template <typename Arch, typename ValueT, typename Alloc>
34 Series<Arch, ValueT, Alloc>::Series(Allocator const& allocator)
35  : Series(0, allocator)
36 {
37 }
38 
39 template <typename Arch, typename ValueT, typename Alloc>
40 template<typename OtherArch, typename OtherAlloc>
42  : _data(copy.size(), allocator)
43 {
44  panda::copy(copy.begin(), copy.end(), _data.begin());
45 }
46 
47 template <typename Arch, typename ValueT, typename Alloc>
49  : _data(copy._data)
50 {
51 }
52 
53 template <typename Arch, typename ValueT, typename Alloc>
54 Series<Arch, ValueT, Alloc>::Series(Series&& to_move)
55  : _data(std::move(to_move))
56 {
57 }
58 
59 template <typename Arch, typename ValueT, typename Alloc>
60 Series<Arch, ValueT, Alloc>::Series(std::size_t size, Allocator const& allocator)
61  : _data(size, allocator)
62 {
63 }
64 
65 template <typename Arch, typename ValueT, typename Alloc>
66 inline
67 typename Series<Arch, ValueT, Alloc>::ConstIterator Series<Arch, ValueT, Alloc>::begin() const
68 {
69  return _data.begin();
70 }
71 
72 template <typename Arch, typename ValueT, typename Alloc>
73 inline
74 typename Series<Arch, ValueT, Alloc>::ConstIterator Series<Arch, ValueT, Alloc>::cbegin() const
75 {
76  return _data.begin();
77 }
78 
79 template <typename Arch, typename ValueT, typename Alloc>
80 inline
81 typename Series<Arch, ValueT, Alloc>::Iterator Series<Arch, ValueT, Alloc>::begin()
82 {
83  return _data.begin();
84 }
85 
86 template <typename Arch, typename ValueT, typename Alloc>
87 inline
88 typename Series<Arch, ValueT, Alloc>::ConstIterator Series<Arch, ValueT, Alloc>::end() const
89 {
90  return _data.end();
91 }
92 
93 template <typename Arch, typename ValueT, typename Alloc>
94 inline
95 typename Series<Arch, ValueT, Alloc>::Iterator Series<Arch, ValueT, Alloc>::end()
96 {
97  return _data.end();
98 }
99 
100 template <typename Arch, typename ValueT, typename Alloc>
101 inline
102 typename Series<Arch, ValueT, Alloc>::ConstIterator Series<Arch, ValueT, Alloc>::cend() const
103 {
104  return _data.cend();
105 }
106 
107 template <typename Arch, typename ValueT, typename Alloc>
108 inline
110 {
111  return _data.size();
112 }
113 
114 template <typename Arch, typename ValueT, typename Alloc>
116 {
117  if(_data.size() == size) return;
118  _data.reset(size);
119 }
120 
121 // ---------- CPU Specialisation -------------------------
122 template <typename ValueT, typename Alloc>
124  : BaseT()
125 {
126 }
127 
128 template <typename ValueT, typename Alloc>
129 Series<cheetah::Cpu, ValueT, Alloc>::Series(Allocator const& allocator)
130  : BaseT(allocator)
131 {
132 }
133 
134 template <typename ValueT, typename Alloc>
135 template<typename OtherArch, typename OtherAlloc>
137  : BaseT(copy.size(), ValueT(), Alloc())
138 {
139  panda::copy(copy.begin(), copy.end(), this->begin());
140 }
141 
142 template <typename ValueT, typename Alloc>
143 Series<cheetah::Cpu, ValueT, Alloc>::Series(std::size_t size, Allocator const& allocator)
144  : BaseT(size, ValueT(), allocator)
145 {
146 }
147 
148 template <typename ValueT, typename Alloc>
149 Series<cheetah::Cpu, ValueT, Alloc>::Series(Series const& copy)
150  : BaseT(copy.size(), ValueT(), copy.allocator())
151 {
152  panda::copy(copy.begin(), copy.end(), this->begin());
153 }
154 
155 template <typename ValueT, typename Alloc>
156 template<typename OtherArch, typename OtherAlloc>
157 Series<cheetah::Cpu, ValueT, Alloc>::Series(Series<OtherArch, ValueT, OtherAlloc> const& copy, Alloc const& allocator)
158  : BaseT(copy.size(), ValueT(), allocator)
159 {
160  panda::copy(copy.begin(), copy.end(), this->begin());
161 }
162 
163 
164 } // namespace data
165 } // namespace cheetah
166 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35
Base class for generic data series.
Definition: Series.h:44
ConstIterator begin() const
Iterators to device memory.
Definition: Series.cpp:67
std::size_t size() const
the size of the series
Definition: Series.cpp:109