CMS 3D CMS Logo

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 int capacity() const
Definition: FlexiStorage.h:12
constexpr I const * data() const
Definition: FlexiStorage.h:18
constexpr const I & operator[](int i) const
Definition: FlexiStorage.h:35
constexpr I & operator[](int i)
Definition: FlexiStorage.h:34
constexpr I * data()
Definition: FlexiStorage.h:17
uint32_t T const *__restrict__ v
const std::complex< double > I
Definition: I.h:8
constexpr const I & operator[](int i) const
Definition: FlexiStorage.h:15
Namespace of DDCMS conversion namespace.
constexpr I const * data() const
Definition: FlexiStorage.h:38
constexpr void init(I *v, int s)
Definition: FlexiStorage.h:27
constexpr int capacity() const
Definition: FlexiStorage.h:32