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

Task type used in parallel_for. More...

#include <parallel_for.h>

Inheritance diagram for tbb::interface9::internal::start_for< Range, Body, Partitioner >:
Collaboration diagram for tbb::interface9::internal::start_for< Range, Body, Partitioner >:

Public Member Functions

 start_for (const Range &range, const Body &body, Partitioner &partitioner)
 Constructor for root task. More...
 
 start_for (start_for &parent_, typename Partitioner::split_type &split_obj)
 Splitting constructor used to generate children. More...
 
 start_for (start_for &parent_, const Range &r, depth_t d)
 Construct right child from the given range as response to the demand. More...
 
void run_body (Range &r)
 Run body for range, serves as callback for partitioner. More...
 
void offer_work (typename Partitioner::split_type &split_obj)
 spawn right task, serves as callback for partitioner More...
 
void offer_work (const Range &r, depth_t d=0)
 spawn right task, serves as callback for partitioner 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...
 
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

static void run (const Range &range, const Body &body, Partitioner &partitioner)
 
static void run (const Range &range, const Body &body, Partitioner &partitioner, task_group_context &context)
 
- 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...
 

Private Member Functions

taskexecute () __TBB_override
 execute task for parallel_for More...
 
void note_affinity (affinity_id id) __TBB_override
 Update affinity info, if any. More...
 

Private Attributes

Range my_range
 
const Body my_body
 
Partitioner::task_partition_type my_partition
 

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...
 
- Protected Member Functions inherited from tbb::task
 task ()
 Default constructor. More...
 

Detailed Description

template<typename Range, typename Body, typename Partitioner>
class tbb::interface9::internal::start_for< Range, Body, Partitioner >

Task type used in parallel_for.

Definition at line 42 of file tbb/parallel_for.h.

Constructor & Destructor Documentation

◆ start_for() [1/3]

template<typename Range , typename Body , typename Partitioner >
tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for ( const Range &  range,
const Body &  body,
Partitioner &  partitioner 
)
inline

Constructor for root task.

Definition at line 55 of file tbb/parallel_for.h.

55  :
56  my_range(range),
57  my_body(body),
58  my_partition(partitioner)
59  {
60  tbb::internal::fgt_algorithm(tbb::internal::PARALLEL_FOR_TASK, this, NULL);
61  }
Partitioner::task_partition_type my_partition
static void fgt_algorithm(string_index, void *, void *)

References tbb::internal::fgt_algorithm().

