tbb::internal::market Class Reference

`#include <market.h>`

Inheritance diagram for tbb::internal::market:
Collaboration diagram for tbb::internal::market:

## Public Member Functions

void | try_destroy_arena (arena *, uintptr_t aba_epoch)
| Removes the arena from the market's list. More...
void | detach_arena (arena &)
| Removes the arena from the market's list. More...
bool | release (bool is_public, bool blocking_terminate)
| Decrements market's refcount and destroys it in the end. More...
void | adjust_demand (arena &, int delta)
| Request that arena's need in workers should be adjusted. More...
bool | must_join_workers () const
| Used when RML asks for join mode during workers termination. More...
size_t | worker_stack_size () const
| Returns the requested stack size of worker threads. More...

## Static Public Member Functions

static arena * | create_arena (int num_slots, int num_reserved_slots, size_t stack_size)
| Creates an arena object. More...
static void | set_active_num_workers (unsigned w)
| Set number of active workers. More...
static unsigned | app_parallelism_limit ()
| Reports active parallelism level according to user's settings. More...
static unsigned | max_num_workers ()

## Private Types

typedef intrusive_list< arena > | arena_list_type
typedef intrusive_list< generic_scheduler > | scheduler_list_type
typedef scheduler_mutex_type | global_market_mutex_type
typedef spin_rw_mutex | arenas_list_mutex_type
| Lightweight mutex guarding accounting operations with arenas list. More...

## Private Member Functions

| market (unsigned workers_soft_limit, unsigned workers_hard_limit, size_t stack_size)
| Constructor. More...
void | destroy ()
| Destroys and deallocates market object created by market::create() More...
int | update_workers_request ()
| Recalculates the number of workers requested from RML and updates the allotment. More...
void | update_allotment (unsigned effective_soft_limit)
| Recalculates the number of workers assigned to each arena in the list. More...
arena * | arena_in_need (arena *prev_arena)
| Returns next arena that needs more workers, or NULL. More...
void | assert_market_valid () const
void | insert_arena_into_list (arena &a)
void | remove_arena_from_list (arena &a)
arena * | arena_in_need (arena_list_type &arenas, arena *hint)
int | update_allotment (arena_list_type &arenas, int total_demand, int max_workers)
bool | is_arena_in_list (arena_list_type &arenas, arena *a)
version_type | version () const __TBB_override
unsigned | max_job_count () const __TBB_override
size_t | min_stack_size () const __TBB_override
policy_type | policy () const __TBB_override
job * | create_one_job () __TBB_override
void | cleanup (job &j) __TBB_override
void | acknowledge_close_connection () __TBB_override
void | process (job &j) __TBB_override
Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Static Private Member Functions

static market & | global_market (bool is_public, unsigned max_num_workers=0, size_t stack_size=0)
| Factory method creating new market object. More...

## Private Attributes

arenas_list_mutex_type | my_arenas_list_mutex
rml::tbb_server * | my_server
| Pointer to the RML server object that services this TBB instance. More...
unsigned | my_num_workers_hard_limit
| Maximal number of workers allowed for use by the underlying resource manager. More...
unsigned | my_num_workers_soft_limit
| Current application-imposed limit on the number of workers (see set_active_num_workers()) More...
int | my_num_workers_requested
| Number of workers currently requested from RML. More...
atomic< unsigned > | my_first_unused_worker_idx
| First unused index of worker. More...
int | my_total_demand
| Number of workers that were requested by all arenas. More...
arena_list_type | my_arenas
| List of registered arenas. More...
arena * | my_next_arena
| The first arena to be checked when idle worker seeks for an arena to enter. More...
uintptr_t | my_arenas_aba_epoch
| ABA prevention marker to assign to newly created arenas. More...
unsigned | my_ref_count
| Reference count controlling market object lifetime. More...
unsigned | my_public_ref_count
| Count of master threads attached. More...
size_t | my_stack_size
| Stack size of worker threads. More...
bool | my_join_workers
| Shutdown mode. More...
unsigned | my_workers_soft_limit_to_report
| Either workers soft limit to be reported via runtime_warning() or skip_soft_limit_warning. More...

## Static Private Attributes

static market * | theMarket
| Currently active global market. More...
static global_market_mutex_type | theMarketMutex
| Mutex guarding creation/destruction of theMarket, insertions/deletions in my_arenas, and cancellation propagation. More...
static const unsigned | skip_soft_limit_warning = ~0U
| The value indicating that the soft limit warning is unnecessary. More...

## Friends

class | generic_scheduler
class | arena
class | tbb::interface7::internal::task_arena_base
template<typename SchedulerTraits >
class | custom_scheduler
class | tbb::task_group_context
void | ITT_DoUnsafeOneTimeInitialization ()

## Detailed Description

Definition at line 45 of file market.h.

## Member Typedef Documentation

## arena_list_type

typedef intrusive_list<arena> tbb::internal::market::arena_list_type

private

Definition at line 54 of file market.h.

## arenas_list_mutex_type

typedef spin_rw_mutex tbb::internal::market::arenas_list_mutex_type

private

Lightweight mutex guarding accounting operations with arenas list.

Definition at line 66 of file market.h.

## global_market_mutex_type

typedef scheduler_mutex_type tbb::internal::market::global_market_mutex_type

private

Definition at line 60 of file market.h.

## scheduler_list_type

typedef intrusive_list<generic_scheduler> tbb::internal::market::scheduler_list_type

private

Definition at line 55 of file market.h.

## Constructor & Destructor Documentation

## market()

tbb::internal::market::market | ( | unsigned | workers_soft_limit,
|  | unsigned | workers_hard_limit,
|  | size_t | stack_size
| ) |  |

private

Constructor.

Definition at line 64 of file market.cpp.

: my_num_workers_hard_limit(workers_hard_limit)
, my_num_workers_soft_limit(workers_soft_limit)
#if __TBB_TASK_PRIORITY
, my_global_top_priority(normalized_normal_priority)
, my_global_bottom_priority(normalized_normal_priority)
#endif /* __TBB_TASK_PRIORITY */
, my_ref_count(1)
, my_stack_size(stack_size)
, my_workers_soft_limit_to_report(workers_soft_limit)
{
#if __TBB_TASK_PRIORITY
__TBB_ASSERT( my_global_reload_epoch == 0, NULL );
my_priority_levels[normalized_normal_priority].workers_available = my_num_workers_soft_limit;
#endif /* __TBB_TASK_PRIORITY */
// Once created RML server will start initializing workers that will need
// global market instance to get worker stack size
my_server = governor::create_rml_server( *this );
__TBB_ASSERT( my_server, "Failed to create RML server" );
}

References __TBB_ASSERT, tbb::internal::governor::create_rml_server(), my_num_workers_soft_limit, and my_server.

Referenced by global_market().

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

## Member Function Documentation

## acknowledge_close_connection()

void tbb::internal::market::acknowledge_close_connection | ( |  | ) |

private

Definition at line 695 of file market.cpp.

{
destroy();
}

References destroy().

Here is the call graph for this function:

## adjust_demand()

void tbb::internal::market::adjust_demand | ( | arena & | a,
|  | int | delta
| ) |  |

