Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::internal::finish_reduce< Body > Class Template Reference

Task type used to combine the partial results of parallel_reduce. More...

#include <parallel_reduce.h>

Inheritance diagram for tbb::interface9::internal::finish_reduce< Body >:
Collaboration diagram for tbb::interface9::internal::finish_reduce< Body >:

Private Member Functions

 finish_reduce (reduction_context context_)
 
 ~finish_reduce ()
 
taskexecute () __TBB_override
 Should be overridden by derived classes. More...
 

Private Attributes

bool has_right_zombie
 Pointer to body, or NULL if the left child has not yet finished. More...
 
const reduction_context my_context
 
Body * my_body
 
aligned_space< Body > zombie_space
 

Friends

template<typename Range , typename Body_ , typename Partitioner >
class start_reduce
 

Additional Inherited Members

- Public Types inherited from tbb::task
enum  state_type {
  executing, reexecute, ready, allocated,
  freed, recycle
}
 Enumeration of task states that the scheduler considers. More...
 
typedef internal::affinity_id affinity_id
 An id as used for specifying affinity. More...
 
- Public Member Functions inherited from tbb::interface9::internal::flag_task
 flag_task ()
 
taskexecute () __TBB_override
 Should be overridden by derived classes. More...
 
- Public Member Functions inherited from tbb::task
virtual ~task ()
 Destructor. More...
 
internal::allocate_continuation_proxyallocate_continuation ()
 Returns proxy for overloaded new that allocates a continuation task of *this. More...
 
internal::allocate_child_proxyallocate_child ()
 Returns proxy for overloaded new that allocates a child task of *this. More...
 
void recycle_as_continuation ()
 Change this to be a continuation of its former self. More...
 
void recycle_as_safe_continuation ()
 Recommended to use, safe variant of recycle_as_continuation. More...
 
void recycle_as_child_of (task &new_parent)
 Change this to be a child of new_parent. More...
 
void recycle_to_reexecute ()
 Schedule this for reexecution after current execute() returns. More...
 
void set_ref_count (int count)
 Set reference count. More...
 
void increment_ref_count ()
 Atomically increment reference count. More...
 
int add_ref_count (int count)
 Atomically adds to reference count and returns its new value. More...
 
int decrement_ref_count ()
 Atomically decrement reference count and returns its new value. More...
 
void spawn_and_wait_for_all (task &child)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void __TBB_EXPORTED_METHOD spawn_and_wait_for_all (task_list &list)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void wait_for_all ()
 Wait for reference count to become one, and set reference count to zero. More...
 
taskparent () const
 task on whose behalf this task is working, or NULL if this is a root. More...
 
void set_parent (task *p)
 sets parent task pointer to specified value More...
 
task_group_contextcontext ()
 This method is deprecated and will be removed in the future. More...
 
task_group_contextgroup ()
 Pointer to the task group descriptor. More...
 
bool is_stolen_task () const
 True if task was stolen from the task pool of another thread. More...
 
bool is_enqueued_task () const
 True if the task was enqueued. More...
 
state_type state () const
 Current execution state. More...
 
int ref_count () const
 The internal reference count. More...
 
bool __TBB_EXPORTED_METHOD is_owned_by_current_thread () const
 Obsolete, and only retained for the sake of backward compatibility. Always returns true. More...
 
void set_affinity (affinity_id id)
 Set affinity for this task. More...
 
affinity_id affinity () const
 Current affinity of this task. More...
 
virtual void __TBB_EXPORTED_METHOD note_affinity (affinity_id id)
 Invoked by scheduler to notify task that it ran on unexpected thread. More...
 
void __TBB_EXPORTED_METHOD change_group (task_group_context &ctx)
 Moves this task from its current group into another one. More...
 
bool cancel_group_execution ()
 Initiates cancellation of all tasks in this cancellation group and its subordinate groups. More...
 
bool is_cancelled () const
 Returns true if the context has received cancellation request. More...
 
__TBB_DEPRECATED void set_group_priority (priority_t p)
 Changes priority of the task group this task belongs to. More...
 
__TBB_DEPRECATED priority_t group_priority () const
 Retrieves current priority of the task group this task belongs to. More...
 
- Static Public Member Functions inherited from tbb::interface9::internal::flag_task
static void mark_task_stolen (task &t)
 
