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 365 of file partitioner.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Mode>
anonymous enum
Enumerator
begin 
run 
pass 

Definition at line 370 of file partitioner.h.

Constructor & Destructor Documentation

◆ dynamic_grainsize_mode() [1/3]

Definition at line 377 of file partitioner.h.

377  : Mode()
378 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
379  , my_dst_tsc(0)
380 #endif
381  , 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 383 of file partitioner.h.

384  : Mode(p, split())
385 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
386  , my_dst_tsc(0)
387 #endif
388  , my_delay(pass)
389  , my_max_depth(p.my_max_depth) {}
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay
void const char const char int ITT_FORMAT __itt_group_sync p

◆ 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 390 of file partitioner.h.

391  : Mode(p, split_obj)
392 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
393  , my_dst_tsc(0)
394 #endif
395  , my_delay(begin)
396  , my_max_depth(p.my_max_depth) {}
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay
void const char const char int ITT_FORMAT __itt_group_sync p

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 417 of file partitioner.h.

417  {
418  __TBB_ASSERT(base <= my_max_depth, 0);
419  my_max_depth -= base;
420  }
#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 397 of file partitioner.h.

397  { // part of old should_execute_range()
398  if( !(self().my_divisor / Mode::my_partition::factor) ) { // if not from the top P tasks of binary tree
399  self().my_divisor = 1; // TODO: replace by on-stack flag (partition_state's member)?
400  if( t.is_stolen_task() && t.parent()->ref_count() >= 2 ) { // runs concurrently with the left task
401 #if __TBB_USE_OPTIONAL_RTTI
402  // RTTI is available, check whether the cast is valid
403  __TBB_ASSERT(dynamic_cast<flag_task*>(t.parent()), 0);
404  // correctness of the cast relies on avoiding the root task for which:
405  // - initial value of my_divisor != 0 (protected by separate assertion)
406  // - is_stolen_task() always returns false for the root task.
407 #endif
409  if( !my_max_depth ) my_max_depth++;
411  return true;
412  }
413  }
414  return false;
415  }
#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 444 of file partitioner.h.

444  {
445  if( pass == my_delay ) {
446  if( self().my_divisor > 1 ) // produce affinitized tasks while they have slot in array
447  return true; // do not do my_max_depth++ here, but be sure range_pool is splittable once more
448  else if( self().my_divisor && my_max_depth ) { // make balancing task
449  self().my_divisor = 0; // once for each task; depth will be decreased in align_depth()
450  return true;
451  }
452  else if( flag_task::is_peer_stolen(t) ) {
454  return true;
455  }
456  } else if( begin == my_delay ) {
457 #ifndef __TBB_USE_MACHINE_TIME_STAMPS
458  my_delay = pass;
459 #else
460  my_dst_tsc = __TBB_time_stamp() + __TBB_task_duration();
461  my_delay = run;
462  } else if( run == my_delay ) {
463  if( __TBB_time_stamp() < my_dst_tsc ) {
464  __TBB_ASSERT(my_max_depth > 0, NULL);
465  my_max_depth--; // increase granularity since tasks seem having too small work
466  return false;
467  }
468  my_delay = pass;
469  return true;
470 #endif // __TBB_USE_MACHINE_TIME_STAMPS
471  }
472  return false;
473  }
#define __TBB_time_stamp()
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay
static bool is_peer_stolen(task &t)
Definition: partitioner.h:143
#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 416 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 422 of file partitioner.h.

422  {
423  if( !range.is_divisible() || !self().max_depth() ) {
424  start.run_body( range ); // simple partitioner goes always here
425  }
426  else { // do range pool
427  internal::range_vector<Range, range_pool_size> range_pool(range);
428  do {
429  range_pool.split_to_fill(self().max_depth()); // fill range pool
430  if( self().check_for_demand( start ) ) {
431  if( range_pool.size() > 1 ) {
432  start.offer_work( range_pool.front(), range_pool.front_depth() );
433  range_pool.pop_front();
434  continue;
435  }
436  if( range_pool.is_divisible(self().max_depth()) ) // was not enough depth to fork a task
437  continue; // note: next split_to_fill() should split range at least once
438  }
439  start.run_body( range_pool.back() );
440  range_pool.pop_back();
441  } while( !range_pool.empty() && !start.is_cancelled() );
442  }
443  }

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 375 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 376 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.