CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
cms::cuda::VecArray< T, maxSize > Class Template Reference

#include <VecArray.h>

Public Types

using self = VecArray< T, maxSize >
 
using value_t = T
 

Public Member Functions

constexpr Tback () const
 
constexpr Tbegin ()
 
constexpr const Tbegin () const
 
constexpr const Tdata () const
 
template<class... Ts>
__device__ int emplace_back (Ts &&...args)
 
template<class... Ts>
constexpr int emplace_back_unsafe (Ts &&...args)
 
constexpr bool empty () const
 
constexpr Tend ()
 
constexpr const Tend () const
 
constexpr bool full () const
 
constexpr Toperator[] (int i)
 
constexpr const Toperator[] (int i) const
 
constexpr T pop_back ()
 
__device__ int push_back (const T &element)
 
constexpr int push_back_unsafe (const T &element)
 
constexpr void reset ()
 
constexpr void resize (int size)
 
constexpr int size () const
 

Static Public Member Functions

static constexpr int capacity ()
 

Private Attributes

T m_data [maxSize]
 
int m_size
 

Detailed Description

template<class T, int maxSize>
class cms::cuda::VecArray< T, maxSize >

Definition at line 14 of file VecArray.h.

Member Typedef Documentation

◆ self

template<class T , int maxSize>
using cms::cuda::VecArray< T, maxSize >::self = VecArray<T, maxSize>

Definition at line 16 of file VecArray.h.

◆ value_t

template<class T , int maxSize>
using cms::cuda::VecArray< T, maxSize >::value_t = T

Definition at line 17 of file VecArray.h.

Member Function Documentation

◆ back()

template<class T , int maxSize>
constexpr T& cms::cuda::VecArray< T, maxSize >::back ( ) const
inlineconstexpr

Definition at line 44 of file VecArray.h.

44  {
45  if (m_size > 0) {
46  return m_data[m_size - 1];
47  } else
48  return T(); //undefined behaviour
49  }

References cms::cuda::VecArray< T, maxSize >::m_data, and cms::cuda::VecArray< T, maxSize >::m_size.

◆ begin() [1/2]

template<class T , int maxSize>
constexpr T* cms::cuda::VecArray< T, maxSize >::begin ( void  )
inlineconstexpr

Definition at line 85 of file VecArray.h.

85 { return m_data; }

References cms::cuda::VecArray< T, maxSize >::m_data.

◆ begin() [2/2]

template<class T , int maxSize>
constexpr const T* cms::cuda::VecArray< T, maxSize >::begin ( void  ) const
inlineconstexpr

Definition at line 83 of file VecArray.h.

83 { return m_data; }

References cms::cuda::VecArray< T, maxSize >::m_data.

◆ capacity()

template<class T , int maxSize>
static constexpr int cms::cuda::VecArray< T, maxSize >::capacity ( )
inlinestaticconstexpr

Definition at line 91 of file VecArray.h.

91 { return maxSize; }

References reco_skim_cfg_mod::maxSize.

◆ data()

template<class T , int maxSize>
constexpr const T* cms::cuda::VecArray< T, maxSize >::data ( ) const
inlineconstexpr

Definition at line 92 of file VecArray.h.

92 { return m_data; }

References cms::cuda::VecArray< T, maxSize >::m_data.

◆ emplace_back()

template<class T , int maxSize>
template<class... Ts>
__device__ int cms::cuda::VecArray< T, maxSize >::emplace_back ( Ts &&...  args)
inline

Definition at line 64 of file VecArray.h.

64  {
65  auto previousSize = atomicAdd(&m_size, 1);
66  if (previousSize < maxSize) {
67  (new (&m_data[previousSize]) T(std::forward<Ts>(args)...));
68  return previousSize;
69  } else {
70  atomicSub(&m_size, 1);
71  return -1;
72  }
73  }

References writedatasetfile::args, cms::cudacompat::atomicAdd(), cms::cudacompat::atomicSub(), cms::cuda::VecArray< T, maxSize >::m_data, cms::cuda::VecArray< T, maxSize >::m_size, and reco_skim_cfg_mod::maxSize.

◆ emplace_back_unsafe()

template<class T , int maxSize>
template<class... Ts>
constexpr int cms::cuda::VecArray< T, maxSize >::emplace_back_unsafe ( Ts &&...  args)
inlineconstexpr

Definition at line 32 of file VecArray.h.

32  {
33  auto previousSize = m_size;
34  m_size++;
35  if (previousSize < maxSize) {
36  (new (&m_data[previousSize]) T(std::forward<Ts>(args)...));
37  return previousSize;
38  } else {
39  --m_size;
40  return -1;
41  }
42  }

References writedatasetfile::args, cms::cuda::VecArray< T, maxSize >::m_data, cms::cuda::VecArray< T, maxSize >::m_size, and reco_skim_cfg_mod::maxSize.

◆ empty()

template<class T , int maxSize>
constexpr bool cms::cuda::VecArray< T, maxSize >::empty ( void  ) const
inlineconstexpr

