diff --git a/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h b/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h index c3a843b64dd04..d4e3a65ae5de7 100644 --- a/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h +++ b/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h @@ -24,8 +24,6 @@ namespace cms { public: using Counter = uint32_t; - using CountersOnly = OneToManyAssocBase; - using index_type = I; struct View { @@ -62,13 +60,6 @@ namespace cms { } } - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE void add(const TAcc &acc, CountersOnly const &co) { - for (uint32_t i = 0; static_cast(i) < totOnes(); ++i) { - alpaka::atomicAdd(acc, off.data() + i, co.off[i], alpaka::hierarchy::Blocks{}); - } - } - template ALPAKA_FN_ACC ALPAKA_FN_INLINE static uint32_t atomicIncrement(const TAcc &acc, Counter &x) { return alpaka::atomicAdd(acc, &x, 1u, alpaka::hierarchy::Blocks{}); @@ -79,20 +70,6 @@ namespace cms { return alpaka::atomicSub(acc, &x, 1u, alpaka::hierarchy::Blocks{}); } - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE void count(const TAcc &acc, I b) { - ALPAKA_ASSERT_OFFLOAD(b < static_cast(nOnes())); - atomicIncrement(acc, off[b]); - } - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE void fill(const TAcc &acc, I b, index_type j) { - ALPAKA_ASSERT_OFFLOAD(b < static_cast(nOnes())); - auto w = atomicDecrement(acc, off[b]); - ALPAKA_ASSERT_OFFLOAD(w > 0); - content[w - 1] = j; - } - // this MUST BE DONE in a single block (or in two kernels!) struct zeroAndInit { template @@ -222,6 +199,20 @@ namespace cms { public: using Counter = typename OneToManyAssocBase::Counter; using View = typename OneToManyAssocBase::View; + using CountersOnly = OneToManyAssocRandomAccess; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE void count(const TAcc &acc, Counter b) { + ALPAKA_ASSERT_OFFLOAD(b < static_cast(this->nOnes())); + this->atomicIncrement(acc, this->off[b]); + } + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE void add(const TAcc &acc, CountersOnly const &co) { + for (uint32_t i = 0; static_cast(i) < this->totOnes(); ++i) { + alpaka::atomicAdd(acc, this->off.data() + i, co.off[i], alpaka::hierarchy::Blocks{}); + } + } template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void finalize(TAcc &acc, Counter *ws = nullptr) { @@ -274,6 +265,13 @@ namespace cms { h->finalize(); } } + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE void fill(const TAcc &acc, Counter b, I j) { + ALPAKA_ASSERT_OFFLOAD(b < static_cast(this->nOnes())); + auto w = this->atomicDecrement(acc, this->off[b]); + ALPAKA_ASSERT_OFFLOAD(w > 0); + this->content[w - 1] = j; + } }; } // namespace alpakatools