|
Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
A scheduler with a customized evaluation loop. More...
#include <custom_scheduler.h>
Public Member Functions | |
| task * | receive_or_steal_task (__TBB_ISOLATION_ARG(__TBB_atomic reference_count &completion_ref_count, isolation_tag isolation)) __TBB_override |
| Try getting a task from the mailbox or stealing from another scheduler. More... | |
Static Public Member Functions | |
| static generic_scheduler * | allocate_scheduler (market &m, bool genuine) |
Private Types | |
| typedef custom_scheduler< SchedulerTraits > | scheduler_type |
Private Member Functions | |
| custom_scheduler (market &m, bool genuine) | |
| void | local_wait_for_all (task &parent, task *child) __TBB_override |
| Scheduler loop that dispatches tasks. More... | |
| void | wait_for_all (task &parent, task *child) __TBB_override |
| Entry point from client code to the scheduler loop that dispatches tasks. More... | |
| void | tally_completion_of_predecessor (task &s, __TBB_ISOLATION_ARG(task *&bypass_slot, isolation_tag isolation)) |
| Decrements ref_count of a predecessor. More... | |
| bool | process_bypass_loop (context_guard_helper< SchedulerTraits::itt_possible > &context_guard, __TBB_ISOLATION_ARG(task *t, isolation_tag isolation)) |
| Implements the bypass loop of the dispatch loop (local_wait_for_all). More... | |
Private Member Functions inherited from tbb::internal::generic_scheduler | |
| bool | is_task_pool_published () const |
| bool | is_local_task_pool_quiescent () const |
| bool | is_quiescent_local_task_pool_empty () const |
| bool | is_quiescent_local_task_pool_reset () const |
| void | attach_mailbox (affinity_id id) |
| void | init_stack_info () |
| Sets up the data necessary for the stealing limiting heuristics. More... | |
| bool | can_steal () |
| Returns true if stealing is allowed. More... | |
| void | publish_task_pool () |
| Used by workers to enter the task pool. More... | |
| void | leave_task_pool () |
| Leave the task pool. More... | |
| void | reset_task_pool_and_leave () |
| Resets head and tail indices to 0, and leaves task pool. More... | |
| task ** | lock_task_pool (arena_slot *victim_arena_slot) const |
| Locks victim's task pool, and returns pointer to it. The pointer can be NULL. More... | |
| void | unlock_task_pool (arena_slot *victim_arena_slot, task **victim_task_pool) const |
| Unlocks victim's task pool. More... | |
| void | acquire_task_pool () const |
| Locks the local task pool. More... | |
| void | release_task_pool () const |
| Unlocks the local task pool. More... | |
| task * | prepare_for_spawning (task *t) |
| Checks if t is affinitized to another thread, and if so, bundles it as proxy. More... | |
| void | commit_spawned_tasks (size_t new_tail) |
| Makes newly spawned tasks visible to thieves. More... | |
| void | commit_relocated_tasks (size_t new_tail) |
| Makes relocated tasks visible to thieves and releases the local task pool. More... | |
| task * | get_task (__TBB_ISOLATION_EXPR(isolation_tag isolation)) |
| Get a task from the local pool. More... | |
| task * | get_task (size_t T) |
| Get a task from the local pool at specified location T. More... | |
| task * | get_mailbox_task (__TBB_ISOLATION_EXPR(isolation_tag isolation)) |
| Attempt to get a task from the mailbox. More... | |
| task * | steal_task (__TBB_ISOLATION_EXPR(isolation_tag isolation)) |
| Attempts to steal a task from a randomly chosen thread/scheduler. More... | |
| task * | steal_task_from (__TBB_ISOLATION_ARG(arena_slot &victim_arena_slot, isolation_tag isolation)) |
| Steal task from another scheduler's ready pool. More... | |
| size_t | prepare_task_pool (size_t n) |
| Makes sure that the task pool can accommodate at least n more elements. More... | |
| bool | cleanup_master (bool blocking_terminate) |
| Perform necessary cleanup when a master thread stops using TBB. More... | |
| void | assert_task_pool_valid () const |
| void | attach_arena (arena *, size_t index, bool is_master) |
| void | nested_arena_entry (arena *, size_t) |
| void | nested_arena_exit () |
| void | wait_until_empty () |
| void | spawn (task &first, task *&next) __TBB_override |
| For internal use only. More... | |
| void | spawn_root_and_wait (task &first, task *&next) __TBB_override |
| For internal use only. More... | |
| void | enqueue (task &, void *reserved) __TBB_override |
| For internal use only. More... | |
| void | local_spawn (task *first, task *&next) |
| void | local_spawn_root_and_wait (task *first, task *&next) |
| void | destroy () |
| Destroy and deallocate this scheduler object. More... | |
| void | cleanup_scheduler () |
| Cleans up this scheduler (the scheduler might be destroyed). More... | |
| task & | allocate_task (size_t number_of_bytes, __TBB_CONTEXT_ARG(task *parent, task_group_context *context)) |
| Allocate task object, either from the heap or a free list. More... | |
| template<free_task_hint h> | |
| void | free_task (task &t) |
| Put task on free list. More... | |
| void | deallocate_task (task &t) |
| Return task object to the memory allocator. More... | |
| bool | is_worker () const |
| True if running on a worker thread, false otherwise. More... | |
| bool | outermost_level () const |
| True if the scheduler is on the outermost dispatch level. More... | |
| bool | master_outermost_level () const |
| True if the scheduler is on the outermost dispatch level in a master thread. More... | |
| bool | worker_outermost_level () const |
| True if the scheduler is on the outermost dispatch level in a worker thread. More... | |
| unsigned | max_threads_in_arena () |
| Returns the concurrency limit of the current arena. More... | |
| void | free_nonlocal_small_task (task &t) |
| Free a small task t that that was allocated by a different scheduler. More... | |
| generic_scheduler (market &, bool) | |
Private Member Functions inherited from tbb::internal::scheduler | |
| virtual | ~scheduler ()=0 |
| Pure virtual destructor;. More... | |
Additional Inherited Members | |
Static Private Member Functions inherited from tbb::internal::generic_scheduler | |
| static bool | is_version_3_task (task &t) |
| static bool | is_proxy (const task &t) |
| True if t is a task_proxy. More... | |
| static generic_scheduler * | create_master (arena *a) |
| Initialize a scheduler for a master thread. More... | |
| static generic_scheduler * | create_worker (market &m, size_t index, bool geniune) |
| Initialize a scheduler for a worker thread. More... | |
| static void | cleanup_worker (void *arg, bool worker) |
| Perform necessary cleanup when a worker thread finishes. More... | |
| static task * | plugged_return_list () |
| Special value used to mark my_return_list as not taking any more entries. More... | |
Private Attributes inherited from tbb::internal::generic_scheduler | |
| uintptr_t | my_stealing_threshold |
| Position in the call stack specifying its maximal filling when stealing is still allowed. More... | |
| market * | my_market |
| The market I am in. More... | |
| FastRandom | my_random |
| Random number generator used for picking a random victim from which to steal. More... | |
| task * | my_free_list |
| Free list of small tasks that can be reused. More... | |
| task * | my_dummy_task |
| Fake root task created by slave threads. More... | |
| long | my_ref_count |
| Reference count for scheduler. More... | |
| bool | my_auto_initialized |
| True if *this was created by automatic TBB initialization. More... | |
| __TBB_atomic intptr_t | my_small_task_count |
| Number of small tasks that have been allocated by this scheduler. More... | |
| task * | my_return_list |
| List of small tasks that have been returned to this scheduler by other schedulers. More... | |
Private Attributes inherited from tbb::internal::intrusive_list_node | |
| intrusive_list_node * | my_prev_node |
| intrusive_list_node * | my_next_node |
Private Attributes inherited from tbb::internal::scheduler_state | |
| size_t | my_arena_index |
| Index of the arena slot the scheduler occupies now, or occupied last time. More... | |
| arena_slot * | my_arena_slot |
| Pointer to the slot in the arena we own at the moment. More... | |
| arena * | my_arena |
| The arena that I own (if master) or am servicing at the moment (if worker) More... | |
| task * | my_innermost_running_task |
| Innermost task whose task::execute() is running. A dummy task on the outermost level. More... | |
| mail_inbox | my_inbox |
| affinity_id | my_affinity_id |
| The mailbox id assigned to this scheduler. More... | |
| scheduler_properties | my_properties |
Static Private Attributes inherited from tbb::internal::generic_scheduler | |
| static const size_t | quick_task_size = 256-task_prefix_reservation_size |
| If sizeof(task) is <=quick_task_size, it is handled on a free list instead of malloc'd. More... | |
| static const size_t | null_arena_index = ~size_t(0) |
| static const size_t | min_task_pool_size = 64 |
A scheduler with a customized evaluation loop.
The customization can use SchedulerTraits to make decisions without needing a run-time check.
Definition at line 52 of file custom_scheduler.h.
|
private |
Definition at line 53 of file custom_scheduler.h.
|
inlineprivate |
Definition at line 55 of file custom_scheduler.h.
|
inlinestatic |
Definition at line 137 of file custom_scheduler.h.
References ITT_SYNC_CREATE, tbb::internal::NFS_Allocate(), p, and s.
|
privatevirtual |
Scheduler loop that dispatches tasks.
If child is non-NULL, it is dispatched first. Then, until "parent" has a reference count of 1, other task are dispatched or stolen.
Implements tbb::internal::generic_scheduler.
Definition at line 557 of file custom_scheduler.h.
References __TBB_ASSERT, __TBB_control_consistency_helper, __TBB_FetchAndDecrementWrelease, __TBB_ISOLATION_ARG, __TBB_ISOLATION_EXPR, tbb::task::allocated, tbb::internal::ConcurrentWaitsEnabled(), tbb::internal::es_ref_count_active, tbb::internal::is_critical(), tbb::internal::governor::is_set(), tbb::internal::task_prefix::isolation, ITT_NOTIFY, ITT_SYNC_CREATE, tbb::task_group_context::may_have_children, tbb::internal::task_prefix::next, tbb::internal::no_isolation, tbb::internal::num_priority_levels, parent, tbb::task::parent(), tbb::task::prefix(), tbb::task::recycle, tbb::internal::task_prefix::state, and sync_releasing.
|
private |
Implements the bypass loop of the dispatch loop (local_wait_for_all).
Definition at line 389 of file custom_scheduler.h.
References __TBB_ASSERT, __TBB_ASSERT_EX, __TBB_fallthrough, __TBB_ISOLATION_ARG, __TBB_ISOLATION_EXPR, tbb::task::allocated, tbb::internal::assert_task_valid(), tbb::internal::task_prefix::context, tbb::task::execute(), tbb::task::executing, GATHER_STATISTIC, tbb::internal::is_critical(), tbb::task::is_enqueued_task(), tbb::internal::task_prefix::isolation, tbb::task_group_context::itt_caller, ITT_NOTIFY, ITT_STACK, tbb::task_group_context::my_cancellation_requested, tbb::internal::task_prefix::next, tbb::internal::task_prefix::next_offloaded, tbb::internal::no_isolation, tbb::internal::task_prefix::owner, p, tbb::task::parent(), tbb::internal::poison_pointer(), tbb::task::prefix(), tbb::task::ready, tbb::task::recycle, tbb::task::reexecute, tbb::internal::task_prefix::ref_count, tbb::internal::reset_extra_state(), s, tbb::internal::context_guard_helper< T >::set_ctx(), tbb::internal::task_prefix::state, tbb::task::state(), tbb::internal::arena::wakeup, and tbb::task::~task().
|
virtual |
Try getting a task from the mailbox or stealing from another scheduler.
Returns the stolen task or NULL if all attempts fail.
Implements tbb::internal::generic_scheduler.
Definition at line 156 of file custom_scheduler.h.
References __TBB_ASSERT, __TBB_control_consistency_helper, __TBB_ISOLATION_ARG, __TBB_ISOLATION_EXPR, __TBB_Yield, GATHER_STATISTIC, int, tbb::internal::is_critical(), ITT_NOTIFY, tbb::internal::no_isolation, p, tbb::internal::prolonged_pause(), and sync_cancel.
|
inlineprivate |
Decrements ref_count of a predecessor.
If it achieves 0, the predecessor is scheduled for execution. When changing, remember that this is a hot path function.
Definition at line 72 of file custom_scheduler.h.
References __TBB_ASSERT, __TBB_control_consistency_helper, __TBB_FetchAndDecrementWrelease, tbb::internal::arena::enqueue_task(), tbb::internal::es_ref_count_active, tbb::internal::is_critical(), ITT_NOTIFY, tbb::internal::generic_scheduler::local_spawn(), tbb::internal::scheduler_state::my_arena, tbb::internal::generic_scheduler::my_random, tbb::internal::task_prefix::next, tbb::internal::no_isolation, p, tbb::task::prefix(), s, and sync_releasing.
|
inlineprivatevirtual |
Entry point from client code to the scheduler loop that dispatches tasks.
The method is virtual, but the *this object is used only for sake of dispatching on the correct vtable, not necessarily the correct *this object. The correct *this object is looked up in TLS.
Implements tbb::internal::scheduler.
Definition at line 65 of file custom_scheduler.h.
References tbb::internal::governor::local_scheduler(), and parent.