31 #if __TBB_PREVIEW_CRITICAL_TASKS && __TBB_CPF_BUILD 36 #include "../rml/include/rml_tbb.h" 45 class task_group_context;
46 class allocate_root_with_context_proxy;
63 #if __TBB_TASK_PRIORITY 64 volatile intptr_t my_top_priority;
77 #if __TBB_PREVIEW_CRITICAL_TASKS && __TBB_CPF_BUILD 83 #if __TBB_PREVIEW_CRITICAL_TASKS 105 #if __TBB_ARENA_OBSERVER 106 observer_list my_observers;
110 #if __TBB_TASK_PRIORITY 111 intptr_t my_bottom_priority;
117 uintptr_t my_reload_epoch;
120 task* my_orphaned_tasks;
140 #if !__TBB_FP_CONTEXT 145 #if __TBB_TASK_GROUP_CONTEXT 158 #if __TBB_ENQUEUE_ENFORCED_CONCURRENCY 159 enum concurrency_mode {
167 concurrency_mode my_concurrency_mode;
182 void restore_priority_if_need();
194 arena (
market&,
unsigned max_num_workers,
unsigned num_reserved_slots );
197 static arena& allocate_arena(
market&,
unsigned num_slots,
unsigned num_reserved_slots );
200 return max(2u, num_slots);
209 __TBB_ASSERT( 0<
id,
"affinity id must be positive integer" );
221 static const pool_state_t SNAPSHOT_EMPTY = 0;
224 static const pool_state_t SNAPSHOT_FULL = pool_state_t(-1);
227 static const unsigned ref_external_bits = 12;
230 static const unsigned ref_external = 1;
231 static const unsigned ref_worker = 1<<ref_external_bits;
242 template<arena::new_work_type work_type>
void advertise_new_work();
246 bool is_out_of_work();
255 template<
unsigned ref_param>
256 inline void on_thread_leaving ( );
259 void dump_arena_statistics ();
263 #if __TBB_TASK_PRIORITY 266 inline bool may_have_tasks (
generic_scheduler*,
bool& tasks_present,
bool& dequeuing_possible );
272 #if __TBB_COUNT_TASK_NODES 273 intptr_t workers_task_node_count();
278 bool has_enqueued_tasks();
280 #if __TBB_ENQUEUE_ENFORCED_CONCURRENCY 281 bool recall_by_mandatory_request()
const {
283 return my_market->my_mandatory_num_requested && my_concurrency_mode==cm_normal;
287 bool must_have_concurrency()
const {
289 ( my_concurrency_mode==cm_enforced_local || my_concurrency_mode==cm_enforced_global );
292 static const size_t out_of_arena = ~size_t(0);
294 template <
bool as_worker>
297 size_t occupy_free_slot_in_range(
generic_scheduler& s,
size_t lower,
size_t upper );
303 template<
unsigned ref_param>
362 #if __TBB_STATISTICS_EARLY_DUMP 368 #if __TBB_ENQUEUE_ENFORCED_CONCURRENCY 379 is_out = is_out_of_work();
394 if( work_type == work_enqueued ) {
395 #if __TBB_ENQUEUE_ENFORCED_CONCURRENCY 397 if( my_concurrency_mode!=cm_enforced_global ) {
398 if(
my_market->mandatory_concurrency_enable(
this ) ) {
406 my_concurrency_mode = cm_enforced_local;
416 else if( work_type == wakeup ) {
427 if( is_busy_or_empty(snapshot) ) {
431 if( snapshot!=SNAPSHOT_EMPTY ) {
443 #if __TBB_ENQUEUE_ENFORCED_CONCURRENCY 444 if( work_type == work_spawned ) {
445 if( my_concurrency_mode!=cm_normal ) {
446 switch( my_concurrency_mode ) {
447 case cm_enforced_local:
455 my_concurrency_mode = cm_normal;
457 case cm_enforced_global:
458 my_market->mandatory_concurrency_disable(
this );
459 restore_priority_if_need();
Class representing where mail is put.
unsigned num_workers_active()
The number of workers active in the arena.
task_stream< num_priority_levels > my_task_stream
Task pool for the tasks scheduled via task::enqueue() method.
unsigned my_num_reserved_slots
The number of reserved slots (can be occupied only by masters).
The structure of an arena, except the array of slots.
unsigned short affinity_id
An id as used for specifying affinity.
Work stealing task scheduler.
argument_integer_type modulo_power_of_two(argument_integer_type arg, divisor_integer_type divisor)
A function to compute arg modulo divisor where divisor is a power of 2.
concurrent_monitor my_exit_monitors
Waiting object for master threads that cannot join the arena.
unsigned my_num_slots
The number of slots in the arena.
cpu_ctl_env my_cpu_ctl_env
FPU control settings of arena's master thread captured at the moment of arena instantiation.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
padded< arena_base > base_type
static generic_scheduler * local_scheduler()
Obtain the thread-local instance of the TBB scheduler.
unsigned my_num_workers_allotted
The number of workers that have been marked out by the resource manager to service the arena...
uintptr_t my_aba_epoch
ABA prevention marker.
The container for "fairness-oriented" aka "enqueued" tasks.
atomic< unsigned > my_references
Reference counter for the arena.
void atomic_fence()
Sequentially consistent full memory fence.
tbb::atomic< uintptr_t > my_pool_state
Current task pool state and estimate of available tasks amount.
static int allocation_size(unsigned num_slots)
unsigned my_max_num_workers
The number of workers requested by the master thread owning the arena.
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
mail_outbox & mailbox(affinity_id id)
Get reference to mailbox corresponding to given affinity_id.
static bool is_busy_or_empty(pool_state_t s)
No tasks to steal or snapshot is being taken.
value_type compare_and_swap(value_type value, value_type comparand)
static const intptr_t num_priority_levels
void adjust_demand(arena &, int delta)
Request that arena's need in workers should be adjusted.
new_work_type
Types of work advertised by advertise_new_work()
#define GATHER_STATISTIC(x)
void try_destroy_arena(arena *, uintptr_t aba_epoch)
Removes the arena from the market's list.
Used to form groups of tasks.
void const char const char int ITT_FORMAT __itt_group_sync s
market * my_market
The market that owns this arena.
Pads type T to fill out to a multiple of cache line size.
static int unsigned num_arena_slots(unsigned num_slots)
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 on_thread_leaving()
Notification that worker or master leaves its arena.
int my_num_workers_requested
The number of workers that are currently requested from the resource manager.
atomic< unsigned > my_limit
The maximal number of currently busy slots.
void advertise_new_work()
If necessary, raise a flag that there is new job in arena.
unsigned my_num_workers_soft_limit
Current application-imposed limit on the number of workers (see set_active_num_workers()) ...
A fast random number generator.