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

## Member Enumeration Documentation

## anonymous enum

template<class Mode>

anonymous enum

Enumerator
begin |
run |
pass |

Definition at line 369 of file partitioner.h.

{
begin = 0,
run,
pass
} my_delay;

## Constructor & Destructor Documentation

## dynamic_grainsize_mode() [1/3]

template<class Mode>

tbb::interface9::internal::dynamic_grainsize_mode< Mode >::dynamic_grainsize_mode | ( |  | ) |

inline

Definition at line 376 of file partitioner.h.

: Mode()
#ifdef __TBB_USE_MACHINE_TIME_STAMPS
, my_dst_tsc(0)
#endif
, my_delay(begin)
, my_max_depth(__TBB_INIT_DEPTH) {}

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

: Mode(p, split())
#ifdef __TBB_USE_MACHINE_TIME_STAMPS
, my_dst_tsc(0)
#endif
, my_delay(pass)
, my_max_depth(p.my_max_depth) {}

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

: Mode(p, split_obj)
#ifdef __TBB_USE_MACHINE_TIME_STAMPS
, my_dst_tsc(0)
#endif
, my_delay(begin)
, my_max_depth(p.my_max_depth) {}

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

{
__TBB_ASSERT(base <= my_max_depth, 0);
my_max_depth -= base;
}

## check_being_stolen()

template<class Mode>

bool tbb::interface9::internal::dynamic_grainsize_mode< Mode >::check_being_stolen | ( | task & | t | ) |

inline

Definition at line 396 of file partitioner.h.

{ // part of old should_execute_range()
if( !(self().my_divisor / Mode::my_partition::factor) ) { // if not from the top P tasks of binary tree
self().my_divisor = 1; // TODO: replace by on-stack flag (partition_state's member)?
if( t.is_stolen_task() && t.parent()->ref_count() >= 2 ) { // runs concurrently with the left task
#if __TBB_USE_OPTIONAL_RTTI
// RTTI is available, check whether the cast is valid
__TBB_ASSERT(dynamic_cast<flag_task*>(t.parent()), 0);
// correctness of the cast relies on avoiding the root task for which:
// - initial value of my_divisor != 0 (protected by separate assertion)
// - is_stolen_task() always returns false for the root task.
#endif
flag_task::mark_task_stolen(t);
if( !my_max_depth ) my_max_depth++;
my_max_depth += __TBB_DEMAND_DEPTH_ADD;
return true;
}
}
return false;
}

## check_for_demand()

template<class Mode>

bool tbb::interface9::internal::dynamic_grainsize_mode< Mode >::check_for_demand | ( | task & | t | ) |

inline

Definition at line 443 of file partitioner.h.

{
if( pass == my_delay ) {
if( self().my_divisor > 1 ) // produce affinitized tasks while they have slot in array
return true; // do not do my_max_depth++ here, but be sure range_pool is splittable once more
else if( self().my_divisor && my_max_depth ) { // make balancing task
self().my_divisor = 0; // once for each task; depth will be decreased in align_depth()
return true;
}
else if( flag_task::is_peer_stolen(t) ) {
my_max_depth += __TBB_DEMAND_DEPTH_ADD;
return true;
}
} else if( begin == my_delay ) {
#ifndef __TBB_USE_MACHINE_TIME_STAMPS
my_delay = pass;
#else
my_dst_tsc = __TBB_time_stamp() + __TBB_task_duration();
my_delay = run;
} else if( run == my_delay ) {
if( __TBB_time_stamp() < my_dst_tsc ) {
__TBB_ASSERT(my_max_depth > 0, NULL);
my_max_depth--; // increase granularity since tasks seem having too small work
return false;
}
my_delay = pass;
return true;
#endif // __TBB_USE_MACHINE_TIME_STAMPS
}
return false;
}

## max_depth()

template<class Mode>

depth_t tbb::interface9::internal::dynamic_grainsize_mode< Mode >::max_depth | ( |  | ) |

inline

Definition at line 415 of file partitioner.h.

{ return my_max_depth; }

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

{
if( !range.is_divisible() || !self().max_depth() ) {
start.run_body( range ); // simple partitioner goes always here
}
else { // do range pool
internal::range_vector<Range, range_pool_size> range_pool(range);
do {
range_pool.split_to_fill(self().max_depth()); // fill range pool
if( self().check_for_demand( start ) ) {
if( range_pool.size() > 1 ) {
start.offer_work( range_pool.front(), range_pool.front_depth() );
range_pool.pop_front();
continue;
}
if( range_pool.is_divisible(self().max_depth()) ) // was not enough depth to fork a task
continue; // note: next split_to_fill() should split range at least once
}
start.run_body( range_pool.back() );
range_pool.pop_back();
} while( !range_pool.empty() && !start.is_cancelled() );
}
}

## 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 374 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 375 of file partitioner.h.

The documentation for this struct was generated from the following file:

- partitioner.h

tbb::interface9::internal::dynamic_grainsize_mode::begin
Definition: partitioner.h:370
tbb::interface9::internal::dynamic_grainsize_mode::pass
Definition: partitioner.h:372
tbb::interface9::internal::flag_task::mark_task_stolen
static void mark_task_stolen(task &t)
Definition: partitioner.h:133
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::interface9::internal::dynamic_grainsize_mode::max_depth
depth_t max_depth()
Definition: partitioner.h:415
tbb::interface9::internal::dynamic_grainsize_mode::check_for_demand
bool check_for_demand(task &t)
Definition: partitioner.h:443
__TBB_INIT_DEPTH
#define __TBB_INIT_DEPTH
Definition: partitioner.h:33
tbb::interface9::internal::dynamic_grainsize_mode::run
Definition: partitioner.h:371
tbb::interface9::internal::flag_task::is_peer_stolen
static bool is_peer_stolen(task &t)
Definition: partitioner.h:142
__TBB_DEMAND_DEPTH_ADD
#define __TBB_DEMAND_DEPTH_ADD
Definition: partitioner.h:37
__TBB_time_stamp
#define __TBB_time_stamp()
Definition: gcc_ia32_common.h:63
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::interface9::internal::dynamic_grainsize_mode::my_delay
enum tbb::interface9::internal::dynamic_grainsize_mode::@15 my_delay
tbb::interface9::internal::dynamic_grainsize_mode::my_max_depth
depth_t my_max_depth
Definition: partitioner.h:374

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.