static bool is_peer_stolen (task &t)
 
- Static Public Member Functions inherited from tbb::task
static internal::allocate_root_proxy allocate_root ()
 Returns proxy for overloaded new that allocates a root task. More...
 
static internal::allocate_root_with_context_proxy allocate_root (task_group_context &ctx)
 Returns proxy for overloaded new that allocates a root task associated with user supplied context. More...
 
static void spawn_root_and_wait (task &root)
 Spawn task allocated by allocate_root, wait for it to complete, and deallocate it. More...
 
static void spawn_root_and_wait (task_list &root_list)
 Spawn root tasks on list and wait for all of them to finish. More...
 
static void enqueue (task &t)
 Enqueue task for starvation-resistant execution. More...
 
static void enqueue (task &t, priority_t p)
 Enqueue task for starvation-resistant execution on the specified priority level. More...
 
static void enqueue (task &t, task_arena &arena, priority_t p=priority_t(0))
 Enqueue task in task_arena. More...
 
static task &__TBB_EXPORTED_FUNC self ()
 The innermost task being executed or destroyed by the current thread at the moment. More...
 
- Public Attributes inherited from tbb::interface9::internal::flag_task
tbb::atomic< bool > my_child_stolen
 
- Protected Member Functions inherited from tbb::task
 task ()
 Default constructor. More...
 

Detailed Description

template<typename Body>
class tbb::interface9::internal::finish_reduce< Body >

Task type used to combine the partial results of parallel_reduce.

Definition at line 48 of file parallel_reduce.h.

Constructor & Destructor Documentation

◆ finish_reduce()

template<typename Body >
tbb::interface9::internal::finish_reduce< Body >::finish_reduce ( reduction_context  context_)
inlineprivate

Definition at line 54 of file parallel_reduce.h.

54  :
55  has_right_zombie(false), // TODO: substitute by flag_task::child_stolen?
56  my_context(context_),
57  my_body(NULL)
58  {
59  }
bool has_right_zombie
Pointer to body, or NULL if the left child has not yet finished.

◆ ~finish_reduce()

template<typename Body >
tbb::interface9::internal::finish_reduce< Body >::~finish_reduce ( )
inlineprivate

Definition at line 60 of file parallel_reduce.h.

60  {
61  if( has_right_zombie )
62  zombie_space.begin()->~Body();
63  }
bool has_right_zombie
Pointer to body, or NULL if the left child has not yet finished.

Member Function Documentation

◆ execute()

template<typename Body >
task* tbb::interface9::internal::finish_reduce< Body >::execute ( )
inlineprivatevirtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 64 of file parallel_reduce.h.

64  {
65  if( has_right_zombie ) {
66  // Right child was stolen.
67  Body* s = zombie_space.begin();
68  my_body->join( *s );
69  // Body::join() won't be called if canceled. Defer destruction to destructor
70  }
71  if( my_context==left_child )
72  itt_store_word_with_release( static_cast<finish_reduce*>(parent())->my_body, my_body );
73  return NULL;
74  }
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
void const char const char int ITT_FORMAT __itt_group_sync s
bool has_right_zombie
Pointer to body, or NULL if the left child has not yet finished.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
Definition: task.h:865

References tbb::internal::itt_store_word_with_release(), tbb::interface9::internal::left_child, parent, and s.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ start_reduce

template<typename Body >
template<typename Range , typename Body_ , typename Partitioner >
friend class start_reduce
friend

Definition at line 76 of file parallel_reduce.h.

Member Data Documentation

◆ has_right_zombie

template<typename Body >
bool tbb::interface9::internal::finish_reduce< Body >::has_right_zombie
private

Pointer to body, or NULL if the left child has not yet finished.

Definition at line 50 of file parallel_reduce.h.

Referenced by tbb::interface9::internal::start_reduce< Range, Body, Partitioner >::execute().

◆ my_body

template<typename Body >
Body* tbb::interface9::internal::finish_reduce< Body >::my_body
private

◆ my_context

template<typename Body >
const reduction_context tbb::interface9::internal::finish_reduce< Body >::my_context
private

Definition at line 51 of file parallel_reduce.h.

◆ zombie_space

template<typename Body >
aligned_space<Body> tbb::interface9::internal::finish_reduce< Body >::zombie_space
private

The documentation for this class was generated from the following file:

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.