Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::allowed_parallelism_control Class Reference
Inheritance diagram for tbb::internal::allowed_parallelism_control:
Collaboration diagram for tbb::internal::allowed_parallelism_control:

Public Member Functions

size_t active_value_if_present () const
 

Private Member Functions

virtual size_t default_value () const __TBB_override
 
virtual bool is_first_arg_preferred (size_t a, size_t b) const __TBB_override
 
virtual void apply_active () const __TBB_override
 
virtual size_t active_value () const __TBB_override
 

Additional Inherited Members

- Public Attributes inherited from tbb::internal::padded_base< control_storage, NFS_MaxLineSize, sizeof(control_storage) % NFS_MaxLineSize >
char pad [S - R]
 
- Protected Attributes inherited from tbb::internal::control_storage
size_t my_active_value
 
atomic< global_control * > my_head
 
spin_mutex my_list_mutex
 

Detailed Description

Definition at line 446 of file tbb_main.cpp.

Member Function Documentation

◆ active_value()

virtual size_t tbb::internal::allowed_parallelism_control::active_value ( ) const
inlineprivatevirtual

Reimplemented from tbb::internal::control_storage.

Definition at line 458 of file tbb_main.cpp.

458  {
459 /* Reading of my_active_value is not synchronized with possible updating
460  of my_head by other thread. It's ok, as value of my_active_value became
461  not invalid, just obsolete. */
462  if (!my_head)
463  return default_value();
464  // non-zero, if market is active
465  const size_t workers = market::max_num_workers();
466  // We can't exceed market's maximal number of workers.
467  // +1 to take master into account
468  return workers? min(workers+1, my_active_value): my_active_value;
469  }
virtual size_t default_value() const __TBB_override
Definition: tbb_main.cpp:447
atomic< global_control * > my_head
Definition: tbb_main.cpp:433
T min(const T &val1, const T &val2)
Utility template function returning lesser of the two values.
Definition: tbb_misc.h:103
static unsigned max_num_workers()
Definition: market.h:357

References default_value(), tbb::internal::market::max_num_workers(), tbb::internal::min(), tbb::internal::control_storage::my_active_value, and tbb::internal::control_storage::my_head.

Here is the call graph for this function:

◆ active_value_if_present()

size_t tbb::internal::allowed_parallelism_control::active_value_if_present ( ) const
inline

Definition at line 471 of file tbb_main.cpp.

471  {
472  return my_head? my_active_value : 0;
473  }
atomic< global_control * > my_head
Definition: tbb_main.cpp:433

References tbb::internal::control_storage::my_active_value, and tbb::internal::control_storage::my_head.

Referenced by tbb::internal::market::app_parallelism_limit().

Here is the caller graph for this function:

◆ apply_active()

virtual void tbb::internal::allowed_parallelism_control::apply_active ( ) const
inlineprivatevirtual

Reimplemented from tbb::internal::control_storage.

Definition at line 453 of file tbb_main.cpp.

453  {
454  __TBB_ASSERT( my_active_value>=1, NULL );
455  // -1 to take master into account
457  }
static void set_active_num_workers(unsigned w)
Set number of active workers.
Definition: market.cpp:217
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT, tbb::internal::control_storage::my_active_value, and tbb::internal::market::set_active_num_workers().

Here is the call graph for this function:

◆ default_value()

virtual size_t tbb::internal::allowed_parallelism_control::default_value ( ) const
inlineprivatevirtual

Implements tbb::internal::control_storage.

Definition at line 447 of file tbb_main.cpp.

447  {
448  return max(1U, governor::default_num_threads());
449  }
static unsigned default_num_threads()
Definition: governor.h:81
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Definition: tbb_misc.h:112

References tbb::internal::governor::default_num_threads(), and tbb::internal::max().

Referenced by active_value().

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

◆ is_first_arg_preferred()

virtual bool tbb::internal::allowed_parallelism_control::is_first_arg_preferred ( size_t  a,
size_t  b 
) const
inlineprivatevirtual

Reimplemented from tbb::internal::control_storage.

Definition at line 450 of file tbb_main.cpp.

450  {
451  return a<b; // prefer min allowed parallelism
452  }

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

Copyright © 2005-2019 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.