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.

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

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  }
void __TBB_EXPORTED_METHOD internal_create()
Definition: tbb_main.cpp:524
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
#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 p
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
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.

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

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  }
void __TBB_EXPORTED_METHOD internal_destroy()
Definition: tbb_main.cpp:540
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
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.

References __TBB_ASSERT, and parameter_max.

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

59  {
60  __TBB_ASSERT(p < parameter_max, "Invalid parameter");
61  return active_value((int)p);
62  }
static size_t active_value(parameter 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 p
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 580 of file tbb_main.cpp.

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

580  {
582  return controls[param]->active_value();
583 }
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
virtual size_t active_value() const
Definition: tbb_main.cpp:462
static control_storage * controls[]
Definition: tbb_main.cpp:511
Here is the call graph for this function:

◆ internal_create()

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

Definition at line 524 of file tbb_main.cpp.

References __TBB_ASSERT_RELEASE, tbb::internal::control_storage::apply_active(), tbb::internal::controls, tbb::internal::control_storage::is_first_arg_preferred(), tbb::internal::__TBB_InitOnce::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().

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

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(), tbb::internal::__TBB_InitOnce::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().

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