Request that arena's need in workers should be adjusted.

Concurrent invocations are possible only on behalf of different arenas.

Definition at line 557 of file market.cpp.

{
__TBB_ASSERT( theMarket, "market instance was destroyed prematurely?" );
if ( !delta )
return;
my_arenas_list_mutex.lock();
int prev_req = a.my_num_workers_requested;
a.my_num_workers_requested += delta;
if ( a.my_num_workers_requested <= 0 ) {
a.my_num_workers_allotted = 0;
if ( prev_req <= 0 ) {
my_arenas_list_mutex.unlock();
return;
}
delta = -prev_req;
}
else if ( prev_req < 0 ) {
delta = a.my_num_workers_requested;
}
my_total_demand += delta;
unsigned effective_soft_limit = my_num_workers_soft_limit;
if (my_mandatory_num_requested > 0) {
__TBB_ASSERT(effective_soft_limit == 0, NULL);
effective_soft_limit = 1;
}
#if !__TBB_TASK_PRIORITY
update_allotment(effective_soft_limit);
#else /* !__TBB_TASK_PRIORITY */
intptr_t p = a.my_top_priority;
priority_level_info &pl = my_priority_levels[p];
pl.workers_requested += delta;
__TBB_ASSERT( pl.workers_requested >= 0, NULL );
if ( a.my_num_workers_requested <= 0 ) {
if ( a.my_top_priority != normalized_normal_priority ) {
GATHER_STATISTIC( ++governor::local_scheduler_if_initialized()->my_counters.arena_prio_resets );
update_arena_top_priority( a, normalized_normal_priority );
}
a.my_bottom_priority = normalized_normal_priority;
}
if ( p == my_global_top_priority ) {
if ( !pl.workers_requested ) {
while ( --p >= my_global_bottom_priority && !my_priority_levels[p].workers_requested )
continue;
if ( p < my_global_bottom_priority )
reset_global_priority();
else
update_global_top_priority(p);
}
my_priority_levels[my_global_top_priority].workers_available = effective_soft_limit;
update_allotment( my_global_top_priority );
}
else if ( p > my_global_top_priority ) {
__TBB_ASSERT( pl.workers_requested > 0, NULL );
// TODO: investigate if the following invariant is always valid
__TBB_ASSERT( a.my_num_workers_requested >= 0, NULL );
update_global_top_priority(p);
a.my_num_workers_allotted = min( (int)effective_soft_limit, a.my_num_workers_requested );
my_priority_levels[p - 1].workers_available = effective_soft_limit - a.my_num_workers_allotted;
update_allotment( p - 1 );
}
else if ( p == my_global_bottom_priority ) {
if ( !pl.workers_requested ) {
while ( ++p <= my_global_top_priority && !my_priority_levels[p].workers_requested )
continue;
if ( p > my_global_top_priority )
reset_global_priority();
else
my_global_bottom_priority = p;
}
else
update_allotment( p );
}
else if ( p < my_global_bottom_priority ) {
int prev_bottom = my_global_bottom_priority;
my_global_bottom_priority = p;
update_allotment( prev_bottom );
}
else {
__TBB_ASSERT( my_global_bottom_priority < p && p < my_global_top_priority, NULL );
update_allotment( p );
}
__TBB_ASSERT( my_global_top_priority >= a.my_top_priority || a.my_num_workers_requested<=0, NULL );
assert_market_valid();
#endif /* !__TBB_TASK_PRIORITY */
if ( delta > 0 ) {
// can't overflow soft_limit, but remember values request by arenas in
// my_total_demand to not prematurely release workers to RML
if ( my_num_workers_requested+delta > (int)effective_soft_limit)
delta = effective_soft_limit - my_num_workers_requested;
} else {
// the number of workers should not be decreased below my_total_demand
if ( my_num_workers_requested+delta < my_total_demand )
delta = min(my_total_demand, (int)effective_soft_limit) - my_num_workers_requested;
}
my_num_workers_requested += delta;
__TBB_ASSERT( my_num_workers_requested <= (int)effective_soft_limit, NULL );
my_arenas_list_mutex.unlock();
// Must be called outside of any locks
my_server->adjust_job_count_estimate( delta );
GATHER_STATISTIC( governor::local_scheduler_if_initialized() ? ++governor::local_scheduler_if_initialized()->my_counters.gate_switches : 0 );
}

References __TBB_ASSERT, assert_market_valid(), GATHER_STATISTIC, tbb::internal::governor::local_scheduler_if_initialized(), tbb::spin_rw_mutex_v3::lock(), tbb::internal::min(), my_arenas_list_mutex, tbb::internal::arena_base::my_num_workers_allotted, my_num_workers_requested, tbb::internal::arena_base::my_num_workers_requested, my_num_workers_soft_limit, my_server, my_total_demand, p, theMarket, tbb::spin_rw_mutex_v3::unlock(), and update_allotment().

Referenced by tbb::internal::arena::advertise_new_work(), tbb::internal::arena::is_out_of_work(), tbb::internal::generic_scheduler::nested_arena_entry(), and tbb::internal::generic_scheduler::nested_arena_exit().

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

## app_parallelism_limit()

unsigned tbb::internal::market::app_parallelism_limit | ( |  | ) |

static

Reports active parallelism level according to user's settings.

Definition at line 512 of file tbb_main.cpp.

{
return allowed_parallelism_ctl.active_value_if_present();
}

References tbb::internal::allowed_parallelism_control::active_value_if_present(), and tbb::internal::allowed_parallelism_ctl.

Referenced by tbb::internal::calc_workers_soft_limit(), and global_market().

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

## arena_in_need() [1/2]

arena* tbb::internal::market::arena_in_need | ( | arena * | prev_arena | ) |

inline private

Returns next arena that needs more workers, or NULL.

Definition at line 221 of file market.h.

{
if(__TBB_load_with_acquire(my_total_demand) <= 0)
return NULL;
arenas_list_mutex_type::scoped_lock lock(my_arenas_list_mutex, /*is_writer=*/false);
arena* a = NULL;
// Checks if arena is alive or not
if ( is_arena_in_list( my_arenas, prev_arena ) ) {
a = arena_in_need( my_arenas, prev_arena );
} else {
a = arena_in_need( my_arenas, my_next_arena );
if (a) {
as_atomic(my_next_arena) = a; // a subject for innocent data race under the reader lock
// TODO: rework global round robin policy to local or random to avoid this write
}
}
return a;
}

References tbb::internal::__TBB_load_with_acquire(), tbb::internal::as_atomic(), is_arena_in_list(), lock, my_arenas, my_arenas_list_mutex, my_next_arena, and my_total_demand.

Referenced by process().

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

## arena_in_need() [2/2]

arena * tbb::internal::market::arena_in_need | ( | arena_list_type & | arenas,
|  | arena * | hint
| ) |  |

private

This method must be invoked under my_arenas_list_mutex.

Definition at line 374 of file market.cpp.

{
if ( arenas.empty() )
return NULL;
arena_list_type::iterator it = hint;
__TBB_ASSERT( it != arenas.end(), NULL );
do {
arena& a = *it;
if ( ++it == arenas.end() )
it = arenas.begin();
if( a.num_workers_active() < a.my_num_workers_allotted ) {
a.my_references += arena::ref_worker;
return &a;
}
} while ( it != hint );
return NULL;
}

