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

Member Enumeration Documentation

◆ anonymous enum

template<class Mode>
anonymous enum
Enumerator
begin 
run 
pass 

Definition at line 366 of file partitioner.h.

Constructor & Destructor Documentation

◆ dynamic_grainsize_mode() [1/3]

Definition at line 373 of file partitioner.h.

373  : Mode()
374 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
375  , my_dst_tsc(0)
376 #endif
377  , my_delay(begin)
#define __TBB_INIT_DEPTH
Definition: partitioner.h:30
enum tbb::interface9::internal::dynamic_grainsize_mode::@23 my_delay

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

380  : Mode(p, split())
381 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
382  , my_dst_tsc(0)
383 #endif
384  , my_delay(pass)
385  , 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 386 of file partitioner.h.

387  : Mode(p, split_obj)
388 #ifdef __TBB_USE_MACHINE_TIME_STAMPS
389  , my_dst_tsc(0)
390 #endif
391  , my_delay(begin)
392  , 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 413 of file partitioner.h.

413  {
414  __TBB_ASSERT(base <= my_max_depth, 0);
415  my_max_depth -= base;
416  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

◆ check_being_stolen()

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

Definition at line 393 of file partitioner.h.

393  { // part of old should_execute_range()
394  if( !(self().my_divisor / Mode::my_partition::factor) ) { // if not from the top P tasks of binary tree
395  self().my_divisor = 1; // TODO: replace by on-stack flag (partition_state's member)?
396  if( t.is_stolen_task() && t.parent()->ref_count() >= 2 ) { // runs concurrently with the left task
397 #if __TBB_USE_OPTIONAL_RTTI
398  // RTTI is available, check whether the cast is valid
399  __TBB_ASSERT(dynamic_cast<flag_task*>(t.parent()), 0);
400  // correctness of the cast relies on avoiding the root task for which:
401  // - initial value of my_divisor != 0 (protected by separate assertion)
402  // - is_stolen_task() always returns false for the root task.
403 #endif
405  if( !my_max_depth ) my_max_depth++;
407  return true;
408  }
409  }
410  return false;
411  }
static void mark_task_stolen(task &t)
Definition: partitioner.h:130
#define __TBB_DEMAND_DEPTH_ADD
Definition: partitioner.h:34
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

◆ check_for_demand()

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

Definition at line 440 of file partitioner.h.

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

◆ max_depth()

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

Definition at line 412 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 418 of file partitioner.h.

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

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 371 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 372 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.