CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 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

Definition at line 146 of file OneToManyAssoc.h.

Definition at line 148 of file OneToManyAssoc.h.

Definition at line 150 of file OneToManyAssoc.h.

Definition at line 145 of file OneToManyAssoc.h.

Member Function Documentation

__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:119
constexpr auto totOnes() const
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61
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:119
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61
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:119
__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:118
__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inline
__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inline
__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  }
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter * apc
__host__ __device__ index_type const uint32_t n
__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
constexpr auto nOnes() const
const dim3 blockIdx
Definition: cudaCompat.h:32
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter * apc
constexpr auto totOnes() const
__host__ __device__ index_type const uint32_t n
__host__ __device__ cms::cuda::OneToManyAssoc::__attribute__ ( (always_inline)  )
inlinefinal
cms::cuda::OneToManyAssoc::assert ( w  ,
 
)
constexpr auto cms::cuda::OneToManyAssoc::capacity ( ) const
inline

Definition at line 169 of file OneToManyAssoc.h.

Referenced by gpuVertexFinder::__attribute__().

169 { return content.capacity(); }
static constexpr int32_t cms::cuda::OneToManyAssoc::ctCapacity ( )
inlinestatic
static constexpr int32_t cms::cuda::OneToManyAssoc::ctNOnes ( )
inlinestatic

Definition at line 165 of file OneToManyAssoc.h.

Referenced by cms::cuda::OneToManyAssoc< hindex_type, S+1, 5 *S >::initStorage().

165 { return ONES; }
cudaStream_t int32_t ONES
cms::cuda::OneToManyAssoc::if ( int(c.m) >=nOnes()  )
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:118
__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()
constexpr auto cms::cuda::OneToManyAssoc::nOnes ( ) const
inline

Definition at line 167 of file OneToManyAssoc.h.

Referenced by cms::cuda::OneToManyAssoc< hindex_type, S+1, 5 *S >::__attribute__().

167 { return totOnes() - 1; }
constexpr auto totOnes() const
constexpr auto cms::cuda::OneToManyAssoc::totOnes ( ) const
inline
__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

cms::cuda::OneToManyAssoc::content[c.n+j] = j
FlexiStorage<index_type, SIZE> cms::cuda::OneToManyAssoc::content
__host__ __device__ index_type cms::cuda::OneToManyAssoc::j
Initial value:
{
assert(b < nOnes())

Definition at line 225 of file OneToManyAssoc.h.

return c cms::cuda::OneToManyAssoc::m
__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< hindex_type, S+1, 5 *S >::__attribute__().

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

Definition at line 274 of file OneToManyAssoc.h.

int32_t cms::cuda::OneToManyAssoc::psws

Definition at line 275 of file OneToManyAssoc.h.

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

Definition at line 232 of file OneToManyAssoc.h.

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

Definition at line 227 of file OneToManyAssoc.h.