References __TBB_ASSERT, tbb::internal::intrusive_list_base< List, T >::begin(), tbb::internal::intrusive_list_base< List, T >::empty(), tbb::internal::intrusive_list_base< List, T >::end(), tbb::internal::arena_base::my_num_workers_allotted, tbb::internal::arena_base::my_references, tbb::internal::arena::num_workers_active(), and tbb::internal::arena::ref_worker.

Here is the call graph for this function:

## assert_market_valid()

void tbb::internal::market::assert_market_valid | ( |  | ) | const

inline private

Definition at line 241 of file market.h.

{}

Referenced by adjust_demand(), and try_destroy_arena().

Here is the caller graph for this function:

## cleanup()

void tbb::internal::market::cleanup | ( | job & | j | ) |

private

Definition at line 681 of file market.cpp.

{
__TBB_ASSERT( theMarket != this, NULL );
generic_scheduler& s = static_cast<generic_scheduler&>(j);
generic_scheduler* mine = governor::local_scheduler_if_initialized();
__TBB_ASSERT( !mine || mine->is_worker(), NULL );
if( mine!=&s ) {
governor::assume_scheduler( &s );
generic_scheduler::cleanup_worker( &s, mine!=NULL );
governor::assume_scheduler( mine );
} else {
generic_scheduler::cleanup_worker( &s, true );
}
}

References __TBB_ASSERT, tbb::internal::governor::assume_scheduler(), tbb::internal::generic_scheduler::cleanup_worker(), tbb::internal::generic_scheduler::is_worker(), tbb::internal::governor::local_scheduler_if_initialized(), s, and theMarket.

Here is the call graph for this function:

## create_arena()

arena * tbb::internal::market::create_arena | ( | int | num_slots,
|  | int | num_reserved_slots,
|  | size_t | stack_size
| ) |  |

static

Creates an arena object.

If necessary, also creates global market instance, and boosts its ref count. Each call to create_arena() must be matched by the call to arena::free_arena().

Definition at line 308 of file market.cpp.

{
__TBB_ASSERT( num_slots > 0, NULL );
__TBB_ASSERT( num_reserved_slots <= num_slots, NULL );
// Add public market reference for master thread/task_arena (that adds an internal reference in exchange).
market &m = global_market( /*is_public=*/true, num_slots-num_reserved_slots, stack_size );
arena& a = arena::allocate_arena( m, num_slots, num_reserved_slots );
// Add newly created arena into the existing market's list.
arenas_list_mutex_type::scoped_lock lock(m.my_arenas_list_mutex);
m.insert_arena_into_list(a);
return &a;
}

References __TBB_ASSERT, tbb::internal::arena::allocate_arena(), global_market(), insert_arena_into_list(), lock, and my_arenas_list_mutex.

Referenced by tbb::internal::governor::init_scheduler().

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

## create_one_job()

rml::job * tbb::internal::market::create_one_job | ( |  | ) |

private

Definition at line 699 of file market.cpp.

{
unsigned index = ++my_first_unused_worker_idx;
__TBB_ASSERT( index > 0, NULL );
ITT_THREAD_SET_NAME(_T("TBB Worker Thread"));
// index serves as a hint decreasing conflicts between workers when they migrate between arenas
generic_scheduler* s = generic_scheduler::create_worker( *this, index, /* genuine = */ true );
#if __TBB_TASK_GROUP_CONTEXT
__TBB_ASSERT( index <= my_num_workers_hard_limit, NULL );
__TBB_ASSERT( !my_workers[index - 1], NULL );
my_workers[index - 1] = s;
#endif /* __TBB_TASK_GROUP_CONTEXT */
return s;
}

References __TBB_ASSERT, _T, tbb::internal::generic_scheduler::create_worker(), ITT_THREAD_SET_NAME, my_first_unused_worker_idx, my_num_workers_hard_limit, and s.

Here is the call graph for this function:

## destroy()

void tbb::internal::market::destroy | ( |  | ) |

private

Destroys and deallocates market object created by market::create()

Definition at line 165 of file market.cpp.

{
#if __TBB_COUNT_TASK_NODES
if ( my_task_node_count )
runtime_warning( "Leaked %ld task objects\n", (long)my_task_node_count );
#endif /* __TBB_COUNT_TASK_NODES */
this->market::~market(); // qualified to suppress warning
NFS_Free( this );
__TBB_InitOnce::remove_ref();
}

References tbb::internal::NFS_Free(), tbb::internal::__TBB_InitOnce::remove_ref(), and tbb::internal::runtime_warning().

Referenced by acknowledge_close_connection().

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

## detach_arena()

void tbb::internal::market::detach_arena | ( | arena & | a | ) |

Removes the arena from the market's list.

This method must be invoked under my_arenas_list_mutex.

Definition at line 322 of file market.cpp.

{
__TBB_ASSERT( theMarket == this, "Global market instance was destroyed prematurely?" );
__TBB_ASSERT( !a.my_slots[0].my_scheduler, NULL );
if (a.my_global_concurrency_mode)
disable_mandatory_concurrency_impl(&a);
remove_arena_from_list(a);
if ( a.my_aba_epoch == my_arenas_aba_epoch )
++my_arenas_aba_epoch;
}

References __TBB_ASSERT, tbb::internal::arena_base::my_aba_epoch, my_arenas_aba_epoch, tbb::internal::arena_slot_line1::my_scheduler, tbb::internal::arena::my_slots, remove_arena_from_list(), and theMarket.

Referenced by try_destroy_arena().

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

## global_market()

market & tbb::internal::market::global_market | ( | bool | is_public,
|  | unsigned | max_num_workers = `0`,
|  | size_t | stack_size = `0`
| ) |  |

static private

Factory method creating new market object.

Definition at line 96 of file market.cpp.

