Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Series.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 #ifndef SKA_CHEETAH_DATA_SERIES_H
25 #define SKA_CHEETAH_DATA_SERIES_H
26 
27 #include "cheetah/data/VectorLike.h"
28 #include "cheetah/utils/Architectures.h"
29 #include "panda/Device.h"
30 #include "panda/DeviceMemory.h"
31 #include <vector>
32 
33 namespace ska {
34 namespace cheetah {
35 namespace data {
36 
43 template <typename Arch, typename ValueT, typename Alloc=panda::DeviceAllocator<ValueT, Arch>>
44 class Series
45 {
46  typedef panda::DeviceMemory<Arch, ValueT, Alloc> DeviceMemoryType;
47 
48  public:
49  typedef typename DeviceMemoryType::Iterator Iterator;
50  typedef typename DeviceMemoryType::ConstIterator ConstIterator;
51  typedef Alloc Allocator;
52  typedef Arch Architecture;
53  typedef ValueT ValueType;
54 
55  public:
56  Series(Allocator const&);
57  Series(std::size_t size, Allocator const&);
58  Series(Series const& copy);
59  Series(Series&& copy_to_move);
60 
64  template<typename OtherArch, typename OtherAlloc>
65  Series(Series<OtherArch, ValueType, OtherAlloc> const& copy, Alloc const& allocator);
66 
73  ConstIterator begin() const;
74  Iterator begin();
75  Iterator end();
76  ConstIterator end() const;
77 
78  ConstIterator cbegin() const;
79  ConstIterator cend() const;
80 
84  std::size_t size() const;
85 
89  void resize(std::size_t size);
90 
91  private:
92  DeviceMemoryType _data;
93 };
94 
98 template <typename ValueType, typename Alloc>
99 class Series<cheetah::Cpu, ValueType, Alloc>: public VectorLike<std::vector<ValueType,Alloc>>
100 {
102 
103  public:
104  typedef cheetah::Cpu Architecture;
105  typedef Alloc Allocator;
106 
107  public:
108  Series();
109  Series(Allocator const&);
110  Series(std::size_t size, Allocator const&);
111  Series(Series const&);
112 
113  template<typename OtherArch, typename OtherAlloc>
115 
119  template<typename OtherArch, typename OtherAlloc>
120  Series(Series<OtherArch, ValueType, OtherAlloc> const& copy, Alloc const& ollocator);
121 };
122 
123 
124 } // namespace data
125 } // namespace cheetah
126 } // namespace ska
127 
128 #include "detail/Series.cpp"
129 #include "cheetah/data/cuda/Series.h"
130 #include "cheetah/data/altera/Series.h"
131 
132 #endif // SKA_CHEETAH_DATA_SERIES_H
Class that wraps objects that export the std::vector interface.
Definition: VectorLike.h:44
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
void resize(std::size_t size)
resize the data
Definition: Series.cpp:115
std::size_t size() const
the size of the series
Definition: Series.cpp:109