16 #ifndef ROOT7_RHistConcurrentFill
17 #define ROOT7_RHistConcurrentFill
25 namespace Experimental {
27 template <
class HIST,
int SIZE>
28 class RHistConcurrentFillManager;
36 template <
class HIST,
int SIZE>
37 class RHistConcurrentFiller:
public Internal::RHistBufferedFillBase<RHistConcurrentFiller<HIST, SIZE>, HIST, SIZE> {
38 RHistConcurrentFillManager<HIST, SIZE> &fManager;
41 using CoordArray_t =
typename HIST::CoordArray_t;
42 using Weight_t =
typename HIST::Weight_t;
44 RHistConcurrentFiller(RHistConcurrentFillManager<HIST, SIZE> &manager): fManager(manager) {}
47 using Internal::RHistBufferedFillBase<RHistConcurrentFiller<HIST, SIZE>, HIST, SIZE>::Fill;
50 void FillN(
const std::span<const CoordArray_t> xN,
const std::span<const Weight_t> weightN)
52 fManager.FillN(xN, weightN);
56 void FillN(
const std::span<const CoordArray_t> xN) { fManager.FillN(xN); }
58 static constexpr
int GetNDim() {
return HIST::GetNDim(); }
61 friend class Internal::RHistBufferedFillBase<RHistConcurrentFiller<HIST, SIZE>, HIST, SIZE>;
62 void FlushImpl() { fManager.FillN(this->GetCoords(), this->GetWeights()); }
76 template <
class HIST,
int SIZE = 1024>
77 class RHistConcurrentFillManager {
78 friend class RHistConcurrentFiller<HIST, SIZE>;
82 using CoordArray_t =
typename HIST::CoordArray_t;
83 using Weight_t =
typename HIST::Weight_t;
87 std::mutex fFillMutex;
90 RHistConcurrentFillManager(HIST &hist): fHist(hist) {}
92 RHistConcurrentFiller<HIST, SIZE> MakeFiller() {
return RHistConcurrentFiller<HIST, SIZE>{*
this}; }
95 void FillN(
const std::span<const CoordArray_t> xN,
const std::span<const Weight_t> weightN)
97 std::lock_guard<std::mutex> lockGuard(fFillMutex);
98 fHist.FillN(xN, weightN);
102 void FillN(
const std::span<const CoordArray_t> xN)
104 std::lock_guard<std::mutex> lockGuard(fFillMutex);