{
global_market_mutex_type::scoped_lock lock( theMarketMutex );
market *m = theMarket;
if( m ) {
++m->my_ref_count;
const unsigned old_public_count = is_public? m->my_public_ref_count++ : /*any non-zero value*/1;
lock.release();
if( old_public_count==0 )
set_active_num_workers( calc_workers_soft_limit(workers_requested, m->my_num_workers_hard_limit) );
// do not warn if default number of workers is requested
if( workers_requested != governor::default_num_threads()-1 ) {
__TBB_ASSERT( skip_soft_limit_warning > workers_requested,
"skip_soft_limit_warning must be larger than any valid workers_requested" );
unsigned soft_limit_to_report = m->my_workers_soft_limit_to_report;
if( soft_limit_to_report < workers_requested ) {
runtime_warning( "The number of workers is currently limited to %u. "
"The request for %u workers is ignored. Further requests for more workers "
"will be silently ignored until the limit changes.\n",
soft_limit_to_report, workers_requested );
// The race is possible when multiple threads report warnings.
// We are OK with that, as there are just multiple warnings.
internal::as_atomic(m->my_workers_soft_limit_to_report).
compare_and_swap(skip_soft_limit_warning, soft_limit_to_report);
}
}
if( m->my_stack_size < stack_size )
runtime_warning( "Thread stack size has been already set to %u. "
"The request for larger stack (%u) cannot be satisfied.\n",
m->my_stack_size, stack_size );
}
else {
// TODO: A lot is done under theMarketMutex locked. Can anything be moved out?
if( stack_size == 0 )
stack_size = global_control::active_value(global_control::thread_stack_size);
// Expecting that 4P is suitable for most applications.
// Limit to 2P for large thread number.
// TODO: ask RML for max concurrency and possibly correct hard_limit
const unsigned factor = governor::default_num_threads()<=128? 4 : 2;
// The requested number of threads is intentionally not considered in
// computation of the hard limit, in order to separate responsibilities
// and avoid complicated interactions between global_control and task_scheduler_init.
// The market guarantees that at least 256 threads might be created.
const unsigned workers_hard_limit = max(max(factor*governor::default_num_threads(), 256u), app_parallelism_limit());
const unsigned workers_soft_limit = calc_workers_soft_limit(workers_requested, workers_hard_limit);
// Create the global market instance
size_t size = sizeof(market);
#if __TBB_TASK_GROUP_CONTEXT
__TBB_ASSERT( __TBB_offsetof(market, my_workers) + sizeof(generic_scheduler*) == sizeof(market),
"my_workers must be the last data field of the market class");
size += sizeof(generic_scheduler*) * (workers_hard_limit - 1);
#endif /* __TBB_TASK_GROUP_CONTEXT */
__TBB_InitOnce::add_ref();
void* storage = NFS_Allocate(1, size, NULL);
memset( storage, 0, size );
// Initialize and publish global market
m = new (storage) market( workers_soft_limit, workers_hard_limit, stack_size );
if( is_public )
m->my_public_ref_count = 1;
theMarket = m;
// This check relies on the fact that for shared RML default_concurrency==max_concurrency
if ( !governor::UsePrivateRML && m->my_server->default_concurrency() < workers_soft_limit )
runtime_warning( "RML might limit the number of workers to %u while %u is requested.\n"
, m->my_server->default_concurrency(), workers_soft_limit );
}
return *m;
}

References __TBB_ASSERT, __TBB_offsetof, tbb::interface9::global_control::active_value(), tbb::internal::__TBB_InitOnce::add_ref(), app_parallelism_limit(), tbb::internal::as_atomic(), tbb::internal::calc_workers_soft_limit(), tbb::internal::governor::default_num_threads(), lock, market(), tbb::internal::max(), my_num_workers_hard_limit, my_public_ref_count, my_ref_count, my_server, my_stack_size, my_workers_soft_limit_to_report, tbb::internal::NFS_Allocate(), tbb::internal::runtime_warning(), set_active_num_workers(), size, skip_soft_limit_warning, theMarket, theMarketMutex, tbb::interface9::global_control::thread_stack_size, and tbb::internal::governor::UsePrivateRML.

Referenced by create_arena(), and tbb::internal::generic_scheduler::create_master().

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

## insert_arena_into_list()

void tbb::internal::market::insert_arena_into_list | ( | arena & | a | ) |

private

Definition at line 29 of file market.cpp.

{
#if __TBB_TASK_PRIORITY
arena_list_type &arenas = my_priority_levels[a.my_top_priority].arenas;
arena *&next = my_priority_levels[a.my_top_priority].next_arena;
#else /* !__TBB_TASK_PRIORITY */
arena_list_type &arenas = my_arenas;
arena *&next = my_next_arena;
#endif /* !__TBB_TASK_PRIORITY */
arenas.push_front( a );
if ( arenas.size() == 1 )
next = &*arenas.begin();
}

References tbb::internal::intrusive_list_base< List, T >::begin(), my_arenas, my_next_arena, tbb::internal::intrusive_list_base< List, T >::push_front(), and tbb::internal::intrusive_list_base< List, T >::size().

Referenced by create_arena().

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

## is_arena_in_list()

bool tbb::internal::market::is_arena_in_list | ( | arena_list_type & | arenas,
|  | arena * | a
| ) |  |

private

This method must be invoked under my_arenas_list_mutex.

Definition at line 424 of file market.cpp.

{
if ( a ) {
for ( arena_list_type::iterator it = arenas.begin(); it != arenas.end(); ++it )
if ( a == &*it )
return true;
}
return false;
}

References tbb::internal::intrusive_list_base< List, T >::begin(), and tbb::internal::intrusive_list_base< List, T >::end().

Referenced by arena_in_need().

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

## max_job_count()

unsigned tbb::internal::market::max_job_count | ( |  | ) | const

inline private

Definition at line 263 of file market.h.

{ return my_num_workers_hard_limit; }

References my_num_workers_hard_limit.

## max_num_workers()

static unsigned tbb::internal::market::max_num_workers | ( |  | ) |

inline static

Definition at line 377 of file market.h.

{
global_market_mutex_type::scoped_lock lock( theMarketMutex );
return theMarket? theMarket->my_num_workers_hard_limit : 0;
}

References lock, my_num_workers_hard_limit, theMarket, and theMarketMutex.

Referenced by tbb::internal::allowed_parallelism_control::active_value().

Here is the caller graph for this function:

## min_stack_size()

size_t tbb::internal::market::min_stack_size | ( |  | ) | const

inline private

Definition at line 265 of file market.h.

{ return worker_stack_size(); }

References worker_stack_size().

Here is the call graph for this function:

## must_join_workers()

bool tbb::internal::market::must_join_workers | ( |  | ) | const

inline

Used when RML asks for join mode during workers termination.

Definition at line 311 of file market.h.

{ return my_join_workers; }

References my_join_workers.

## policy()

policy_type tbb::internal::market::policy | ( |  | ) | const

inline private

Definition at line 267 of file market.h.

{ return throughput; }

## process()

void tbb::internal::market::process | ( | job & | j | ) |

private

Definition at line 659 of file market.cpp.

{
generic_scheduler& s = static_cast<generic_scheduler&>(j);
// s.my_arena can be dead. Don't access it until arena_in_need is called
arena *a = s.my_arena;
__TBB_ASSERT( governor::is_set(&s), NULL );
for (int i = 0; i < 2; ++i) {
while ( (a = arena_in_need(a)) ) {
a->process(s);
a = NULL; // to avoid double checks in arena_in_need(arena*) for the same priority level
}
// Workers leave market because there is no arena in need. It can happen earlier than
// adjust_job_count_estimate() decreases my_slack and RML can put this thread to sleep.
// It might result in a busy-loop checking for my_slack<0 and calling this method instantly.
// the yield refines this spinning.
if ( !i )
__TBB_Yield();
}
GATHER_STATISTIC( ++s.my_counters.market_roundtrips );
}

References __TBB_ASSERT, __TBB_Yield, arena_in_need(), GATHER_STATISTIC, tbb::internal::governor::is_set(), tbb::internal::arena::process(), and s.

Here is the call graph for this function:

## release()

bool tbb::internal::market::release | ( | bool | is_public,
|  | bool | blocking_terminate
| ) |  |

Decrements market's refcount and destroys it in the end.

Definition at line 175 of file market.cpp.

