tbb::internal::sum_node< Range, Body > Class Template Reference
Algorithms

Split work to be done in the scan. More...

`#include <parallel_scan.h>`

Inheritance diagram for tbb::internal::sum_node< Range, Body >:
Collaboration diagram for tbb::internal::sum_node< Range, Body >:

## Public Attributes

final_sum_type * | my_incoming
final_sum_type * | my_body
Body * | my_stuff_last

## Private Types

typedef final_sum< Range, Body > | final_sum_type

## Private Member Functions

| sum_node (const Range range_, bool left_is_final_)
task * | create_child (const Range &range_, final_sum_type &f, sum_node *n, final_sum_type *incoming_, Body *stuff_last_)
task * | execute () __TBB_override
| Should be overridden by derived classes. More...

## Private Attributes

final_sum_type * | my_left_sum
sum_node * | my_left
sum_node * | my_right
bool | my_left_is_final
Range | my_range

## Friends

template<typename Range_ , typename Body_ , typename Partitioner_ >
class | start_scan
template<typename Range_ , typename Body_ >
class | finish_scan

## 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::task
virtual | ~task ()
| Destructor. More...
internal::allocate_continuation_proxy & | allocate_continuation ()
| Returns proxy for overloaded new that allocates a continuation task of *this. More...
internal::allocate_child_proxy & | allocate_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...
task * | parent () 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_context * | context ()
| This method is deprecated and will be removed in the future. More...
task_group_context * | group ()
| 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::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 __TBB_DEPRECATED void | enqueue (task &t, priority_t p)
| Enqueue task for starvation-resistant execution on the specified priority level. More...
static __TBB_DEPRECATED 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...
Protected Member Functions inherited from tbb::task
| task ()
| Default constructor. More...

## Detailed Description

### template<typename Range, typename Body>
class tbb::internal::sum_node< Range, Body >

Split work to be done in the scan.

Definition at line 82 of file parallel_scan.h.

## Member Typedef Documentation

## final_sum_type

template<typename Range, typename Body>

typedef final_sum<Range,Body> tbb::internal::sum_node< Range, Body >::final_sum_type

private

Definition at line 83 of file parallel_scan.h.

## Constructor & Destructor Documentation

## sum_node()

template<typename Range, typename Body>

tbb::internal::sum_node< Range, Body >::sum_node | ( | const Range | range_,
|  | bool | left_is_final_
| ) |  |

inline private

Definition at line 94 of file parallel_scan.h.

:
my_stuff_last(NULL),
my_left_sum(NULL),
my_left(NULL),
my_right(NULL),
my_left_is_final(left_is_final_),
my_range(range_)
{
// Poison fields that will be set by second pass.
poison_pointer(my_body);
poison_pointer(my_incoming);
}

References tbb::internal::sum_node< Range, Body >::my_body, tbb::internal::sum_node< Range, Body >::my_incoming, and tbb::internal::poison_pointer().

Here is the call graph for this function:

## Member Function Documentation

## create_child()

template<typename Range, typename Body>

task* tbb::internal::sum_node< Range, Body >::create_child | ( | const Range & | range_,
|  | final_sum_type & | f,
|  | sum_node< Range, Body > * | n,
|  | final_sum_type * | incoming_,
|  | Body * | stuff_last_
| ) |  |

inline private

Definition at line 106 of file parallel_scan.h.

{
if( !n ) {
f.recycle_as_child_of( *this );
f.finish_construction( range_, stuff_last_ );
return &f;
} else {
n->my_body = &f;
n->my_incoming = incoming_;
n->my_stuff_last = stuff_last_;
return n;
}
}

References tbb::internal::final_sum< Range, Body >::finish_construction(), tbb::internal::sum_node< Range, Body >::my_body, tbb::internal::sum_node< Range, Body >::my_incoming, tbb::internal::sum_node< Range, Body >::my_stuff_last, and tbb::task::recycle_as_child_of().

Referenced by tbb::internal::sum_node< Range, Body >::execute().

Here is the call graph for this function:
Here is the caller graph for this function:

## execute()

template<typename Range, typename Body>

task* tbb::internal::sum_node< Range, Body >::execute | ( |  | ) |

inline private virtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 118 of file parallel_scan.h.

{
if( my_body ) {
if( my_incoming )
my_left_sum->my_body.reverse_join( my_incoming->my_body );
recycle_as_continuation();
sum_node& c = *this;
task* b = c.create_child(Range(my_range,split()),*my_left_sum,my_right,my_left_sum,my_stuff_last);
task* a = my_left_is_final ? NULL : c.create_child(my_range,*my_body,my_left,my_incoming,NULL);
set_ref_count( (a!=NULL)+(b!=NULL) );
my_body = NULL;
if( a ) spawn(*b);
else a = b;
return a;
} else {
return NULL;
}
}

