CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
cms::cuda::OneToManyAssoc Class Reference

#include <OneToManyAssoc.h>

Public Types

using Counter = uint32_t
 
using CountersOnly = OneToManyAssoc< I, ONES, 0 >
 
using index_type = I
 
using View = OneToManyAssocView< OneToManyAssoc< I, ONES, SIZE > >
 

Public Member Functions

__host__ __device__ __attribute__ ((always_inline)) void add(CountersOnly const &co)
 
__host__ __device__ __attribute__ ((always_inline)) void count(int32_t b)
 
__host__ __device__ __attribute__ ((always_inline)) void fill(int32_t b
 
__host__ __device__ __attribute__ ((always_inline)) int32_t bulkFill(AtomicPairCounter &apc
 
__host__ __device__ __attribute__ ((always_inline)) void bulkFinalize(AtomicPairCounter const &apc)
 
__host__ __device__ __attribute__ ((always_inline)) void bulkFinalizeFill(AtomicPairCounter const &apc)
 
__host__ __device__ __attribute__ ((always_inline)) void final ize(Counter *ws
 
 assert (w > 0)
 
constexpr auto capacity () const
 
 for (uint32_t j=0;j< n;++j) content[c.n+j]
 
 if (int(c.m) >=nOnes()) return -int32_t(c.m)
 
__host__ __device__ void initStorage (View view)
 
constexpr auto nOnes () const
 
constexpr auto totOnes () const
 
__host__ __device__ void zero ()
 

Static Public Member Functions

static __host__ __device__ __attribute__ ((always_inline)) uint32_t atomicIncrement(Counter &x)
 
static __host__ __device__ __attribute__ ((always_inline)) uint32_t atomicDecrement(Counter &x)
 
static constexpr int32_t ctCapacity ()
 
static constexpr int32_t ctNOnes ()
 
static constexpr uint32_t ilog2 (uint32_t v)
 

Public Attributes

 content [w - 1] = j
 
FlexiStorage< index_type, SIZE > content
 
__host__ __device__ index_type j
 
return c m
 
__host__ __device__ index_type const uint32_t n
 
 off [c.m] = c.n
 
__host__ __device__ ONES off
 
int32_t psws
 
__host__ __device__ index_type const * v
 
auto w = atomicDecrement(off[b])
 

Detailed Description

Definition at line 143 of file OneToManyAssoc.h.

Member Typedef Documentation

◆ Counter

Definition at line 146 of file OneToManyAssoc.h.

◆ CountersOnly

Definition at line 148 of file OneToManyAssoc.h.

◆ index_type

Definition at line 150 of file OneToManyAssoc.h.

◆ View

Definition at line 145 of file OneToManyAssoc.h.

Member Function Documentation

◆ __attribute__() [1/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) const &
inline

Definition at line 191 of file OneToManyAssoc.h.

191  {
192  for (int32_t i = 0; i < totOnes(); ++i) {
193 #ifdef __CUDA_ARCH__
194  atomicAdd(off.data() + i, co.off[i]);
195 #else
196  auto &a = (std::atomic<Counter> &)(off[i]);
197  a += co.off[i];
198 #endif
199  }
200  }
__host__ __device__ VT * co
Definition: prefixScan.h:47
double a
Definition: hdecay.h:121
constexpr auto totOnes() const
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61

◆ __attribute__() [2/9]

static __host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) &
inlinestatic

Definition at line 202 of file OneToManyAssoc.h.

202  {
203 #ifdef __CUDA_ARCH__
204  return atomicAdd(&x, 1);
205 #else
206  auto &a = (std::atomic<Counter> &)(x);
207  return a++;
208 #endif
209  }
double a
Definition: hdecay.h:121
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61

◆ __attribute__() [3/9]

static __host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) &
inlinestatic

Definition at line 211 of file OneToManyAssoc.h.

211  {
212 #ifdef __CUDA_ARCH__
213  return atomicSub(&x, 1);
214 #else
215  auto &a = (std::atomic<Counter> &)(x);
216  return a--;
217 #endif
218  }
T1 atomicSub(T1 *a, T2 b)
Definition: cudaCompat.h:73
double a
Definition: hdecay.h:121

◆ __attribute__() [4/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inline

Definition at line 220 of file OneToManyAssoc.h.

220  {
221  assert(b < nOnes());
222  atomicIncrement(off[b]);
223  }
constexpr auto nOnes() const
double b
Definition: hdecay.h:120

◆ __attribute__() [5/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inline

◆ __attribute__() [6/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) &
inline

◆ __attribute__() [7/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) const &
inline

Definition at line 242 of file OneToManyAssoc.h.

242  {
243  off[apc.get().m] = apc.get().n;
244  }
__device__ __host__ Counters get() const
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter * apc

◆ __attribute__() [8/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  ) const &
inline

Definition at line 246 of file OneToManyAssoc.h.

246  {
247  int m = apc.get().m;
248  auto n = apc.get().n;
249  if (m >= nOnes()) { // overflow!
250  off[nOnes()] = uint32_t(off[nOnes() - 1]);
251  return;
252  }
253  auto first = m + blockDim.x * blockIdx.x + threadIdx.x;
254  for (int i = first; i < totOnes(); i += gridDim.x * blockDim.x) {
255  off[i] = n;
256  }
257  }
const dim3 threadIdx
Definition: cudaCompat.h:29
const dim3 gridDim
Definition: cudaCompat.h:33
const dim3 blockDim
Definition: cudaCompat.h:30
__device__ __host__ Counters get() const
const dim3 blockIdx
Definition: cudaCompat.h:32
constexpr auto nOnes() const
constexpr auto totOnes() const
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter * apc
__host__ __device__ index_type const uint32_t n

◆ __attribute__() [9/9]

__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inlinefinal

◆ assert()

cms::cuda::OneToManyAssoc::assert ( w  ,
 
)

◆ capacity()

constexpr auto cms::cuda::OneToManyAssoc::capacity ( ) const
inline

Definition at line 169 of file OneToManyAssoc.h.

169 { return content.capacity(); }

◆ ctCapacity()

static constexpr int32_t cms::cuda::OneToManyAssoc::ctCapacity ( )
inlinestatic

◆ ctNOnes()

static constexpr int32_t cms::cuda::OneToManyAssoc::ctNOnes ( )
inlinestatic

Definition at line 165 of file OneToManyAssoc.h.

Referenced by cms::cuda::OneToManyAssoc< I, NHISTS *NBINS+1, SIZE >::initStorage().

165 { return ONES; }
cudaStream_t int32_t ONES

◆ for()

cms::cuda::OneToManyAssoc::for ( )

◆ if()

cms::cuda::OneToManyAssoc::if ( int(c.m) >=nOnes()  )

◆ ilog2()

static constexpr uint32_t cms::cuda::OneToManyAssoc::ilog2 ( uint32_t  v)
inlinestatic

Definition at line 152 of file OneToManyAssoc.h.

152  {
153  constexpr uint32_t b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
154  constexpr uint32_t s[] = {1, 2, 4, 8, 16};
155 
156  uint32_t r = 0; // result of log2(v) will go here
157  for (auto i = 4; i >= 0; i--)
158  if (v & b[i]) {
159  v >>= s[i];
160  r |= s[i];
161  }
162  return r;
163  }
__host__ __device__ index_type const * v
double b
Definition: hdecay.h:120

◆ initStorage()

__host__ __device__ void cms::cuda::OneToManyAssoc::initStorage ( View  view)
inline

Definition at line 171 of file OneToManyAssoc.h.

171  {
172  assert(view.assoc == this);
173  if constexpr (ctCapacity() < 0) {
174  assert(view.contentStorage);
175  assert(view.contentSize > 0);
176  content.init(view.contentStorage, view.contentSize);
177  }
178  if constexpr (ctNOnes() < 0) {
179  assert(view.offStorage);
180  assert(view.offSize > 0);
181  off.init(view.offStorage, view.offSize);
182  }
183  }
static constexpr int32_t ctCapacity()
static constexpr int32_t ctNOnes()

◆ nOnes()

constexpr auto cms::cuda::OneToManyAssoc::nOnes ( ) const
inline

Definition at line 167 of file OneToManyAssoc.h.

Referenced by cms::cuda::OneToManyAssoc< I, NHISTS *NBINS+1, SIZE >::__attribute__().

167 { return totOnes() - 1; }
constexpr auto totOnes() const

◆ totOnes()

constexpr auto cms::cuda::OneToManyAssoc::totOnes ( ) const
inline

◆ zero()

__host__ __device__ void cms::cuda::OneToManyAssoc::zero ( )
inline

Definition at line 185 of file OneToManyAssoc.h.

185  {
186  for (int32_t i = 0; i < totOnes(); ++i) {
187  off[i] = 0;
188  }
189  }
constexpr auto totOnes() const

Member Data Documentation

◆ content [1/2]

cms::cuda::OneToManyAssoc::content[w - 1] = j

◆ content [2/2]

FlexiStorage<index_type, SIZE> cms::cuda::OneToManyAssoc::content

◆ j

__host__ __device__ index_type cms::cuda::OneToManyAssoc::j
Initial value:
{
assert(b < nOnes())

Definition at line 225 of file OneToManyAssoc.h.

◆ m

return c cms::cuda::OneToManyAssoc::m

◆ n

__host__ __device__ index_type const uint32_t cms::cuda::OneToManyAssoc::n
Initial value:
{
auto c = apc.add(n)

Definition at line 232 of file OneToManyAssoc.h.

Referenced by cms::cuda::OneToManyAssoc< I, NHISTS *NBINS+1, SIZE >::__attribute__().

◆ off [1/2]

cms::cuda::OneToManyAssoc::off[c.m] = c.n

◆ off [2/2]

__host__ __device__ ONES cms::cuda::OneToManyAssoc::off

Definition at line 274 of file OneToManyAssoc.h.

◆ psws

int32_t cms::cuda::OneToManyAssoc::psws

Definition at line 275 of file OneToManyAssoc.h.

◆ v

__host__ __device__ index_type const* cms::cuda::OneToManyAssoc::v

◆ w

auto cms::cuda::OneToManyAssoc::w = atomicDecrement(off[b])

Definition at line 227 of file OneToManyAssoc.h.