Referenced by tbb::interface9::internal::start_for< Range, Body, Partitioner >::offer_work(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::run().

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

◆ start_for() [2/3]

template<typename Range , typename Body , typename Partitioner >
tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for ( start_for< Range, Body, Partitioner > &  parent_,
typename Partitioner::split_type &  split_obj 
)
inline

Splitting constructor used to generate children.

parent_ becomes left child. Newly constructed object is right child.

Definition at line 64 of file tbb/parallel_for.h.

64  :
65  my_range(parent_.my_range, split_obj),
66  my_body(parent_.my_body),
67  my_partition(parent_.my_partition, split_obj)
68  {
69  my_partition.set_affinity(*this);
70  tbb::internal::fgt_algorithm(tbb::internal::PARALLEL_FOR_TASK, this, (void *)&parent_);
71  }
Partitioner::task_partition_type my_partition
static void fgt_algorithm(string_index, void *, void *)

References tbb::internal::fgt_algorithm(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_partition.

Here is the call graph for this function:

◆ start_for() [3/3]

template<typename Range , typename Body , typename Partitioner >
tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for ( start_for< Range, Body, Partitioner > &  parent_,
const Range &  r,
depth_t  d 
)
inline

Construct right child from the given range as response to the demand.

parent_ remains left child. Newly constructed object is right child.

Definition at line 74 of file tbb/parallel_for.h.

74  :
75  my_range(r),
76  my_body(parent_.my_body),
77  my_partition(parent_.my_partition, split())
78  {
79  my_partition.set_affinity(*this);
80  my_partition.align_depth( d );
81  tbb::internal::fgt_algorithm(tbb::internal::PARALLEL_FOR_TASK, this, (void *)&parent_);
82  }
Partitioner::task_partition_type my_partition
static void fgt_algorithm(string_index, void *, void *)
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

References d, tbb::internal::fgt_algorithm(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_partition.

Here is the call graph for this function:

Member Function Documentation

◆ execute()

template<typename Range , typename Body , typename Partitioner >
task * tbb::interface9::internal::start_for< Range, Body, Partitioner >::execute ( )
privatevirtual

execute task for parallel_for

Implements tbb::task.

Definition at line 140 of file tbb/parallel_for.h.

140  {
141  my_partition.check_being_stolen( *this );
142  my_partition.execute(*this, my_range);
143  return NULL;
144  }
Partitioner::task_partition_type my_partition

References tbb::task::execute().

Here is the call graph for this function:

◆ note_affinity()

template<typename Range , typename Body , typename Partitioner >
void tbb::interface9::internal::start_for< Range, Body, Partitioner >::note_affinity ( affinity_id  id)
inlineprivatevirtual

Update affinity info, if any.

Reimplemented from tbb::task.

Definition at line 49 of file tbb/parallel_for.h.

49  {
50  my_partition.note_affinity( id );
51  }
Partitioner::task_partition_type my_partition

References tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_partition.

◆ offer_work() [1/2]

template<typename Range , typename Body , typename Partitioner >
void tbb::interface9::internal::start_for< Range, Body, Partitioner >::offer_work ( typename Partitioner::split_type &  split_obj)
inline

spawn right task, serves as callback for partitioner

Definition at line 120 of file tbb/parallel_for.h.

120  {
121  spawn( *new( allocate_sibling(static_cast<task*>(this), sizeof(start_for)) ) start_for(*this, split_obj) );
122  }
void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.

References tbb::interface9::internal::allocate_sibling(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for().

Here is the call graph for this function:

◆ offer_work() [2/2]

template<typename Range , typename Body , typename Partitioner >
void tbb::interface9::internal::start_for< Range, Body, Partitioner >::offer_work ( const Range &  r,
depth_t  d = 0 
)
inline

spawn right task, serves as callback for partitioner

Definition at line 124 of file tbb/parallel_for.h.

124  {
125  spawn( *new( allocate_sibling(static_cast<task*>(this), sizeof(start_for)) ) start_for(*this, r, d) );
126  }
void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.
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

References tbb::interface9::internal::allocate_sibling(), d, and tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for().

Here is the call graph for this function:

◆ run() [1/2]

template<typename Range , typename Body , typename Partitioner >
static void tbb::interface9::internal::start_for< Range, Body, Partitioner >::run ( const Range &  range,
const Body &  body,
Partitioner &  partitioner 
)
inlinestatic

Definition at line 83 of file tbb/parallel_for.h.

83  {
84  if( !range.empty() ) {
85 #if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP
86  start_for& a = *new(task::allocate_root()) start_for(range,body,partitioner);
87 #else
88  // Bound context prevents exceptions from body to affect nesting or sibling algorithms,
89  // and allows users to handle exceptions safely by wrapping parallel_for in the try-block.
90  task_group_context context(PARALLEL_FOR);
91  start_for& a = *new(task::allocate_root(context)) start_for(range,body,partitioner);
92 #endif /* __TBB_TASK_GROUP_CONTEXT && !TBB_JOIN_OUTER_TASK_GROUP */
93  // REGION BEGIN
94  fgt_begin_algorithm( tbb::internal::PARALLEL_FOR_TASK, (void*)&context );
96  fgt_end_algorithm( (void*)&context );
97  // REGION END
98  }
99  }
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:663
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.
task_group_context * context()
This method is deprecated and will be removed in the future.
Definition: task.h:878
static void fgt_end_algorithm(void *)
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
Definition: task.h:808
static void fgt_begin_algorithm(string_index, void *)

References tbb::task::allocate_root(), tbb::task::context(), tbb::internal::fgt_begin_algorithm(), tbb::internal::fgt_end_algorithm(), tbb::task::spawn_root_and_wait(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for().

Referenced by tbb::parallel_for().

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

◆ run() [2/2]

template<typename Range , typename Body , typename Partitioner >
static void tbb::interface9::internal::start_for< Range, Body, Partitioner >::run ( const Range &  range,
const Body &  body,
Partitioner &  partitioner,
task_group_context context 
)
inlinestatic

Definition at line 101 of file tbb/parallel_for.h.

101  {
102  if( !range.empty() ) {
103  start_for& a = *new(task::allocate_root(context)) start_for(range,body,partitioner);
104  // REGION BEGIN
105  fgt_begin_algorithm( tbb::internal::PARALLEL_FOR_TASK, (void*)&context );
107  fgt_end_algorithm( (void*)&context );
108  // END REGION
109  }
110  }
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:663
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.
task_group_context * context()
This method is deprecated and will be removed in the future.
Definition: task.h:878
static void fgt_end_algorithm(void *)
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
Definition: task.h:808
static void fgt_begin_algorithm(string_index, void *)

References tbb::task::allocate_root(), tbb::task::context(), tbb::internal::fgt_begin_algorithm(), tbb::internal::fgt_end_algorithm(), tbb::task::spawn_root_and_wait(), and tbb::interface9::internal::start_for< Range, Body, Partitioner >::start_for().

Here is the call graph for this function:

◆ run_body()

template<typename Range , typename Body , typename Partitioner >
void tbb::interface9::internal::start_for< Range, Body, Partitioner >::run_body ( Range &  r)
inline

Run body for range, serves as callback for partitioner.

Definition at line 113 of file tbb/parallel_for.h.

113  {
114  fgt_alg_begin_body( tbb::internal::PARALLEL_FOR_TASK, (void *)const_cast<Body*>(&(this->my_body)), (void*)this );
115  my_body( r );
116  fgt_alg_end_body( (void *)const_cast<Body*>(&(this->my_body)) );
117  }
static void fgt_alg_begin_body(string_index, void *, void *)
static void fgt_alg_end_body(void *)

Member Data Documentation

◆ my_body

template<typename Range , typename Body , typename Partitioner >
const Body tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_body
private

Definition at line 44 of file tbb/parallel_for.h.

◆ my_partition

template<typename Range , typename Body , typename Partitioner >
Partitioner::task_partition_type tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_partition
private

◆ my_range

template<typename Range , typename Body , typename Partitioner >
Range tbb::interface9::internal::start_for< Range, Body, Partitioner >::my_range
private

Definition at line 43 of file tbb/parallel_for.h.


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.