{
__TBB_ASSERT( theMarket == this, "Global market instance was destroyed prematurely?" );
bool do_release = false;
{
global_market_mutex_type::scoped_lock lock( theMarketMutex );
if ( blocking_terminate ) {
__TBB_ASSERT( is_public, "Only an object with a public reference can request the blocking terminate" );
while ( my_public_ref_count == 1 && my_ref_count > 1 ) {
lock.release();
// To guarantee that request_close_connection() is called by the last master, we need to wait till all
// references are released. Re-read my_public_ref_count to limit waiting if new masters are created.
// Theoretically, new private references to the market can be added during waiting making it potentially
// endless.
// TODO: revise why the weak scheduler needs market's pointer and try to remove this wait.
// Note that the market should know about its schedulers for cancellation/exception/priority propagation,
// see e.g. task_group_context::cancel_group_execution()
while ( __TBB_load_with_acquire( my_public_ref_count ) == 1 && __TBB_load_with_acquire( my_ref_count ) > 1 )
__TBB_Yield();
lock.acquire( theMarketMutex );
}
}
if ( is_public ) {
__TBB_ASSERT( theMarket == this, "Global market instance was destroyed prematurely?" );
__TBB_ASSERT( my_public_ref_count, NULL );
--my_public_ref_count;
}
if ( --my_ref_count == 0 ) {
__TBB_ASSERT( !my_public_ref_count, NULL );
do_release = true;
theMarket = NULL;
}
}
if( do_release ) {
__TBB_ASSERT( !__TBB_load_with_acquire(my_public_ref_count), "No public references remain if we remove the market." );
// inform RML that blocking termination is required
my_join_workers = blocking_terminate;
my_server->request_close_connection();
return blocking_terminate;
}
return false;
}

References __TBB_ASSERT, tbb::internal::__TBB_load_with_acquire(), __TBB_Yield, lock, my_join_workers, my_public_ref_count, my_ref_count, my_server, theMarket, and theMarketMutex.

Referenced by tbb::internal::generic_scheduler::cleanup_master(), tbb::internal::arena::free_arena(), and set_active_num_workers().

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

## remove_arena_from_list()

void tbb::internal::market::remove_arena_from_list | ( | arena & | a | ) |

private

Definition at line 42 of file market.cpp.

{
#if __TBB_TASK_PRIORITY
arena_list_type &arenas = my_priority_levels[a.my_top_priority].arenas;
arena *&next = my_priority_levels[a.my_top_priority].next_arena;
#else /* !__TBB_TASK_PRIORITY */
arena_list_type &arenas = my_arenas;
arena *&next = my_next_arena;
#endif /* !__TBB_TASK_PRIORITY */
arena_list_type::iterator it = next;
__TBB_ASSERT( it != arenas.end(), NULL );
if ( next == &a ) {
if ( ++it == arenas.end() && arenas.size() > 1 )
it = arenas.begin();
next = &*it;
}
arenas.remove( a );
}

References __TBB_ASSERT, tbb::internal::intrusive_list_base< List, T >::begin(), tbb::internal::intrusive_list_base< List, T >::end(), my_arenas, my_next_arena, tbb::internal::intrusive_list_base< List, T >::remove(), and tbb::internal::intrusive_list_base< List, T >::size().

Referenced by detach_arena().

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

## set_active_num_workers()

void tbb::internal::market::set_active_num_workers | ( | unsigned | w | ) |

static

Set number of active workers.

Definition at line 235 of file market.cpp.

