Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
InternalIMTUtils.hxx
Go to the documentation of this file.
1#ifndef ROOT_INTERNAL_IMTUTILS
2#define ROOT_INTERNAL_IMTUTILS
3
4#include <functional>
5#include <memory>
6
7namespace ROOT {
8class TThreadExecutor;
9}
10
12
13/// \brief Abstract implementation of the oneAPI Range requirements
14///
15/// For the specification, see
16/// https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/named_requirements/algorithms/range.
17///
18/// The class is meant to pass implementations from other parts of ROOT to the
19/// internal calls to the TBB parallel_for overload taking a Range object.
21public:
22 virtual std::unique_ptr<RAbstractTBBRangeImpl> SplitWork() = 0;
23 virtual bool Empty() const = 0;
24 virtual bool IsDivisible() const = 0;
26
27 // Destructor is required for dynamic polymorphism, so apply rule of five
28 virtual ~RAbstractTBBRangeImpl() = default;
33};
34
35// Entry point to a parallel_for that takes a Range and Body
36// https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/algorithms/functions/parallel_for_func
37void ParallelFor(ROOT::TThreadExecutor &pool, std::unique_ptr<RAbstractTBBRangeImpl> rangeImpl,
38 const std::function<void(const RAbstractTBBRangeImpl &)> &body);
39
40} // namespace ROOT::Internal::IMTUtils
41
42#endif
Abstract implementation of the oneAPI Range requirements.
RAbstractTBBRangeImpl & operator=(RAbstractTBBRangeImpl &&)=default
virtual std::unique_ptr< RAbstractTBBRangeImpl > SplitWork()=0
RAbstractTBBRangeImpl(const RAbstractTBBRangeImpl &)=default
RAbstractTBBRangeImpl & operator=(const RAbstractTBBRangeImpl &)=default
RAbstractTBBRangeImpl(RAbstractTBBRangeImpl &&)=default
This class provides a simple interface to execute the same task multiple times in parallel threads,...
void ParallelFor(ROOT::TThreadExecutor &pool, std::unique_ptr< RAbstractTBBRangeImpl > rangeImpl, const std::function< void(const RAbstractTBBRangeImpl &)> &body)