60 const Size granularity,
97 template <
typename TFunctor>
100 parallelFor(scheduler, from, to, granularity, std::forward<TFunctor>(functor));
112 template <
typename TFunctor>
116 const Size granularity,
117 TFunctor&& functor) {
120 for (
Size i = n1; i < n2; ++i) {
129 template <
typename TFunctor>
131 parallelFor(scheduler, *sequence.
begin(), *sequence.
end(), std::forward<TFunctor>(functor));
#define SPH_ASSERT(x,...)
Generic wrappers of lambdas, functors and other callables.
uint32_t Size
Integral type used to index arrays (by default).
Helper objects allowing to iterate in reverse, iterate over multiple containeres, etc.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
SequentialScheduler SEQUENTIAL
Global instance of the sequential scheduler.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
virtual Optional< Size > getThreadIdx() const =0
Returns the index of the calling thread.
virtual void parallelFor(const Size from, const Size to, const Size granularity, const Function< void(Size n1, Size n2)> &functor)
Processes the given range concurrently.
virtual Size getRecommendedGranularity() const =0
Returns a value of granularity that is expected to perform well with the current thread count.
virtual SharedPtr< ITask > submit(const Function< void()> &task)=0
Submits a task to be potentially executed asynchronously.
virtual Size getThreadCnt() const =0
Returns the number of threads used by this scheduler.
Handle used to control tasks submitted into the scheduler.
virtual bool completed() const =0
Checks if the task already finished.
virtual void wait()=0
Waits till the task and all the child tasks are completed.
INLINE IndexIterator begin() const
INLINE IndexIterator end() const
Dummy scheduler that simply executes the submitted tasks sequentially on calling thread.
virtual Size getRecommendedGranularity() const override
Returns a value of granularity that is expected to perform well with the current thread count.
virtual SharedPtr< ITask > submit(const Function< void()> &task) override
Submits a task to be potentially executed asynchronously.
virtual Size getThreadCnt() const override
Returns the number of threads used by this scheduler.
static SharedPtr< SequentialScheduler > getGlobalInstance()
virtual Optional< Size > getThreadIdx() const override
Returns the index of the calling thread.
Base class for all polymorphic objects.