35 class task_group_context;
39 #if _MSC_VER || (__GNUC__==3 && __GNUC_MINOR__<3) 40 #define __TBB_TASK_BASE_ACCESS public 42 #define __TBB_TASK_BASE_ACCESS private 62 namespace interface5 {
75 static void spawn(
task& t );
109 virtual void spawn_root_and_wait(
task& first,
task*& next ) = 0;
116 virtual void enqueue(
task& t,
void* reserved ) = 0;
126 #if __TBB_TASK_ISOLATION 132 #if __TBB_TASK_GROUP_CONTEXT 167 #if __TBB_PREVIEW_CRITICAL_TASKS 193 friend class internal::scheduler;
194 friend class internal::allocate_root_proxy;
195 friend class internal::allocate_child_proxy;
196 friend class internal::allocate_continuation_proxy;
197 friend class internal::allocate_additional_child_of_proxy;
198 #if __TBB_PREVIEW_CRITICAL_TASKS 203 #if __TBB_TASK_ISOLATION 204 isolation_tag isolation;
207 intptr_t reserved_space_for_task_isolation_tag;
210 #if __TBB_TASK_GROUP_CONTEXT 226 #if __TBB_TASK_PRIORITY 234 #if __TBB_TASK_PRIORITY 284 #if __TBB_TASK_GROUP_CONTEXT 286 #if __TBB_TASK_PRIORITY 289 #if __TBB_PREVIEW_CRITICAL_TASKS 303 #if TBB_USE_CAPTURED_EXCEPTION 337 friend class internal::generic_scheduler;
341 #if TBB_USE_CAPTURED_EXCEPTION 349 version_mask = 0xFFFF,
350 traits_mask = 0xFFFFul << traits_offset
360 exact_exception = 0x0001ul << traits_offset,
362 fp_settings = 0x0002ul << traits_offset,
364 concurrent_wait = 0x0004ul << traits_offset,
365 #if TBB_USE_CAPTURED_EXCEPTION 368 default_traits = exact_exception
374 may_have_children = 1,
402 - 2 *
sizeof(uintptr_t)-
sizeof(
void*) -
sizeof(internal::context_list_node_t)
405 -
sizeof(internal::cpu_ctl_env_space)
434 #if __TBB_TASK_PRIORITY 435 intptr_t my_priority;
445 #if __TBB_TASK_PRIORITY 482 uintptr_t t = default_traits )
483 : my_kind(relation_with_parent)
484 , my_version_and_traits(3 | t)
485 , my_name(internal::CUSTOM_CTX)
493 , my_version_and_traits(3 | default_traits)
546 #if __TBB_TASK_PRIORITY 555 uintptr_t
traits()
const {
return my_version_and_traits & traits_mask; }
564 friend class internal::allocate_root_with_context_proxy;
572 template <
typename T>
576 void bind_to ( internal::generic_scheduler *local_sched );
579 void register_with ( internal::generic_scheduler *local_sched );
602 task() {prefix().extra_state=1;}
609 virtual task* execute() = 0;
625 #if __TBB_RECYCLE_TO_ENQUEUE 637 return internal::allocate_root_proxy();
640 #if __TBB_TASK_GROUP_CONTEXT 641 static internal::allocate_root_with_context_proxy allocate_root(
task_group_context& ctx ) {
643 return internal::allocate_root_with_context_proxy(ctx);
650 return *
reinterpret_cast<internal::allocate_continuation_proxy*
>(
this);
655 return *
reinterpret_cast<internal::allocate_child_proxy*
>(
this);
659 using task_base::allocate_additional_child_of;
661 #if __TBB_DEPRECATED_TASK_INTERFACE 669 using task_base::destroy;
685 __TBB_ASSERT( prefix().state==executing,
"execute not running?" );
686 prefix().state = allocated;
693 __TBB_ASSERT( prefix().state==executing,
"execute not running?" );
694 prefix().state = recycle;
699 internal::task_prefix&
p = prefix();
700 __TBB_ASSERT( prefix().state==executing||prefix().state==allocated,
"execute not running, or already recycled" );
701 __TBB_ASSERT( prefix().ref_count==0,
"no child tasks allowed when recycled as a child" );
706 p.parent = &new_parent;
707 #if __TBB_TASK_GROUP_CONTEXT 715 __TBB_ASSERT( prefix().state==executing,
"execute not running, or already recycled" );
716 __TBB_ASSERT( prefix().ref_count==0,
"no child tasks allowed when recycled for reexecution" );
717 prefix().state = reexecute;
720 #if __TBB_RECYCLE_TO_ENQUEUE 723 void recycle_to_enqueue() {
724 __TBB_ASSERT( prefix().state==executing,
"execute not running, or already recycled" );
725 prefix().state = to_enqueue;
735 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 736 internal_set_ref_count(count);
738 prefix().ref_count =
count;
753 __TBB_ASSERT( k>=0,
"task's reference count underflowed" );
762 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 763 return int(internal_decrement_ref_count());
770 using task_base::spawn;
774 prefix().owner->wait_for_all( *
this, &child );
782 root.
prefix().owner->spawn_root_and_wait( root, root.
prefix().next );
788 static void spawn_root_and_wait(
task_list& root_list );
793 prefix().owner->wait_for_all( *
this, NULL );
797 #if __TBB_TASK_PRIORITY 810 t.
prefix().owner->enqueue( t, NULL );
813 #if __TBB_TASK_PRIORITY 816 #if __TBB_PREVIEW_CRITICAL_TASKS 822 t.
prefix().owner->enqueue( t, (
void*)p );
834 #if __TBB_TASK_GROUP_CONTEXT 835 __TBB_ASSERT(!p || prefix().context == p->
prefix().context,
"The tasks must be in the same context");
840 #if __TBB_TASK_GROUP_CONTEXT 851 return (prefix().extra_state & 0x80)!=0;
865 __TBB_ASSERT( ref_count_==
int(ref_count_),
"integer overflow error");
867 return int(prefix().ref_count);
885 affinity_id
affinity()
const {
return prefix().affinity;}
894 #if __TBB_TASK_GROUP_CONTEXT 913 bool is_cancelled ()
const {
return prefix().context->is_group_execution_cancelled(); }
915 bool is_cancelled ()
const {
return false; }
918 #if __TBB_TASK_PRIORITY 919 void set_group_priority (
priority_t p ) { prefix().context->set_priority(p); }
930 friend class internal::scheduler;
931 friend class internal::allocate_root_proxy;
932 #if __TBB_TASK_GROUP_CONTEXT 933 friend class internal::allocate_root_with_context_proxy;
935 friend class internal::allocate_continuation_proxy;
936 friend class internal::allocate_child_proxy;
937 friend class internal::allocate_additional_child_of_proxy;
942 return reinterpret_cast<internal::task_prefix*
>(
const_cast<task*
>(
this))[-1];
944 #if __TBB_PREVIEW_CRITICAL_TASKS 950 #if __TBB_PREVIEW_CRITICAL_TASKS 969 #if __TBB_ALLOW_MUTABLE_FUNCTORS 980 #if __TBB_CPP11_RVALUE_REF_PRESENT 1008 task.
prefix().next = NULL;
1010 next_ptr = &task.
prefix().next;
1026 __TBB_ASSERT( !empty(),
"attempt to pop item from empty task_list" );
1027 task* result =
first;
1028 first = result->
prefix().next;
1029 if( !first ) next_ptr = &
first;
1046 t->prefix().owner->spawn( *t, *list.
next_ptr );
1053 t->prefix().owner->spawn_root_and_wait( *t, *root_list.
next_ptr );
1068 #if __TBB_TASK_GROUP_CONTEXT 1070 return &
p.allocate(bytes);
1074 p.free( *static_cast<tbb::task*>(task) );
1079 return &
p.allocate(bytes);
1083 p.free( *static_cast<tbb::task*>(task) );
1087 return &
p.allocate(bytes);
1091 p.free( *static_cast<tbb::task*>(task) );
1095 return &
p.allocate(bytes);
1099 p.free( *static_cast<tbb::task*>(task) );
__TBB_atomic kind_type my_kind
Flavor of this context: bound or isolated.
void push_back(task &task)
Push task onto back of list.
tbb::task * parent
The task whose reference count includes me.
void clear()
Clear the list.
unsigned short affinity_id
An id as used for specifying affinity.
void increment_ref_count()
Atomically increment reference count.
version_traits_word_layout
Work stealing task scheduler.
void recycle_as_continuation()
Change this to be a continuation of its former self.
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 id
Memory prefix to a task object.
#define __TBB_FetchAndDecrementWrelease(P)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
state_type
Enumeration of task states that the scheduler considers.
const isolation_tag no_isolation
internal::generic_scheduler * my_owner
Scheduler instance that registered this context in its thread specific list.
task_group_context * context()
This method is deprecated and will be removed in the future.
Interface to be implemented by all exceptions TBB recognizes and propagates across the threads...
tbb::task * next
"next" field for list of task
auto first(Container &c) -> decltype(begin(c))
Base class for types that should not be assigned.
int add_ref_count(int count)
Atomically adds to reference count and returns its new value.
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
task_list()
Construct empty list.
task that does nothing. Useful for synchronization.
priority_t group_priority() const
Retrieves current priority of the task group this task belongs to.
#define __TBB_TASK_BASE_ACCESS
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
internal::context_list_node_t my_node
Used to form the thread specific list of contexts without additional memory allocation.
__TBB_atomic reference_count ref_count
Reference count used for synchronization.
int decrement_ref_count()
Atomically decrement reference count and returns its new value.
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
static void __TBB_EXPORTED_FUNC free(task &)
task_group_context * my_parent
Pointer to the context of the parent cancellation group. NULL for isolated contexts.
allocate_additional_child_of_proxy(task &parent_)
#define __TBB_FetchAndIncrementWacquire(P)
internal::affinity_id affinity_id
An id as used for specifying affinity.
version_tag_v3 version_tag
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
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 count
intptr_t isolation_tag
A tag for task isolation.
static tbb::internal::allocate_additional_child_of_proxy allocate_additional_child_of(task &t)
Like allocate_child, except that task's parent becomes "t", not this.
bool is_cancelled() const
Returns true if the context has received cancellation request.
void set_ref_count(int count)
Set reference count.
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
scheduler * owner
Obsolete. The scheduler that owns the task.
void recycle_to_reexecute()
Schedule this for reexecution after current execute() returns.
task_group_context * group()
Pointer to the task group descriptor.
void const char const char int ITT_FORMAT __itt_group_sync p
task_group_context(internal::string_index name)
Base class for methods that became static in TBB 3.0.
bool is_critical(task &t)
uintptr_t my_cancellation_requested
Specifies whether cancellation was requested for this task group.
allocate_root_with_context_proxy(task_group_context &ctx)
tbb::task & task()
The task corresponding to this task_prefix.
bool is_stolen_task() const
True if task was stolen from the task pool of another thread.
int ref_count() const
The internal reference count.
task is in ready pool, or is going to be put there, or was just taken off.
task * self
No longer used, but retained for binary layout compatibility. Always NULL.
#define __TBB_EXPORTED_METHOD
affinity_id affinity() const
Current affinity of this task.
__itt_caller itt_caller
Used to set and maintain stack stitching point for Intel Performance Tools.
static task &__TBB_EXPORTED_FUNC allocate(size_t size)
task * execute() __TBB_override
Should be overridden by derived classes.
task is running, and will be destroyed after method execute() completes.
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 * task
task_group_context & my_context
state_type state() const
Current execution state.
unsigned char extra_state
Miscellaneous state that is not directly visible to users, stored as a byte for compactness.
unsigned char state
A task::state_type, stored as a byte for compactness.
static const int priority_stride_v4
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
uintptr_t my_state
Internal state (combination of state flags, currently only may_have_children).
void recycle_as_safe_continuation()
Recommended to use, safe variant of recycle_as_continuation.
void call_itt_notify(notify_type, void *)
task * execute() __TBB_override
Should be overridden by derived classes.
internal::tbb_exception_ptr exception_container_type
exception_container_type * my_exception
Pointer to the container storing exception being propagated across this task group.
static void spawn(task &t)
Schedule task for execution when a worker becomes available.
Used to form groups of tasks.
int depth
Obsolete. Used to be scheduling depth before TBB 2.2.
uintptr_t my_version_and_traits
Version for run-time checks and behavioral traits of the context.
#define __TBB_EXPORTED_FUNC
void move(tbb_thread &t1, tbb_thread &t2)
task * next_offloaded
Pointer to the next offloaded lower priority task.
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
context_list_node_t * my_prev
internal::string_index my_name
Decription of algorithm for scheduler based instrumentation.
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 size
Base class for user-defined tasks.
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 __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
void spawn_and_wait_for_all(task &child)
Similar to spawn followed by wait_for_all, but more efficient.
void set_affinity(affinity_id id)
Set affinity for this task.
void make_critical(task &t)
intptr_t reference_count
A reference count.
task_group_context(kind_type relation_with_parent=bound, uintptr_t t=default_traits)
Default & binding constructor.
static const int priority_critical
function_task(const F &f)
scheduler * origin
The scheduler that allocated the task, or NULL if the task is big.
task_group_context * context
Shared context that is used to communicate asynchronous state changes.
void __TBB_EXPORTED_METHOD free(task &) const
void recycle_as_child_of(task &new_parent)
Change this to be a child of new_parent.
bool cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups...
task object is on free list, or is going to be put there, or was just taken off.
uintptr_t _my_kind_aligner
Class delimiting the scope of task scheduler activity.
internal::cpu_ctl_env_space my_cpu_ctl_env
Space for platform-specific FPU settings.
task()
Default constructor.
struct ___itt_caller * __itt_caller
Base class for types that should not be copied or assigned.
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
void set_parent(task *p)
sets parent task pointer to specified value
bool empty() const
True if list if empty; false otherwise.
task object is freshly allocated or recycled.
uintptr_t traits() const
Returns the context's trait.
~task_list()
Destroys the list, but does not destroy the task objects.
virtual ~task()
Destructor.
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
Exception container that preserves the exact copy of the original exception.