17#ifndef __TBB_parallel_reduce_H
18#define __TBB_parallel_reduce_H
20#define __TBB_parallel_reduce_H_include_area
47 template<
typename Body>
75 template<
typename Range,
typename Body_,
typename Partitioner>
84 template<
typename Range,
typename Body,
typename Partitioner>
96 template<
typename Body_>
101 start_reduce(
const Range& range, Body* body, Partitioner& partitioner ) :
131 static void run(
const Range& range, Body& body, Partitioner& partitioner ) {
132 if( !range.empty() ) {
133#if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
143#if __TBB_TASK_GROUP_CONTEXT
154 void offer_work(
typename Partitioner::split_type& split_obj) {
180 template<
typename Range,
typename Body,
typename Partitioner>
182 my_partition.check_being_stolen( *
this );
190 my_partition.execute(*
this, my_range);
201 template<
typename Body>
215 template<
typename Range,
typename Body_,
typename Partitioner>
221 template<
typename Range,
typename Body,
typename Partitioner>
246 static void run(
const Range& range, Body& body, Partitioner& partitioner ) {
247 if( !range.empty() ) {
248#if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
258#if __TBB_TASK_GROUP_CONTEXT
265 void offer_work(
typename Partitioner::split_type& split_obj) {
276 template<
typename Range,
typename Body,
typename Partitioner>
278 my_partition.
execute(*
this, my_range);
294 template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
361template<
typename Range,
typename Body>
368template<
typename Range,
typename Body>
375template<
typename Range,
typename Body>
382template<
typename Range,
typename Body>
389template<
typename Range,
typename Body>
394#if __TBB_TASK_GROUP_CONTEXT
397template<
typename Range,
typename Body>
404template<
typename Range,
typename Body>
411template<
typename Range,
typename Body>
418template<
typename Range,
typename Body>
425template<
typename Range,
typename Body>
436template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
437Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction ) {
446template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
447Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
451 ::run(range, body, partitioner );
457template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
458Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
462 ::run( range, body, partitioner );
468template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
469Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
473 ::run( range, body, partitioner );
479template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
480Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
484 ::run( range, body, partitioner );
488#if __TBB_TASK_GROUP_CONTEXT
491template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
492Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
502template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
503Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
507 ::run( range, body, partitioner, context );
513template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
514Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
518 ::run( range, body, partitioner, context );
524template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
525Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
529 ::run( range, body, partitioner, context );
535template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
536Value
parallel_reduce(
const Range& range,
const Value& identity,
const RealBody& real_body,
const Reduction& reduction,
540 ::run( range, body, partitioner, context );
547template<
typename Range,
typename Body>
554template<
typename Range,
typename Body>
561template<
typename Range,
typename Body>
566#if __TBB_TASK_GROUP_CONTEXT
569template<
typename Range,
typename Body>
576template<
typename Range,
typename Body>
583template<
typename Range,
typename Body>
595template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
602template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
606 ::run(range, body, partitioner);
612template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
616 ::run(range, body, partitioner);
619#if __TBB_TASK_GROUP_CONTEXT
622template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
630template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
635 ::run(range, body, partitioner, context);
641template<
typename Range,
typename Value,
typename RealBody,
typename Reduction>
646 ::run(range, body, partitioner, context);
655#undef __TBB_parallel_reduce_H_include_area
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define __TBB_DEFAULT_PARTITIONER
void const char const char int ITT_FORMAT __itt_group_sync s
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id parent
void parallel_deterministic_reduce(const Range &range, Body &body)
Parallel iteration with deterministic reduction and default simple partitioner.
void parallel_reduce(const Range &range, Body &body)
Parallel iteration with reduction and default partitioner.
Identifiers declared inside namespace internal should never be used directly by client code.
T itt_load_word_with_acquire(const tbb::atomic< T > &src)
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
Task type used to combine the partial results of parallel_reduce.
task * execute() __TBB_override
Should be overridden by derived classes.
finish_reduce(reduction_context context_)
aligned_space< Body > zombie_space
const reduction_context my_context
bool has_right_zombie
Pointer to body, or NULL if the left child has not yet finished.
Task type used to split the work of parallel_reduce.
void offer_work(typename Partitioner::split_type &split_obj)
spawn right task, serves as callback for partitioner
void offer_work(const Range &r, depth_t d=0)
spawn right task, serves as callback for partitioner
Partitioner::task_partition_type my_partition
static void run(const Range &range, Body &body, Partitioner &partitioner)
start_reduce(start_reduce &parent_, const Range &r, depth_t d)
Construct right child from the given range as response to the demand.
reduction_context my_context
start_reduce(const Range &range, Body *body, Partitioner &partitioner)
Constructor used for root task.
start_reduce(start_reduce &parent_, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
finish_reduce< Body > finish_type
task * execute() __TBB_override
Should be overridden by derived classes.
static void run(const Range &range, Body &body, Partitioner &partitioner, task_group_context &context)
void note_affinity(affinity_id id) __TBB_override
Update affinity info, if any.
void run_body(Range &r)
Run body for range.
Task type used to combine the partial results of parallel_deterministic_reduce.
task * execute() __TBB_override
Should be overridden by derived classes.
finish_deterministic_reduce(Body &body)
Task type used to split the work of parallel_deterministic_reduce.
finish_deterministic_reduce< Body > finish_type
Partitioner::task_partition_type my_partition
static void run(const Range &range, Body &body, Partitioner &partitioner)
task * execute() __TBB_override
Should be overridden by derived classes.
start_deterministic_reduce(start_deterministic_reduce &parent_, finish_type &c, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
static void run(const Range &range, Body &body, Partitioner &partitioner, task_group_context &context)
start_deterministic_reduce(const Range &range, Body &body, Partitioner &partitioner)
Constructor used for root task.
void offer_work(typename Partitioner::split_type &split_obj)
Auxiliary class for parallel_reduce; for internal use only.
lambda_reduce_body(const lambda_reduce_body &other)
lambda_reduce_body(lambda_reduce_body &other, tbb::split)
const Reduction & my_reduction
const RealBody & my_real_body
lambda_reduce_body & operator=(const lambda_reduce_body &other)
void join(lambda_reduce_body &rhs)
void operator()(Range &range)
const Value & identity_element
lambda_reduce_body(const Value &identity, const RealBody &body, const Reduction &reduction)
Join task node that contains shared flag for stealing feedback.
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
Used to form groups of tasks.
Base class for user-defined tasks.
virtual task * execute()=0
Should be overridden by derived classes.
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
void set_parent(task *p)
sets parent task pointer to specified value
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
void set_ref_count(int count)
Set reference count.
task_group_context * context()
This method is deprecated and will be removed in the future.
internal::affinity_id affinity_id
An id as used for specifying affinity.
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
Dummy type that distinguishes splitting constructor from copy constructor.