{
market *m;
{
global_market_mutex_type::scoped_lock lock( theMarketMutex );
if ( !theMarket )
return; // actual value will be used at market creation
m = theMarket;
if (m->my_num_workers_soft_limit == soft_limit)
return;
++m->my_ref_count;
}
// have my_ref_count for market, use it safely
int delta = 0;
{
arenas_list_mutex_type::scoped_lock lock( m->my_arenas_list_mutex );
__TBB_ASSERT(soft_limit <= m->my_num_workers_hard_limit, NULL);
#if __TBB_ENQUEUE_ENFORCED_CONCURRENCY
#if __TBB_TASK_PRIORITY
#define FOR_EACH_PRIORITY_LEVEL_BEGIN { \
for (int p = m->my_global_top_priority; p >= m->my_global_bottom_priority; --p) { \
priority_level_info& pl = m->my_priority_levels[p]; \
arena_list_type& arenas = pl.arenas;
#else
#define FOR_EACH_PRIORITY_LEVEL_BEGIN { { \
const int p = 0; \
tbb::internal::suppress_unused_warning(p); \
arena_list_type& arenas = m->my_arenas;
#endif
#define FOR_EACH_PRIORITY_LEVEL_END } }
if (m->my_num_workers_soft_limit == 0 && m->my_mandatory_num_requested > 0) {
FOR_EACH_PRIORITY_LEVEL_BEGIN
for (arena_list_type::iterator it = arenas.begin(); it != arenas.end(); ++it)
if (it->my_global_concurrency_mode)
m->disable_mandatory_concurrency_impl(&*it);
FOR_EACH_PRIORITY_LEVEL_END
}
__TBB_ASSERT(m->my_mandatory_num_requested == 0, NULL);
#endif
as_atomic(m->my_num_workers_soft_limit) = soft_limit;
// report only once after new soft limit value is set
m->my_workers_soft_limit_to_report = soft_limit;
#if __TBB_ENQUEUE_ENFORCED_CONCURRENCY
if (m->my_num_workers_soft_limit == 0) {
FOR_EACH_PRIORITY_LEVEL_BEGIN
for (arena_list_type::iterator it = arenas.begin(); it != arenas.end(); ++it) {
if (!it->my_task_stream.empty(p))
m->enable_mandatory_concurrency_impl(&*it);
}
FOR_EACH_PRIORITY_LEVEL_END
}
#undef FOR_EACH_PRIORITY_LEVEL_BEGIN
#undef FOR_EACH_PRIORITY_LEVEL_END
#endif
delta = m->update_workers_request();
}
// adjust_job_count_estimate must be called outside of any locks
if( delta!=0 )
m->my_server->adjust_job_count_estimate( delta );
// release internal market reference to match ++m->my_ref_count above
m->release( /*is_public=*/false, /*blocking_terminate=*/false );
}

References __TBB_ASSERT, tbb::internal::as_atomic(), lock, my_arenas_list_mutex, my_num_workers_hard_limit, my_num_workers_soft_limit, my_ref_count, my_server, my_workers_soft_limit_to_report, p, release(), theMarket, theMarketMutex, and update_workers_request().

Referenced by tbb::internal::allowed_parallelism_control::apply_active(), and global_market().

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

## try_destroy_arena()

void tbb::internal::market::try_destroy_arena | ( | arena * | a,
|  | uintptr_t | aba_epoch
| ) |  |

Removes the arena from the market's list.

Definition at line 333 of file market.cpp.

{
bool locked = true;
__TBB_ASSERT( a, NULL );
// we hold reference to the market, so it cannot be destroyed at any moment here
__TBB_ASSERT( this == theMarket, NULL );
__TBB_ASSERT( my_ref_count!=0, NULL );
my_arenas_list_mutex.lock();
assert_market_valid();
#if __TBB_TASK_PRIORITY
// scan all priority levels, not only in [my_global_bottom_priority;my_global_top_priority]
// range, because arena to be destroyed can have no outstanding request for workers
for ( int p = num_priority_levels-1; p >= 0; --p ) {
priority_level_info &pl = my_priority_levels[p];
arena_list_type &my_arenas = pl.arenas;
#endif /* __TBB_TASK_PRIORITY */
arena_list_type::iterator it = my_arenas.begin();
for ( ; it != my_arenas.end(); ++it ) {
if ( a == &*it ) {
if ( it->my_aba_epoch == aba_epoch ) {
// Arena is alive
if ( !a->my_num_workers_requested && !a->my_references ) {
__TBB_ASSERT( !a->my_num_workers_allotted && (a->my_pool_state == arena::SNAPSHOT_EMPTY || !a->my_max_num_workers), "Inconsistent arena state" );
// Arena is abandoned. Destroy it.
detach_arena( *a );
my_arenas_list_mutex.unlock();
locked = false;
a->free_arena();
}
}
if (locked)
my_arenas_list_mutex.unlock();
return;
}
}
#if __TBB_TASK_PRIORITY
}
#endif /* __TBB_TASK_PRIORITY */
my_arenas_list_mutex.unlock();
}

References __TBB_ASSERT, assert_market_valid(), tbb::internal::intrusive_list_base< List, T >::begin(), detach_arena(), tbb::internal::intrusive_list_base< List, T >::end(), tbb::internal::arena::free_arena(), tbb::spin_rw_mutex_v3::lock(), my_arenas, my_arenas_list_mutex, tbb::internal::arena_base::my_max_num_workers, tbb::internal::arena_base::my_num_workers_allotted, tbb::internal::arena_base::my_num_workers_requested, tbb::internal::arena_base::my_pool_state, my_ref_count, tbb::internal::arena_base::my_references, tbb::internal::num_priority_levels, p, tbb::internal::arena::SNAPSHOT_EMPTY, theMarket, and tbb::spin_rw_mutex_v3::unlock().

Referenced by tbb::internal::arena::on_thread_leaving().

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

## update_allotment() [1/2]

int tbb::internal::market::update_allotment | ( | arena_list_type & | arenas,
|  | int | total_demand,
|  | int | max_workers
| ) |  |

private

Definition at line 391 of file market.cpp.

{
__TBB_ASSERT( workers_demand > 0, NULL );
max_workers = min(workers_demand, max_workers);
int assigned = 0;
int carry = 0;
for (arena_list_type::iterator it = arenas.begin(); it != arenas.end(); ++it) {
arena& a = *it;
if (a.my_num_workers_requested <= 0) {
__TBB_ASSERT(!a.my_num_workers_allotted, NULL);
continue;
}
int allotted = 0;
#if __TBB_ENQUEUE_ENFORCED_CONCURRENCY
if (my_num_workers_soft_limit == 0) {
__TBB_ASSERT(max_workers == 0 || max_workers == 1, NULL);
allotted = a.my_global_concurrency_mode && assigned < max_workers ? 1 : 0;
} else
#endif
{
int tmp = a.my_num_workers_requested * max_workers + carry;
allotted = tmp / workers_demand;
carry = tmp % workers_demand;
// a.my_num_workers_requested may temporarily exceed a.my_max_num_workers
allotted = min(allotted, (int)a.my_max_num_workers);
}
a.my_num_workers_allotted = allotted;
assigned += allotted;
}
__TBB_ASSERT( 0 <= assigned && assigned <= max_workers, NULL );
return assigned;
}

References __TBB_ASSERT, tbb::internal::intrusive_list_base< List, T >::begin(), tbb::internal::intrusive_list_base< List, T >::end(), tbb::internal::min(), tbb::internal::arena_base::my_max_num_workers, tbb::internal::arena_base::my_num_workers_allotted, tbb::internal::arena_base::my_num_workers_requested, and my_num_workers_soft_limit.

Here is the call graph for this function:

## update_allotment() [2/2]

void tbb::internal::market::update_allotment | ( | unsigned | effective_soft_limit | ) |

inline private

Recalculates the number of workers assigned to each arena in the list.

The actual number of workers servicing a particular arena may temporarily deviate from the calculated value.

Definition at line 214 of file market.h.

{
if ( my_total_demand )
update_allotment( my_arenas, my_total_demand, (int)effective_soft_limit );
}

References my_arenas, and my_total_demand.

Referenced by adjust_demand(), and update_workers_request().

Here is the caller graph for this function:

## update_workers_request()

int tbb::internal::market::update_workers_request | ( |  | ) |

private

Recalculates the number of workers requested from RML and updates the allotment.

Definition at line 217 of file market.cpp.

{
int old_request = my_num_workers_requested;
my_num_workers_requested = min(my_total_demand, (int)my_num_workers_soft_limit);
#if __TBB_ENQUEUE_ENFORCED_CONCURRENCY
if (my_mandatory_num_requested > 0) {
__TBB_ASSERT(my_num_workers_soft_limit == 0, NULL);
my_num_workers_requested = 1;
}
#endif
#if __TBB_TASK_PRIORITY
my_priority_levels[my_global_top_priority].workers_available = my_num_workers_requested;
update_allotment(my_global_top_priority);
#else
update_allotment(my_num_workers_requested);
#endif
return my_num_workers_requested - old_request;
}

References __TBB_ASSERT, tbb::internal::min(), my_num_workers_requested, my_num_workers_soft_limit, my_total_demand, and update_allotment().

Referenced by set_active_num_workers().

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

## version()

version_type tbb::internal::market::version | ( |  | ) | const

inline private

Definition at line 261 of file market.h.

{ return 0; }

## worker_stack_size()

size_t tbb::internal::market::worker_stack_size | ( |  | ) | const

inline

Returns the requested stack size of worker threads.

Definition at line 314 of file market.h.

{ return my_stack_size; }

References my_stack_size.

Referenced by tbb::internal::generic_scheduler::init_stack_info(), and min_stack_size().

Here is the caller graph for this function:

## Friends And Related Function Documentation

## arena

friend class arena

friend

Definition at line 47 of file market.h.

## custom_scheduler

template<typename SchedulerTraits >

friend class custom_scheduler

friend

Definition at line 49 of file market.h.

## generic_scheduler

friend class generic_scheduler

friend

Definition at line 46 of file market.h.

## ITT_DoUnsafeOneTimeInitialization

void ITT_DoUnsafeOneTimeInitialization | ( |  | ) |

friend

## tbb::interface7::internal::task_arena_base

friend class tbb::interface7::internal::task_arena_base

friend

Definition at line 48 of file market.h.

## tbb::task_group_context

friend class tbb::task_group_context

friend

Definition at line 50 of file market.h.

## Member Data Documentation

## my_arenas

arena_list_type tbb::internal::market::my_arenas

private

List of registered arenas.

Definition at line 135 of file market.h.

Referenced by arena_in_need(), insert_arena_into_list(), remove_arena_from_list(), try_destroy_arena(), and update_allotment().

## my_arenas_aba_epoch

uintptr_t tbb::internal::market::my_arenas_aba_epoch

private

ABA prevention marker to assign to newly created arenas.

Definition at line 143 of file market.h.

Referenced by tbb::internal::arena::arena(), and detach_arena().

## my_arenas_list_mutex

arenas_list_mutex_type tbb::internal::market::my_arenas_list_mutex

private

Definition at line 67 of file market.h.

Referenced by adjust_demand(), arena_in_need(), create_arena(), set_active_num_workers(), and try_destroy_arena().

## my_first_unused_worker_idx

atomic<unsigned> tbb::internal::market::my_first_unused_worker_idx

private

First unused index of worker.

Used to assign indices to the new workers coming from RML, and busy part of my_workers array.

Definition at line 86 of file market.h.

Referenced by create_one_job().

## my_join_workers

bool tbb::internal::market::my_join_workers

private

Shutdown mode.

Definition at line 155 of file market.h.

Referenced by must_join_workers(), and release().

## my_next_arena

arena* tbb::internal::market::my_next_arena

private

The first arena to be checked when idle worker seeks for an arena to enter.

The check happens in round-robin fashion.

Definition at line 139 of file market.h.

Referenced by arena_in_need(), insert_arena_into_list(), and remove_arena_from_list().

## my_num_workers_hard_limit

unsigned tbb::internal::market::my_num_workers_hard_limit

private

Maximal number of workers allowed for use by the underlying resource manager.

It can't be changed after market creation.

Definition at line 74 of file market.h.

Referenced by create_one_job(), global_market(), max_job_count(), max_num_workers(), and set_active_num_workers().

## my_num_workers_requested

int tbb::internal::market::my_num_workers_requested

private

Number of workers currently requested from RML.

Definition at line 81 of file market.h.

Referenced by adjust_demand(), and update_workers_request().

## my_num_workers_soft_limit

unsigned tbb::internal::market::my_num_workers_soft_limit

private

Current application-imposed limit on the number of workers (see set_active_num_workers())

It can't be more than my_num_workers_hard_limit.

Definition at line 78 of file market.h.

Referenced by adjust_demand(), tbb::internal::arena::advertise_new_work(), market(), tbb::internal::arena::on_thread_leaving(), set_active_num_workers(), update_allotment(), and update_workers_request().

## my_public_ref_count

unsigned tbb::internal::market::my_public_ref_count

private

Count of master threads attached.

Definition at line 149 of file market.h.

Referenced by global_market(), and release().

## my_ref_count

unsigned tbb::internal::market::my_ref_count

private

Reference count controlling market object lifetime.

Definition at line 146 of file market.h.

Referenced by global_market(), release(), set_active_num_workers(), and try_destroy_arena().

## my_server

rml::tbb_server* tbb::internal::market::my_server

private

Pointer to the RML server object that services this TBB instance.

Definition at line 70 of file market.h.

Referenced by adjust_demand(), global_market(), market(), release(), and set_active_num_workers().

## my_stack_size

size_t tbb::internal::market::my_stack_size

private

Stack size of worker threads.

Definition at line 152 of file market.h.

Referenced by global_market(), and worker_stack_size().

## my_total_demand

int tbb::internal::market::my_total_demand

private

Number of workers that were requested by all arenas.

Definition at line 89 of file market.h.

Referenced by adjust_demand(), arena_in_need(), update_allotment(), and update_workers_request().

## my_workers_soft_limit_to_report

unsigned tbb::internal::market::my_workers_soft_limit_to_report

private

Either workers soft limit to be reported via runtime_warning() or skip_soft_limit_warning.

Definition at line 161 of file market.h.

Referenced by global_market(), and set_active_num_workers().

## skip_soft_limit_warning

const unsigned tbb::internal::market::skip_soft_limit_warning = ~0U

static private

The value indicating that the soft limit warning is unnecessary.

Definition at line 158 of file market.h.

Referenced by global_market().

## theMarket

market * tbb::internal::market::theMarket

static private

Currently active global market.

Definition at line 58 of file market.h.

Referenced by adjust_demand(), cleanup(), detach_arena(), global_market(), max_num_workers(), release(), set_active_num_workers(), and try_destroy_arena().

## theMarketMutex

market::global_market_mutex_type tbb::internal::market::theMarketMutex

static private

Mutex guarding creation/destruction of theMarket, insertions/deletions in my_arenas, and cancellation propagation.

Definition at line 63 of file market.h.

Referenced by global_market(), max_num_workers(), release(), and set_active_num_workers().

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

- market.h
- market.cpp
- tbb_main.cpp

tbb::internal::__TBB_load_with_acquire
T __TBB_load_with_acquire(const volatile T &location)
Definition: tbb_machine.h:712
tbb::internal::intrusive_list_base::end
iterator end()
Definition: intrusive_list.h:159
tbb::internal::governor::UsePrivateRML
static bool UsePrivateRML
Definition: governor.h:64
tbb::internal::allowed_parallelism_ctl
static allowed_parallelism_control allowed_parallelism_ctl
Definition: tbb_main.cpp:507
tbb::internal::arena::ref_worker
static const unsigned ref_worker
Definition: arena.h:328
tbb::internal::market::my_num_workers_requested
int my_num_workers_requested
Number of workers currently requested from RML.
Definition: market.h:81
tbb::internal::__TBB_InitOnce::add_ref
static void add_ref()
Add reference to resources. If first reference added, acquire the resources.
Definition: tbb_main.cpp:117
tbb::internal::market::my_arenas_aba_epoch
uintptr_t my_arenas_aba_epoch
ABA prevention marker to assign to newly created arenas.
Definition: market.h:143
tbb::interface9::global_control::thread_stack_size
Definition: global_control.h:29
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::market::global_market
static market & global_market(bool is_public, unsigned max_num_workers=0, size_t stack_size=0)
Factory method creating new market object.
Definition: market.cpp:96
tbb::internal::market::my_workers_soft_limit_to_report
unsigned my_workers_soft_limit_to_report
Either workers soft limit to be reported via runtime_warning() or skip_soft_limit_warning.
Definition: market.h:161
tbb::internal::market::my_ref_count
unsigned my_ref_count
Reference count controlling market object lifetime.
Definition: market.h:146
tbb::internal::market::my_first_unused_worker_idx
atomic< unsigned > my_first_unused_worker_idx
First unused index of worker.
Definition: market.h:86
tbb::internal::intrusive_list_base::begin
iterator begin()
Definition: intrusive_list.h:157
tbb::internal::runtime_warning
void __TBB_EXPORTED_FUNC runtime_warning(const char *format,...)
Report a runtime warning.
Definition: tbb_assert_impl.h:85
tbb::internal::market::is_arena_in_list
bool is_arena_in_list(arena_list_type &arenas, arena *a)
Definition: market.cpp:424
tbb::spin_rw_mutex_v3::unlock
void unlock()
Release lock.
Definition: spin_rw_mutex.h:187
size
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
Definition: ittnotify_static.h:109
tbb::internal::market::my_next_arena
arena * my_next_arena
The first arena to be checked when idle worker seeks for an arena to enter.
Definition: market.h:139
tbb::internal::governor::local_scheduler_if_initialized
static generic_scheduler * local_scheduler_if_initialized()
Definition: governor.h:139
tbb::interface9::global_control::active_value
static size_t active_value(parameter p)
Definition: global_control.h:59
tbb::internal::market::my_arenas_list_mutex
arenas_list_mutex_type my_arenas_list_mutex
Definition: market.h:67
tbb::internal::market::detach_arena
void detach_arena(arena &)
Removes the arena from the market's list.
Definition: market.cpp:322
tbb::internal::market::destroy
void destroy()
Destroys and deallocates market object created by market::create()
Definition: market.cpp:165
tbb::internal::market::my_public_ref_count
unsigned my_public_ref_count
Count of master threads attached.
Definition: market.h:149
tbb::internal::market::my_server
rml::tbb_server * my_server
Pointer to the RML server object that services this TBB instance.
Definition: market.h:70
tbb::internal::market::remove_arena_from_list
void remove_arena_from_list(arena &a)
Definition: market.cpp:42
tbb::internal::market::worker_stack_size
size_t worker_stack_size() const
Returns the requested stack size of worker threads.
Definition: market.h:314
tbb::internal::governor::default_num_threads
static unsigned default_num_threads()
Definition: governor.h:84
ITT_THREAD_SET_NAME
#define ITT_THREAD_SET_NAME(name)
Definition: itt_notify.h:113
tbb::internal::market::arena_list_type
intrusive_list< arena > arena_list_type
Definition: market.h:54
tbb::internal::arena::SNAPSHOT_EMPTY
static const pool_state_t SNAPSHOT_EMPTY
No tasks to steal since last snapshot was taken.
Definition: arena.h:318
tbb::internal::market::my_join_workers
bool my_join_workers
Shutdown mode.
Definition: market.h:155
tbb::internal::market::update_allotment
void update_allotment(unsigned effective_soft_limit)
Recalculates the number of workers assigned to each arena in the list.
Definition: market.h:214
GATHER_STATISTIC
#define GATHER_STATISTIC(x)
Definition: tbb_statistics.h:232
tbb::internal::__TBB_InitOnce::remove_ref
static void remove_ref()
Remove reference to resources. If last reference removed, release the resources.
Definition: tbb_main.cpp:122
tbb::internal::market::my_num_workers_soft_limit
unsigned my_num_workers_soft_limit
Current application-imposed limit on the number of workers (see set_active_num_workers())
Definition: market.h:78
lock
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 * lock
Definition: ittnotify_static.h:121
__TBB_Yield
#define __TBB_Yield()
Definition: ibm_aix51.h:44
tbb::internal::arena::allocate_arena
static arena & allocate_arena(market &, unsigned num_slots, unsigned num_reserved_slots)
Allocate an instance of arena.
Definition: arena.cpp:285
tbb::internal::market::my_num_workers_hard_limit
unsigned my_num_workers_hard_limit
Maximal number of workers allowed for use by the underlying resource manager.
Definition: market.h:74
tbb::internal::market::skip_soft_limit_warning
static const unsigned skip_soft_limit_warning
The value indicating that the soft limit warning is unnecessary.
Definition: market.h:158
_T
#define _T(string_literal)
Standard Windows style macro to markup the string literals.
Definition: itt_notify.h:59
tbb::internal::market::my_total_demand
int my_total_demand
Number of workers that were requested by all arenas.
Definition: market.h:89
tbb::internal::market::theMarket
static market * theMarket
Currently active global market.
Definition: market.h:58
tbb::internal::market::app_parallelism_limit
static unsigned app_parallelism_limit()
Reports active parallelism level according to user's settings.
Definition: tbb_main.cpp:512
s
void const char const char int ITT_FORMAT __itt_group_sync s
Definition: ittnotify_static.h:91
__TBB_offsetof
#define __TBB_offsetof(class_name, member_name)
Extended variant of the standard offsetof macro.
Definition: tbb_stddef.h:266
tbb::internal::market::generic_scheduler
friend class generic_scheduler
Definition: market.h:46
tbb::internal::governor::assume_scheduler
static void assume_scheduler(generic_scheduler *s)
Temporarily set TLS slot to the given scheduler.
Definition: governor.cpp:116
tbb::internal::calc_workers_soft_limit
static unsigned calc_workers_soft_limit(unsigned workers_soft_limit, unsigned workers_hard_limit)
Definition: market.cpp:86
tbb::internal::governor::is_set
static bool is_set(generic_scheduler *s)
Used to check validity of the local scheduler TLS contents.
Definition: governor.cpp:120
tbb::internal::allowed_parallelism_control::active_value_if_present
size_t active_value_if_present() const
Definition: tbb_main.cpp:491
tbb::internal::market::arena
friend class arena
Definition: market.h:47
tbb::internal::max
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Definition: tbb_misc.h:119
tbb::internal::num_priority_levels
static const intptr_t num_priority_levels
Definition: scheduler_common.h:129
tbb::internal::market::my_stack_size
size_t my_stack_size
Stack size of worker threads.
Definition: market.h:152
tbb::internal::as_atomic
atomic< T > & as_atomic(T &t)
Definition: atomic.h:572
tbb::internal::market::theMarketMutex
static global_market_mutex_type theMarketMutex
Mutex guarding creation/destruction of theMarket, insertions/deletions in my_arenas,...
Definition: market.h:63
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::internal::market::set_active_num_workers
static void set_active_num_workers(unsigned w)
Set number of active workers.
Definition: market.cpp:235
tbb::internal::NFS_Free
void __TBB_EXPORTED_FUNC NFS_Free(void *)
Free memory allocated by NFS_Allocate.
Definition: cache_aligned_allocator.cpp:198
tbb::internal::governor::create_rml_server
static rml::tbb_server * create_rml_server(rml::tbb_client &)
Definition: governor.cpp:92
tbb::internal::market::arena_in_need
arena * arena_in_need(arena *prev_arena)
Returns next arena that needs more workers, or NULL.
Definition: market.h:221
tbb::spin_rw_mutex_v3::lock
void lock()
Acquire writer lock.
Definition: spin_rw_mutex.h:180
tbb::internal::market::market
market(unsigned workers_soft_limit, unsigned workers_hard_limit, size_t stack_size)
Constructor.
Definition: market.cpp:64
tbb::internal::min
T min(const T &val1, const T &val2)
Utility template function returning lesser of the two values.
Definition: tbb_misc.h:110
tbb::internal::NFS_Allocate
void *__TBB_EXPORTED_FUNC NFS_Allocate(size_t n_element, size_t element_size, void *hint)
Allocate memory on cache/sector line boundary.
Definition: cache_aligned_allocator.cpp:176
tbb::internal::generic_scheduler::create_worker
static generic_scheduler * create_worker(market &m, size_t index, bool geniune)
Initialize a scheduler for a worker thread.
Definition: scheduler.cpp:1271
tbb::internal::market::assert_market_valid
void assert_market_valid() const
Definition: market.h:241
tbb::internal::market::my_arenas
arena_list_type my_arenas
List of registered arenas.
Definition: market.h:135
tbb::internal::generic_scheduler::cleanup_worker
static void cleanup_worker(void *arg, bool worker)
Perform necessary cleanup when a worker thread finishes.
Definition: scheduler.cpp:1329

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.