Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::internal::dynamic_grainsize_mode< Mode > Struct Template Reference

#include <partitioner.h>

Inheritance diagram for tbb::interface9::internal::dynamic_grainsize_mode< Mode >:
Collaboration diagram for tbb::interface9::internal::dynamic_grainsize_mode< Mode >:

Public Types

enum  { begin = 0, run, pass }
 

Public Member Functions

 dynamic_grainsize_mode ()
 
 dynamic_grainsize_mode (dynamic_grainsize_mode &p, split)
 
 dynamic_grainsize_mode (dynamic_grainsize_mode &p, const proportional_split &split_obj)
 
bool check_being_stolen (task &t)
 
depth_t max_depth ()
 
void align_depth (depth_t base)
 
template<typename StartType , typename Range >
void work_balance (StartType &start, Range &range)
 
bool check_for_demand (task &t)
 

Public Attributes

enum tbb::interface9::internal::dynamic_grainsize_mode:: { ... }  my_delay
 
depth_t my_max_depth
 

Static Public Attributes

static const unsigned range_pool_size = __TBB_RANGE_POOL_CAPACITY
 

Detailed Description

template<class Mode>
struct tbb::interface9::internal::dynamic_grainsize_mode< Mode >

Determine work-balance phase implementing splitting & stealing actions

Definition at line 380 of file partitioner.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Mode>
anonymous enum
Enumerator
begin 
run 
pass 

Definition at line 385 of file partitioner.h.

Constructor & Destructor Documentation

◆ dynamic_grainsize_mode() [1/3]

Definition at line 392 of file partitioner.h.

392  : Mode()
393 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
394  , my_dst_tsc(0)
395 #endif
396  , my_delay(begin)
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay
#define __TBB_INIT_DEPTH
Definition: partitioner.h:34

◆ dynamic_grainsize_mode() [2/3]

template<class Mode>
tbb::interface9::internal::dynamic_grainsize_mode< Mode >::dynamic_grainsize_mode ( dynamic_grainsize_mode< Mode > &  p,
split   
)
inline

Definition at line 398 of file partitioner.h.

399  : Mode(p, split())
400 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
401  , my_dst_tsc(0)
402 #endif
403  , my_delay(pass)
404  , my_max_depth(p.my_max_depth) {}
void const char const char int ITT_FORMAT __itt_group_sync p
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay

◆ dynamic_grainsize_mode() [3/3]

template<class Mode>
tbb::interface9::internal::dynamic_grainsize_mode< Mode >::dynamic_grainsize_mode ( dynamic_grainsize_mode< Mode > &  p,
const proportional_split split_obj 
)
inline

Definition at line 405 of file partitioner.h.

406  : Mode(p, split_obj)
407 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
408  , my_dst_tsc(0)
409 #endif
410  , my_delay(begin)
411  , my_max_depth(p.my_max_depth) {}
void const char const char int ITT_FORMAT __itt_group_sync p
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay

Member Function Documentation

◆ align_depth()

template<class Mode>
void tbb::interface9::internal::dynamic_grainsize_mode< Mode >::align_depth ( depth_t  base)
inline

Definition at line 432 of file partitioner.h.

