Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::global_control Class Reference

#include <global_control.h>

Collaboration diagram for tbb::interface9::global_control:

Public Types

enum  parameter { max_allowed_parallelism, thread_stack_size, parameter_max }
 

Public Member Functions

 global_control (parameter p, size_t value)
 
 ~global_control ()
 

Static Public Member Functions

static size_t active_value (parameter p)
 

Private Member Functions

void __TBB_EXPORTED_METHOD internal_create ()
 
void __TBB_EXPORTED_METHOD internal_destroy ()
 

Static Private Member Functions

static size_t __TBB_EXPORTED_FUNC active_value (int param)
 

Private Attributes

size_t my_value
 
global_controlmy_next
 
parameter my_param
 

Detailed Description

Definition at line 25 of file global_control.h.

Member Enumeration Documentation

◆ parameter

Enumerator
max_allowed_parallelism 
thread_stack_size 
parameter_max 

Definition at line 27 of file global_control.h.

Constructor & Destructor Documentation

◆ global_control()

tbb::interface9::global_control::global_control ( parameter  p,
size_t  value 
)
inline

Definition at line 33 of file global_control.h.

33  :
34  my_value(value), my_next(NULL), my_param(p) {
35  __TBB_ASSERT(my_param < parameter_max, "Invalid parameter");
36 #if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00)
37  // For Windows 8 Store* apps it's impossible to set stack size
38  if (p==thread_stack_size)
39  return;
40 #elif __TBB_x86_64 && (_WIN32 || _WIN64)
41  if (p==thread_stack_size)
42  __TBB_ASSERT_RELEASE((unsigned)value == value, "Stack size is limited to unsigned int range");
43 #endif
45  __TBB_ASSERT_RELEASE(my_value>0, "max_allowed_parallelism cannot be 0.");
47  }
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
void const char const char int ITT_FORMAT __itt_group_sync p
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
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 value
void __TBB_EXPORTED_METHOD internal_create()
Definition: tbb_main.cpp:523

References __TBB_ASSERT, __TBB_ASSERT_RELEASE, internal_create(), max_allowed_parallelism, my_param, my_value, p, parameter_max, thread_stack_size, and value.

Here is the call graph for this function:

◆ ~global_control()

tbb::interface9::global_control::~global_control ( )
inline

Definition at line 49 of file global_control.h.

49  {
50  __TBB_ASSERT(my_param < parameter_max, "Invalid parameter. Probably the object was corrupted.");
51 #if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00)
52  // For Windows 8 Store* apps it's impossible to set stack size
54  return;
55 #endif
57  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
void __TBB_EXPORTED_METHOD internal_destroy()
Definition: tbb_main.cpp:539

References __TBB_ASSERT, internal_destroy(), my_param, parameter_max, and thread_stack_size.

Here is the call graph for this function:

Member Function Documentation

◆ active_value() [1/2]

static size_t tbb::interface9::global_control::active_value ( parameter  p)
inlinestatic

Definition at line 59 of file global_control.h.

59  {
60  __TBB_ASSERT(p < parameter_max, "Invalid parameter");
61  return active_value((int)p);
62  }
static size_t active_value(parameter p)
void const char const char int ITT_FORMAT __itt_group_sync p
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT, p, and parameter_max.

Referenced by tbb::internal::market::global_market(), and tbb::internal::tbb_thread_v3::internal_start().

Here is the caller graph for this function:

◆ active_value() [2/2]

size_t tbb::interface9::global_control::active_value ( int  param)
staticprivate

Definition at line 579 of file tbb_main.cpp.

579  {
581  return controls[param]->active_value();
582 }
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
virtual size_t active_value() const
Definition: tbb_main.cpp:461
static control_storage * controls[]
Definition: tbb_main.cpp:510

References __TBB_ASSERT_RELEASE, tbb::internal::control_storage::active_value(), tbb::internal::controls, and parameter_max.

Here is the call graph for this function:

◆ internal_create()

void tbb::interface9::global_control::internal_create ( )
private

Definition at line 523 of file tbb_main.cpp.

523  {
525  control_storage *const c = controls[my_param];
526 
530  // to guarantee that apply_active() is called with current active value,
531  // calls it here and in internal_destroy() under my_list_mutex
532  c->apply_active();
533  }
534  my_next = c->my_head;
535  // publish my_head, at this point my_active_value must be valid
536  c->my_head = this;
537 }
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
virtual bool is_first_arg_preferred(size_t a, size_t b) const
Definition: tbb_main.cpp:458
atomic< global_control * > my_head
Definition: tbb_main.cpp:453
static control_storage * controls[]
Definition: tbb_main.cpp:510
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
virtual void apply_active() const
Definition: tbb_main.cpp:457
friend class scoped_lock
Definition: spin_mutex.h:179