Definition at line 94 of file VecArray.h.

94 { return 0 == m_size; }

References cms::cuda::VecArray< T, maxSize >::m_size.

◆ end() [1/2]

template<class T , int maxSize>
constexpr T* cms::cuda::VecArray< T, maxSize >::end ( void  )
inlineconstexpr

◆ end() [2/2]

template<class T , int maxSize>
constexpr const T* cms::cuda::VecArray< T, maxSize >::end ( void  ) const
inlineconstexpr

◆ full()

template<class T , int maxSize>
constexpr bool cms::cuda::VecArray< T, maxSize >::full ( ) const
inlineconstexpr

Definition at line 95 of file VecArray.h.

95 { return maxSize == m_size; }

References cms::cuda::VecArray< T, maxSize >::m_size, and reco_skim_cfg_mod::maxSize.

◆ operator[]() [1/2]

template<class T , int maxSize>
constexpr T& cms::cuda::VecArray< T, maxSize >::operator[] ( int  i)
inlineconstexpr

Definition at line 88 of file VecArray.h.

88 { return m_data[i]; }

References mps_fire::i, and cms::cuda::VecArray< T, maxSize >::m_data.

◆ operator[]() [2/2]

template<class T , int maxSize>
constexpr const T& cms::cuda::VecArray< T, maxSize >::operator[] ( int  i) const
inlineconstexpr

Definition at line 89 of file VecArray.h.

89 { return m_data[i]; }

References mps_fire::i, and cms::cuda::VecArray< T, maxSize >::m_data.

◆ pop_back()

template<class T , int maxSize>
constexpr T cms::cuda::VecArray< T, maxSize >::pop_back ( )
inlineconstexpr

Definition at line 75 of file VecArray.h.

75  {
76  if (m_size > 0) {
77  auto previousSize = m_size--;
78  return m_data[previousSize - 1];
79  } else
80  return T();
81  }

References cms::cuda::VecArray< T, maxSize >::m_data, and cms::cuda::VecArray< T, maxSize >::m_size.

◆ push_back()

template<class T , int maxSize>
__device__ int cms::cuda::VecArray< T, maxSize >::push_back ( const T element)
inline

Definition at line 52 of file VecArray.h.

52  {
53  auto previousSize = atomicAdd(&m_size, 1);
54  if (previousSize < maxSize) {
55  m_data[previousSize] = element;
56  return previousSize;
57  } else {
58  atomicSub(&m_size, 1);
59  return -1;
60  }
61  }

References cms::cudacompat::atomicAdd(), cms::cudacompat::atomicSub(), cms::cuda::VecArray< T, maxSize >::m_data, cms::cuda::VecArray< T, maxSize >::m_size, and reco_skim_cfg_mod::maxSize.

◆ push_back_unsafe()

template<class T , int maxSize>
constexpr int cms::cuda::VecArray< T, maxSize >::push_back_unsafe ( const T element)
inlineconstexpr

Definition at line 19 of file VecArray.h.

19  {
20  auto previousSize = m_size;
21  m_size++;
22  if (previousSize < maxSize) {
23  m_data[previousSize] = element;
24  return previousSize;
25  } else {
26  --m_size;
27  return -1;
28  }
29  }

References cms::cuda::VecArray< T, maxSize >::m_data, cms::cuda::VecArray< T, maxSize >::m_size, and reco_skim_cfg_mod::maxSize.

◆ reset()

template<class T , int maxSize>
constexpr void cms::cuda::VecArray< T, maxSize >::reset ( void  )
inlineconstexpr

Definition at line 90 of file VecArray.h.

90 { m_size = 0; }

References cms::cuda::VecArray< T, maxSize >::m_size.

◆ resize()

template<class T , int maxSize>
constexpr void cms::cuda::VecArray< T, maxSize >::resize ( int  size)
inlineconstexpr

◆ size()

template<class T , int maxSize>
constexpr int cms::cuda::VecArray< T, maxSize >::size ( void  ) const
inlineconstexpr

Member Data Documentation

◆ m_data

template<class T , int maxSize>
T cms::cuda::VecArray< T, maxSize >::m_data[maxSize]
private

◆ m_size

template<class T , int maxSize>
int cms::cuda::VecArray< T, maxSize >::m_size
private
writedatasetfile.args
args
Definition: writedatasetfile.py:18
cms::cudacompat::atomicSub
T1 atomicSub(T1 *a, T2 b)
Definition: cudaCompat.h:73
mps_fire.i
i
Definition: mps_fire.py:428
cms::cudacompat::atomicAdd
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61
cms::cuda::VecArray::m_data
T m_data[maxSize]
Definition: VecArray.h:98
reco_skim_cfg_mod.maxSize
maxSize
Definition: reco_skim_cfg_mod.py:154
cms::cuda::VecArray::m_size
int m_size
Definition: VecArray.h:100
T
long double T
Definition: Basic3DVectorLD.h:48
cms::cuda::VecArray::size
constexpr int size() const
Definition: VecArray.h:87