CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions
cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE > Class Template Reference

#include <OneToManyAssoc.h>

Inheritance diagram for cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >:
cms::alpakatools::OneToManyAssocBase< I, ONES, SIZE >

Public Types

using Counter = typename OneToManyAssocBase< I, ONES, SIZE >::Counter
 
using View = typename OneToManyAssocBase< I, ONES, SIZE >::View
 
- Public Types inherited from cms::alpakatools::OneToManyAssocBase< I, ONES, SIZE >
using Counter = uint32_t
 
using CountersOnly = OneToManyAssocBase< I, ONES, 0 >
 
using index_type = I
 

Public Member Functions

template<typename TAcc >
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void finalize (TAcc &acc, Counter *ws=nullptr)
 
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void finalize ()
 
- Public Member Functions inherited from cms::alpakatools::OneToManyAssocBase< I, ONES, SIZE >
template<typename TAcc >
ALPAKA_FN_ACC ALPAKA_FN_INLINE void add (const TAcc &acc, CountersOnly const &co)
 
constexpr index_type const * begin () const
 
constexpr index_type const * begin (uint32_t b) const
 
constexpr auto capacity () const
 
template<typename TAcc >
ALPAKA_FN_ACC ALPAKA_FN_INLINE void count (const TAcc &acc, I b)
 
constexpr index_type const * end () const
 
constexpr index_type const * end (uint32_t b) const
 
template<typename TAcc >
ALPAKA_FN_ACC ALPAKA_FN_INLINE void fill (const TAcc &acc, I b, index_type j)
 
ALPAKA_FN_HOST_ACC void initStorage (View view)
 
constexpr auto nOnes () const
 
constexpr auto size () const
 
constexpr auto size (uint32_t b) const
 
constexpr auto totOnes () const
 
ALPAKA_FN_HOST_ACC void zero ()
 

Static Public Member Functions

template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void launchFinalize (OneToManyAssocRandomAccess *h, TQueue &queue)
 
template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void launchFinalize (View view, TQueue &queue)
 
- Static Public Member Functions inherited from cms::alpakatools::OneToManyAssocBase< I, ONES, SIZE >
template<typename TAcc >
ALPAKA_FN_ACC static ALPAKA_FN_INLINE uint32_t atomicDecrement (const TAcc &acc, Counter &x)
 
template<typename TAcc >
ALPAKA_FN_ACC static ALPAKA_FN_INLINE uint32_t atomicIncrement (const TAcc &acc, Counter &x)
 
static constexpr int32_t ctCapacity ()
 
static constexpr int32_t ctNOnes ()
 
template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void launchZero (OneToManyAssocBase *h, TQueue &queue)
 
template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void launchZero (View view, TQueue &queue)
 

Additional Inherited Members

- Public Attributes inherited from cms::alpakatools::OneToManyAssocBase< I, ONES, SIZE >
FlexiStorage< index_type, SIZE > content
 
FlexiStorage< Counter, ONES > off
 
int32_t psws
 

Detailed Description

template<typename I, int32_t ONES, int32_t SIZE>
class cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >

Definition at line 209 of file OneToManyAssoc.h.

Member Typedef Documentation

◆ Counter

template<typename I, int32_t ONES, int32_t SIZE>
using cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::Counter = typename OneToManyAssocBase<I, ONES, SIZE>::Counter

Definition at line 211 of file OneToManyAssoc.h.

◆ View

template<typename I, int32_t ONES, int32_t SIZE>
using cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::View = typename OneToManyAssocBase<I, ONES, SIZE>::View

Definition at line 212 of file OneToManyAssoc.h.

Member Function Documentation

◆ finalize() [1/2]

template<typename I, int32_t ONES, int32_t SIZE>
template<typename TAcc >
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::finalize ( TAcc &  acc,
Counter ws = nullptr 
)
inline

Definition at line 215 of file OneToManyAssoc.h.

215  {
216  ALPAKA_ASSERT_ACC(this->off[this->totOnes() - 1] == 0);
217  blockPrefixScan(acc, this->off.data(), this->totOnes(), ws);
218  ALPAKA_ASSERT_ACC(this->off[this->totOnes() - 1] == this->off[this->totOnes() - 2]);
219  }
FlexiStorage< Counter, ONES > off
ALPAKA_FN_ACC ALPAKA_FN_INLINE void blockPrefixScan(const TAcc &acc, T const *ci, T *co, int32_t size, T *ws=nullptr)
Definition: prefixScan.h:47

◆ finalize() [2/2]

template<typename I, int32_t ONES, int32_t SIZE>
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::finalize ( void  )
inline

Definition at line 221 of file OneToManyAssoc.h.

221  {
222  // Single thread finalize.
223  for (uint32_t i = 1; static_cast<int>(i) < this->totOnes(); ++i)
224  this->off[i] += this->off[i - 1];
225  }
FlexiStorage< Counter, ONES > off

◆ launchFinalize() [1/2]

template<typename I, int32_t ONES, int32_t SIZE>
template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::launchFinalize ( OneToManyAssocRandomAccess< I, ONES, SIZE > *  h,
TQueue &  queue 
)
inlinestatic

Definition at line 228 of file OneToManyAssoc.h.

228  {
229  View view = {h, nullptr, nullptr, -1, -1};
230  launchFinalize<TAcc>(view, queue);
231  }
typename OneToManyAssocBase< I, ONES, SIZE >::View View
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ launchFinalize() [2/2]

template<typename I, int32_t ONES, int32_t SIZE>
template<typename TAcc , typename TQueue >
static ALPAKA_FN_INLINE void cms::alpakatools::OneToManyAssocRandomAccess< I, ONES, SIZE >::launchFinalize ( View  view,
TQueue &  queue 
)
inlinestatic

Definition at line 234 of file OneToManyAssoc.h.

234  {
235  // View stores a base pointer, we need to upcast back...
236  auto h = static_cast<OneToManyAssocRandomAccess *>(view.assoc);
238  if constexpr (!requires_single_thread_per_block_v<TAcc>) {
239  Counter *poff = (Counter *)((char *)(h) + offsetof(OneToManyAssocRandomAccess, off));
242  ALPAKA_ASSERT_ACC(view.offStorage);
243  ALPAKA_ASSERT_ACC(view.offSize > 0);
244  nOnes = view.offSize;
245  poff = view.offStorage;
246  }
248  int32_t *ppsws = (int32_t *)((char *)(h) + offsetof(OneToManyAssocRandomAccess, psws));
249  auto nthreads = 1024;
250  auto nblocks = (nOnes + nthreads - 1) / nthreads;
251  auto workDiv = cms::alpakatools::make_workdiv<TAcc>(nblocks, nthreads);
252  alpaka::exec<TAcc>(queue,
253  workDiv,
254  multiBlockPrefixScan<Counter>(),
255  poff,
256  poff,
257  nOnes,
258  nblocks,
259  ppsws,
260  alpaka::getPreferredWarpSize(alpaka::getDev(queue)));
261  } else {
262  h->finalize();
263  }
264  }
FlexiStorage< Counter, ONES > off
typename OneToManyAssocBase< I, ONES, SIZE >::Counter Counter
static constexpr int32_t ctNOnes()
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int nthreads
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4