References __TBB_ASSERT_RELEASE, tbb::internal::control_storage::apply_active(), tbb::internal::controls, tbb::internal::control_storage::is_first_arg_preferred(), lock, tbb::internal::control_storage::my_active_value, tbb::internal::control_storage::my_head, tbb::internal::control_storage::my_list_mutex, and parameter_max.

Referenced by global_control().

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

◆ internal_destroy()

void tbb::interface9::global_control::internal_destroy ( )
private

Definition at line 539 of file tbb_main.cpp.

539  {
540  global_control *prev = 0;
541 
543  control_storage *const c = controls[my_param];
544  __TBB_ASSERT( c->my_head, NULL );
545 
546  // Concurrent reading and changing global parameter is possible.
547  // In this case, my_active_value may not match current state of parameters.
548  // This is OK because:
549  // 1) my_active_value is either current or previous
550  // 2) my_active_value is current on internal_destroy leave
552  size_t new_active = (size_t)-1, old_active = c->my_active_value;
553 
554  if ( c->my_head != this )
555  new_active = c->my_head->my_value;
556  else if ( c->my_head->my_next )
557  new_active = c->my_head->my_next->my_value;
558  // if there is only one element, new_active will be set later
559  for ( global_control *curr = c->my_head; curr; prev = curr, curr = curr->my_next )
560  if ( curr == this ) {
561  if ( prev )
562  prev->my_next = my_next;
563  else
564  c->my_head = my_next;
565  } else
566  if (c->is_first_arg_preferred(curr->my_value, new_active))
567  new_active = curr->my_value;
568 
569  if ( !c->my_head ) {
570  __TBB_ASSERT( new_active==(size_t)-1, NULL );
571  new_active = c->default_value();
572  }
573  if ( new_active != old_active ) {
574  c->my_active_value = new_active;
575  c->apply_active();
576  }
577 }
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
virtual bool is_first_arg_preferred(size_t a, size_t b) const
Definition: tbb_main.cpp:458
atomic< global_control * > my_head
Definition: tbb_main.cpp:453
virtual size_t default_value() const =0
static control_storage * controls[]
Definition: tbb_main.cpp:510
global_control(parameter p, size_t value)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
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
virtual void apply_active() const
Definition: tbb_main.cpp:457
friend class scoped_lock
Definition: spin_mutex.h:179

References __TBB_ASSERT, __TBB_ASSERT_RELEASE, tbb::internal::control_storage::apply_active(), tbb::internal::controls, tbb::internal::control_storage::default_value(), tbb::internal::control_storage::is_first_arg_preferred(), lock, tbb::internal::control_storage::my_active_value, tbb::internal::control_storage::my_head, tbb::internal::control_storage::my_list_mutex, my_next, and parameter_max.

Referenced by ~global_control().

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

Member Data Documentation

◆ my_next

global_control* tbb::interface9::global_control::my_next
private

Definition at line 65 of file global_control.h.

Referenced by internal_destroy().

◆ my_param

parameter tbb::interface9::global_control::my_param
private

Definition at line 66 of file global_control.h.

Referenced by global_control(), and ~global_control().

◆ my_value

size_t tbb::interface9::global_control::my_value
private

Definition at line 64 of file global_control.h.

Referenced by global_control().


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

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.