1#ifndef BVH_V2_EXECUTOR_H
2#define BVH_V2_EXECUTOR_H
13template <
typename Derived>
15 template <
typename Loop>
16 inline void for_each(
size_t begin,
size_t end,
const Loop& loop) {
17 return static_cast<Derived*
>(
this)->
for_each(begin, end, loop);
20 template <
typename T,
typename Reduce,
typename Join>
21 inline T
reduce(
size_t begin,
size_t end,
const T& init,
const Reduce&
reduce,
const Join& join) {
22 return static_cast<Derived*
>(
this)->
reduce(begin, end, init,
reduce, join);
28 template <
typename Loop>
29 void for_each(
size_t begin,
size_t end,
const Loop& loop) {
33 template <
typename T,
typename Reduce,
typename Join>
34 T
reduce(
size_t begin,
size_t end,
const T& init,
const Reduce&
reduce,
const Join&) {
50 template <
typename Loop>
51 void for_each(
size_t begin,
size_t end,
const Loop& loop) {
53 return loop(begin, end);
56 for (
size_t i = begin; i < end; i += chunk_size) {
57 size_t next = std::min(end, i + chunk_size);
63 template <
typename T,
typename Reduce,
typename Join>
64 T
reduce(
size_t begin,
size_t end,
const T& init,
const Reduce&
reduce,
const Join& join) {
73 for (
size_t i = begin; i < end; i += chunk_size) {
74 size_t next = std::min(end, i + chunk_size);
76 auto&
result = per_thread_result[thread_id];
82 join(per_thread_result[0], std::move(per_thread_result[i]));
83 return per_thread_result[0];
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
size_t get_thread_count() const
Helper object that provides iteration and reduction over one-dimensional ranges.
T reduce(size_t begin, size_t end, const T &init, const Reduce &reduce, const Join &join)
void for_each(size_t begin, size_t end, const Loop &loop)
Executor that executes in parallel using the given thread pool.
T reduce(size_t begin, size_t end, const T &init, const Reduce &reduce, const Join &join)
ParallelExecutor(ThreadPool &thread_pool, size_t parallel_threshold=1024)
size_t parallel_threshold
void for_each(size_t begin, size_t end, const Loop &loop)
Executor that executes serially.
void for_each(size_t begin, size_t end, const Loop &loop)
T reduce(size_t begin, size_t end, const T &init, const Reduce &reduce, const Join &)