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 450 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 462 of file tbb_main.cpp.

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

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 475 of file tbb_main.cpp.

475  {
476  return my_head? my_active_value : 0;
477  }
atomic< global_control * > my_head
Definition: tbb_main.cpp:437

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 457 of file tbb_main.cpp.

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

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 451 of file tbb_main.cpp.

451  {
452  return max(1U, governor::default_num_threads());
453  }
static unsigned default_num_threads()
Definition: governor.h:85
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Definition: tbb_misc.h:116

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 454 of file tbb_main.cpp.

454  {
455  return a<b; // prefer min allowed parallelism
456  }

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.