CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FlexiStorage.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_CUDAUtilities_interface_FlexiStorage_h
2 #define HeterogeneousCore_CUDAUtilities_interface_FlexiStorage_h
3 
4 #include <cstdint>
5 
6 namespace cms {
7  namespace cuda {
8 
9  template <typename I, int S>
10  class FlexiStorage {
11  public:
12  constexpr int capacity() const { return S; }
13 
14  constexpr I& operator[](int i) { return m_v[i]; }
15  constexpr const I& operator[](int i) const { return m_v[i]; }
16 
17  constexpr I* data() { return m_v; }
18  constexpr I const* data() const { return m_v; }
19 
20  private:
21  I m_v[S];
22  };
23 
24  template <typename I>
25  class FlexiStorage<I, -1> {
26  public:
27  constexpr void init(I* v, int s) {
28  m_v = v;
29  m_capacity = s;
30  }
31 
32  constexpr int capacity() const { return m_capacity; }
33 
34  constexpr I& operator[](int i) { return m_v[i]; }
35  constexpr const I& operator[](int i) const { return m_v[i]; }
36 
37  constexpr I* data() { return m_v; }
38  constexpr I const* data() const { return m_v; }
39 
40  private:
41  I* m_v;
43  };
44 
45  } // namespace cuda
46 
47 } // namespace cms
48 
49 #endif
constexpr I & operator[](int i)
Definition: FlexiStorage.h:14
constexpr I & operator[](int i)
Definition: FlexiStorage.h:34
uint32_t T const *__restrict__ v
constexpr int capacity() const
Definition: FlexiStorage.h:32
constexpr I const * data() const
Definition: FlexiStorage.h:38
constexpr I * data()
Definition: FlexiStorage.h:17
constexpr int capacity() const
Definition: FlexiStorage.h:12
constexpr void init(I *v, int s)
Definition: FlexiStorage.h:27
const std::complex< double > I
Definition: I.h:8
constexpr I const * data() const
Definition: FlexiStorage.h:18
constexpr const I & operator[](int i) const
Definition: FlexiStorage.h:35
constexpr const I & operator[](int i) const
Definition: FlexiStorage.h:15