432  {
433  __TBB_ASSERT(base <= my_max_depth, 0);
434  my_max_depth -= base;
435  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

◆ check_being_stolen()

template<class Mode>
bool tbb::interface9::internal::dynamic_grainsize_mode< Mode >::check_being_stolen ( task t)
inline

Definition at line 412 of file partitioner.h.

412  { // part of old should_execute_range()
413  if( !(self().my_divisor / Mode::my_partition::factor) ) { // if not from the top P tasks of binary tree
414  self().my_divisor = 1; // TODO: replace by on-stack flag (partition_state's member)?
415  if( t.is_stolen_task() && t.parent()->ref_count() >= 2 ) { // runs concurrently with the left task
416 #if __TBB_USE_OPTIONAL_RTTI
417  // RTTI is available, check whether the cast is valid
418  __TBB_ASSERT(dynamic_cast<flag_task*>(t.parent()), 0);
419  // correctness of the cast relies on avoiding the root task for which:
420  // - initial value of my_divisor != 0 (protected by separate assertion)
421  // - is_stolen_task() always returns false for the root task.
422 #endif
424  if( !my_max_depth ) my_max_depth++;
426  return true;
427  }
428  }
429  return false;
430  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
static void mark_task_stolen(task &t)
Definition: partitioner.h:134
#define __TBB_DEMAND_DEPTH_ADD
Definition: partitioner.h:38

◆ check_for_demand()

template<class Mode>
bool tbb::interface9::internal::dynamic_grainsize_mode< Mode >::check_for_demand ( task t)
inline

Definition at line 459 of file partitioner.h.

459  {
460  if( pass == my_delay ) {
461  if( self().my_divisor > 1 ) // produce affinitized tasks while they have slot in array
462  return true; // do not do my_max_depth++ here, but be sure range_pool is splittable once more
463  else if( self().my_divisor && my_max_depth ) { // make balancing task
464  self().my_divisor = 0; // once for each task; depth will be decreased in align_depth()
465  return true;
466  }
467  else if( flag_task::is_peer_stolen(t) ) {
469  return true;
470  }
471  } else if( begin == my_delay ) {
472 #ifndef __TBB_USE_MACHINE_TIME_STAMPS
473  my_delay = pass;
474 #else
475  my_dst_tsc = __TBB_time_stamp() + __TBB_task_duration();
476  my_delay = run;
477  } else if( run == my_delay ) {
478  if( __TBB_time_stamp() < my_dst_tsc ) {
479  __TBB_ASSERT(my_max_depth > 0, NULL);
480  my_max_depth--; // increase granularity since tasks seem having too small work
481  return false;
482  }
483  my_delay = pass;
484  return true;
485 #endif // __TBB_USE_MACHINE_TIME_STAMPS
486  }
487  return false;
488  }
#define __TBB_time_stamp()
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
static bool is_peer_stolen(task &t)
Definition: partitioner.h:143
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay
#define __TBB_DEMAND_DEPTH_ADD
Definition: partitioner.h:38

◆ max_depth()

template<class Mode>
depth_t tbb::interface9::internal::dynamic_grainsize_mode< Mode >::max_depth ( )
inline

Definition at line 431 of file partitioner.h.

◆ work_balance()

template<class Mode>
template<typename StartType , typename Range >
void tbb::interface9::internal::dynamic_grainsize_mode< Mode >::work_balance ( StartType &  start,
Range &  range 
)
inline

Definition at line 437 of file partitioner.h.

437  {
438  if( !range.is_divisible() || !self().max_depth() ) {
439  start.run_body( range ); // simple partitioner goes always here
440  }
441  else { // do range pool
442  internal::range_vector<Range, range_pool_size> range_pool(range);
443  do {
444  range_pool.split_to_fill(self().max_depth()); // fill range pool
445  if( self().check_for_demand( start ) ) {
446  if( range_pool.size() > 1 ) {
447  start.offer_work( range_pool.front(), range_pool.front_depth() );
448  range_pool.pop_front();
449  continue;
450  }
451  if( range_pool.is_divisible(self().max_depth()) ) // was not enough depth to fork a task
452  continue; // note: next split_to_fill() should split range at least once
453  }
454  start.run_body( range_pool.back() );
455  range_pool.pop_back();
456  } while( !range_pool.empty() && !start.is_cancelled() );
457  }
458  }

Member Data Documentation

◆ my_delay

enum { ... } tbb::interface9::internal::dynamic_grainsize_mode< Mode >::my_delay

◆ my_max_depth

template<class Mode>
depth_t tbb::interface9::internal::dynamic_grainsize_mode< Mode >::my_max_depth

Definition at line 390 of file partitioner.h.

◆ range_pool_size

template<class Mode>
const unsigned tbb::interface9::internal::dynamic_grainsize_mode< Mode >::range_pool_size = __TBB_RANGE_POOL_CAPACITY
static

Definition at line 391 of file partitioner.h.


The documentation for this struct 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.