References tbb::internal::sum_node< Range, Body >::create_child(), tbb::internal::final_sum< Range, Body >::my_body, tbb::internal::sum_node< Range, Body >::my_body, tbb::internal::sum_node< Range, Body >::my_incoming, tbb::internal::sum_node< Range, Body >::my_left, tbb::internal::sum_node< Range, Body >::my_left_is_final, tbb::internal::sum_node< Range, Body >::my_left_sum, tbb::internal::sum_node< Range, Body >::my_range, tbb::internal::sum_node< Range, Body >::my_right, tbb::internal::sum_node< Range, Body >::my_stuff_last, tbb::task::recycle_as_continuation(), and tbb::task::set_ref_count().

Here is the call graph for this function:

## Friends And Related Function Documentation

## finish_scan

template<typename Range, typename Body>
template<typename Range_ , typename Body_ >

friend class finish_scan

friend

Definition at line 139 of file parallel_scan.h.

## start_scan

template<typename Range, typename Body>
template<typename Range_ , typename Body_ , typename Partitioner_ >

friend class start_scan

friend

Definition at line 136 of file parallel_scan.h.

## Member Data Documentation

## my_body

template<typename Range, typename Body>

final_sum_type* tbb::internal::sum_node< Range, Body >::my_body

Definition at line 86 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::create_child(), tbb::internal::sum_node< Range, Body >::execute(), tbb::internal::start_scan< Range, Body, Partitioner >::run(), and tbb::internal::sum_node< Range, Body >::sum_node().

## my_incoming

template<typename Range, typename Body>

final_sum_type* tbb::internal::sum_node< Range, Body >::my_incoming

Definition at line 85 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::create_child(), tbb::internal::sum_node< Range, Body >::execute(), tbb::internal::start_scan< Range, Body, Partitioner >::run(), and tbb::internal::sum_node< Range, Body >::sum_node().

## my_left

template<typename Range, typename Body>

sum_node* tbb::internal::sum_node< Range, Body >::my_left

private

Definition at line 90 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::execute(), tbb::internal::finish_scan< Range, Body >::execute(), and tbb::internal::start_scan< Range, Body, Partitioner >::execute().

## my_left_is_final

template<typename Range, typename Body>

bool tbb::internal::sum_node< Range, Body >::my_left_is_final

private

Definition at line 92 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::execute(), and tbb::internal::finish_scan< Range, Body >::execute().

## my_left_sum

template<typename Range, typename Body>

final_sum_type* tbb::internal::sum_node< Range, Body >::my_left_sum

private

Definition at line 89 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::execute(), tbb::internal::finish_scan< Range, Body >::execute(), and tbb::internal::start_scan< Range, Body, Partitioner >::execute().

## my_range

template<typename Range, typename Body>

Range tbb::internal::sum_node< Range, Body >::my_range

private

Definition at line 93 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::execute().

## my_right

template<typename Range, typename Body>

sum_node* tbb::internal::sum_node< Range, Body >::my_right

private

Definition at line 91 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::execute(), tbb::internal::finish_scan< Range, Body >::execute(), and tbb::internal::start_scan< Range, Body, Partitioner >::execute().

## my_stuff_last

template<typename Range, typename Body>

Body* tbb::internal::sum_node< Range, Body >::my_stuff_last

Definition at line 87 of file parallel_scan.h.

Referenced by tbb::internal::sum_node< Range, Body >::create_child(), tbb::internal::sum_node< Range, Body >::execute(), and tbb::internal::start_scan< Range, Body, Partitioner >::run().

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

- parallel_scan.h

tbb::task::set_ref_count
void set_ref_count(int count)
Set reference count.
Definition: task.h:750
tbb::internal::sum_node::my_body
final_sum_type * my_body
Definition: parallel_scan.h:86
tbb::internal::poison_pointer
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:305
tbb::internal::sum_node::my_left_is_final
bool my_left_is_final
Definition: parallel_scan.h:92
tbb::internal::sum_node::my_incoming
final_sum_type * my_incoming
Definition: parallel_scan.h:85
tbb::task::recycle_as_continuation
void recycle_as_continuation()
Change this to be a continuation of its former self.
Definition: task.h:700
tbb::task::task
task()
Default constructor.
Definition: task.h:614
tbb::internal::sum_node::my_left
sum_node * my_left
Definition: parallel_scan.h:90
tbb::internal::sum_node::my_stuff_last
Body * my_stuff_last
Definition: parallel_scan.h:87
tbb::internal::sum_node::my_range
Range my_range
Definition: parallel_scan.h:93
tbb::internal::sum_node::sum_node
sum_node(const Range range_, bool left_is_final_)
Definition: parallel_scan.h:94
tbb::internal::sum_node::my_right
sum_node * my_right
Definition: parallel_scan.h:91
tbb::internal::final_sum::my_body
Body my_body
Definition: parallel_scan.h:52
tbb::internal::sum_node::my_left_sum
final_sum_type * my_left_sum
Definition: parallel_scan.h:89

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.