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)) int32_t bulkFill(AtomicPairCounter &apc
 
__host__ __device__ __attribute__ ((always_inline)) void add(CountersOnly const &co)
 
__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 count(int32_t b)
 
__host__ __device__ __attribute__ ((always_inline)) void fill(int32_t b
 
__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 atomicDecrement(Counter &x)
 
static __host__ __device__ __attribute__ ((always_inline)) uint32_t atomicIncrement(Counter &x)
 
static constexpr int32_t ctCapacity ()
 
static constexpr int32_t ctNOnes ()
 
static constexpr uint32_t ilog2 (uint32_t v)
 

Public Attributes

FlexiStorage< index_type, SIZE > content
 
 content [w - 1] = j
 
__host__ __device__ index_type j
 
return c m
 
__host__ __device__ const index_type uint32_t n
 
__host__ __device__ ONES off
 
 off [c.m] = c.n
 
int32_t psws
 
__host__ __device__ const index_typev
 
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)  ) &
inline

◆ __attribute__() [2/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  }

◆ __attribute__() [3/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  }

◆ __attribute__() [4/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  }

◆ __attribute__() [5/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  }

◆ __attribute__() [6/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  }

◆ __attribute__() [7/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  }

◆ __attribute__() [8/9]

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

◆ __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
inlineconstexpr

Definition at line 169 of file OneToManyAssoc.h.

169 { return content.capacity(); }

Referenced by gpuVertexFinder::__attribute__().

◆ ctCapacity()

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

Definition at line 168 of file OneToManyAssoc.h.

168 { return SIZE; }

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

◆ ctNOnes()

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

Definition at line 165 of file OneToManyAssoc.h.

165 { return ONES; }

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

◆ 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)
inlinestaticconstexpr

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  }

◆ 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  }

◆ nOnes()

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

Definition at line 167 of file OneToManyAssoc.h.

167 { return totOnes() - 1; }

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

◆ totOnes()

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

◆ 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  }

Member Data Documentation

◆ content [1/2]

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

◆ content [2/2]

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

◆ 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__ const index_type 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__().

◆ off [1/2]

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

Definition at line 274 of file OneToManyAssoc.h.

◆ off [2/2]

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

◆ psws

int32_t cms::cuda::OneToManyAssoc::psws

Definition at line 275 of file OneToManyAssoc.h.

◆ v

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

◆ w

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

Definition at line 227 of file OneToManyAssoc.h.

cms::cudacompat::atomicSub
T1 atomicSub(T1 *a, T2 b)
Definition: cudaCompat.h:73
cms::cuda::OneToManyAssoc::n
__host__ __device__ const index_type uint32_t n
Definition: OneToManyAssoc.h:232
mps_fire.i
i
Definition: mps_fire.py:428
DDAxes::x
cms::cuda::ONES
cudaStream_t int32_t ONES
Definition: OneToManyAssoc.h:57
cms::cuda::OneToManyAssoc::v
__host__ __device__ const index_type * v
Definition: OneToManyAssoc.h:232
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cms::cuda::co
__host__ __device__ VT * co
Definition: prefixScan.h:47
cms::cudacompat::atomicAdd
T1 atomicAdd(T1 *a, T2 b)
Definition: cudaCompat.h:61
b
double b
Definition: hdecay.h:118
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
cms::cudacompat::gridDim
const dim3 gridDim
Definition: cudaCompat.h:33
a
double a
Definition: hdecay.h:119
cms::cudacompat::blockDim
const dim3 blockDim
Definition: cudaCompat.h:30
cms::cuda::OneToManyAssoc::ctNOnes
static constexpr int32_t ctNOnes()
Definition: OneToManyAssoc.h:165
cms::cuda::OneToManyAssoc::m
return c m
Definition: OneToManyAssoc.h:239
cms::cuda::OneToManyAssoc::assert
assert(w > 0)
cms::cudacompat::threadIdx
const dim3 threadIdx
Definition: cudaCompat.h:29
cms::cuda::OneToManyAssoc::nOnes
constexpr auto nOnes() const
Definition: OneToManyAssoc.h:167
cms::cuda::OneToManyAssoc::totOnes
constexpr auto totOnes() const
Definition: OneToManyAssoc.h:166
alignCSCRings.r
r
Definition: alignCSCRings.py:93
cms::cuda::OneToManyAssoc::content
content[w - 1]
Definition: OneToManyAssoc.h:229
cms::cuda::OneToManyAssoc::ctCapacity
static constexpr int32_t ctCapacity()
Definition: OneToManyAssoc.h:168
StopReason::SIZE
apc
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter * apc
Definition: CAHitNtupletGeneratorKernelsImpl.h:43
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
cms::cuda::OneToManyAssoc::off
off[c.m]
Definition: OneToManyAssoc.h:236
cms::cudacompat::blockIdx
const dim3 blockIdx
Definition: cudaCompat.h:32