17#ifndef __TBB_partitioner_H
18#define __TBB_partitioner_H
20#define __TBB_partitioner_H_include_area
23#ifndef __TBB_INITIAL_CHUNKS
25#define __TBB_INITIAL_CHUNKS 2
27#ifndef __TBB_RANGE_POOL_CAPACITY
29#define __TBB_RANGE_POOL_CAPACITY 8
31#ifndef __TBB_INIT_DEPTH
33#define __TBB_INIT_DEPTH 5
35#ifndef __TBB_DEMAND_DEPTH_ADD
37#define __TBB_DEMAND_DEPTH_ADD 1
39#ifndef __TBB_STATIC_THRESHOLD
41#define __TBB_STATIC_THRESHOLD 40000
44#define __TBB_NONUNIFORM_TASK_CREATION 1
45#ifdef __TBB_time_stamp
46#define __TBB_USE_MACHINE_TIME_STAMPS 1
47#define __TBB_task_duration() __TBB_STATIC_THRESHOLD
57#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
59 #pragma warning (push)
60 #pragma warning (disable: 4244)
65class auto_partitioner;
66class simple_partitioner;
67class static_partitioner;
68class affinity_partitioner;
72 class affinity_partition_type;
109template<
typename Range,
typename Body,
typename Partitioner>
class start_scan;
114namespace interface9 {
115template<
typename Range,
typename Body,
typename Partitioner>
class start_for;
119namespace interface9 {
123template<
typename Range,
typename Body,
typename Partitioner>
class start_for;
124template<
typename Range,
typename Body,
typename Partitioner>
class start_reduce;
125template<
typename Range,
typename Body,
typename Partitioner>
class start_deterministic_reduce;
135#if TBB_USE_THREADING_TOOLS
137 flag.fetch_and_store<
release>(
true);
153template <
typename T, depth_t MaxCapacity>
165 new(
static_cast<void *
>(
my_pool.begin()) ) T(elem);
220template <
typename Partition>
232 Partition&
self() {
return *
static_cast<Partition*
>(
this); }
234 template<
typename StartType,
typename Range>
236 start.run_body( range );
239 template<
typename StartType,
typename Range>
240 void execute(StartType &start, Range &range) {
248 if ( range.is_divisible() ) {
251 typename Partition::split_type split_obj =
self().template get_split<Range>();
252 start.offer_work( split_obj );
256 self().work_balance(start, range);
261template <
typename Partition>
283template <
typename Range,
typename =
void>
287template <
typename Range>
290#if __TBB_NONUNIFORM_TASK_CREATION
291 size_t right = (n + 2) / 3;
293 size_t right = n / 2;
295 size_t left = n - right;
301template <
typename Partition>
310#if __TBB_ENABLE_RANGE_FEEDBACK
311 size_t portion = size_t(
float(src.
my_divisor) *
float(split_obj.
right())
312 /
float(split_obj.
left() + split_obj.
right()) + 0.5f);
314 size_t portion = split_obj.
right() * my_partition::factor;
316 portion = (portion + my_partition::factor/2) & (0ul - my_partition::factor);
317#if __TBB_ENABLE_RANGE_FEEDBACK
320 portion = my_partition::factor;
322 portion = src.
my_divisor - my_partition::factor;
328 return self().my_divisor > my_partition::factor;
330 template <
typename Range>
341 return size_t(current_index);
345template <
typename Partition>
366#ifdef __TBB_USE_MACHINE_TIME_STAMPS
377#ifdef __TBB_USE_MACHINE_TIME_STAMPS
384#ifdef __TBB_USE_MACHINE_TIME_STAMPS
391#ifdef __TBB_USE_MACHINE_TIME_STAMPS
397 if( !(self().my_divisor / Mode::my_partition::factor) ) {
398 self().my_divisor = 1;
400#if __TBB_USE_OPTIONAL_RTTI
420 template<
typename StartType,
typename Range>
422 if( !range.is_divisible() || !self().
max_depth() ) {
423 start.run_body( range );
430 if( range_pool.
size() > 1 ) {
438 start.run_body( range_pool.
back() );
440 }
while( !range_pool.
empty() && !start.is_cancelled() );
445 if( self().my_divisor > 1 )
448 self().my_divisor = 0;
456#ifndef __TBB_USE_MACHINE_TIME_STAMPS
505 template<
typename StartType,
typename Range>
506 void execute(StartType &start, Range &range) {
507 split_type split_obj =
split();
508 while( range.is_divisible() )
509 start.offer_work( split_obj );
510 start.run_body( range );
606 typedef interface9::internal::simple_partition_type::split_type
split_type;
628 typedef interface9::internal::auto_partition_type::split_type
split_type;
671#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
672 #pragma warning (pop)
674#undef __TBB_INITIAL_CHUNKS
675#undef __TBB_RANGE_POOL_CAPACITY
676#undef __TBB_INIT_DEPTH
679#undef __TBB_partitioner_H_include_area
#define __TBB_EXPORTED_METHOD
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define __TBB_DEMAND_DEPTH_ADD
#define __TBB_RANGE_POOL_CAPACITY
#define __TBB_INITIAL_CHUNKS
#define __TBB_time_stamp()
#define __TBB_EXPORTED_FUNC
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 id
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 ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
Identifiers declared inside namespace internal should never be used directly by client code.
unsigned short affinity_id
An id as used for specifying affinity.
size_t __TBB_EXPORTED_FUNC get_initial_auto_partitioner_divisor()
static size_t get_initial_partition_head()
int current_thread_index()
Returns the index, aka slot number, of the calling thread in its current arena.
Enables one or the other code branches.
Task type used in parallel_for.
Task type used to split the work of parallel_reduce.
Task type used to split the work of parallel_deterministic_reduce.
Initial task to split the work.
Defines entry point for affinity partitioner into TBB run-time library.
size_t my_size
Number of elements in my_array.
void __TBB_EXPORTED_METHOD resize(unsigned factor)
Resize my_array.
affinity_partitioner_base_v3()
Zeros the fields.
~affinity_partitioner_base_v3()
Deallocates my_array.
affinity_id * my_array
Array that remembers affinities of tree positions to affinity_id.
Provides backward-compatible methods for partition objects without affinity.
task * continue_after_execute_range()
void note_affinity(task::affinity_id)
void spawn_or_delay(bool, task &b)
void set_affinity(task &)
bool decide_whether_to_delay()
Join task node that contains shared flag for stealing feedback.
static bool is_peer_stolen(task &t)
static void mark_task_stolen(task &t)
tbb::atomic< bool > my_child_stolen
task * execute() __TBB_override
Should be overridden by derived classes.
Range pool stores ranges of type T in a circular buffer with MaxCapacity.
void split_to_fill(depth_t max_depth)
tbb::aligned_space< T, MaxCapacity > my_pool
range_vector(const T &elem)
initialize via first range in pool
depth_t my_depth[MaxCapacity]
bool is_divisible(depth_t max_depth)
depth_t front_depth()
similarly to front(), returns depth of the first range in the pool
void note_affinity(task::affinity_id)
void execute(StartType &start, Range &range)
bool check_for_demand(task &)
void work_balance(StartType &start, Range &range)
bool check_being_stolen(task &)
void align_depth(depth_t)
void set_affinity(task &)
Provides default splitting strategy for partition objects.
static const unsigned factor
adaptive_mode(adaptive_mode &src, split)
size_t do_split(adaptive_mode &src, split)
A helper class to create a proportional_split object for a given type of Range.
static proportional_split get_split(size_t)
static proportional_split get_split(size_t n)
Provides proportional splitting strategy for partition objects.
proportional_split get_split()
size_t do_split(proportional_mode &src, const proportional_split &split_obj)
proportional_mode(proportional_mode &src, split)
proportional_mode(proportional_mode &src, const proportional_split &split_obj)
Provides default linear indexing of partitioner's sequence.
linear_affinity_mode(linear_affinity_mode &src, const proportional_split &split_obj)
linear_affinity_mode(linear_affinity_mode &src, split)
void set_affinity(task &t)
dynamic_grainsize_mode(dynamic_grainsize_mode &p, split)
bool check_for_demand(task &t)
bool check_being_stolen(task &t)
static const unsigned range_pool_size
void align_depth(depth_t base)
void work_balance(StartType &start, Range &range)
enum tbb::interface9::internal::dynamic_grainsize_mode::@15 my_delay
dynamic_grainsize_mode(dynamic_grainsize_mode &p, const proportional_split &split_obj)
bool check_for_demand(task &t)
auto_partition_type(const auto_partitioner &)
auto_partition_type(auto_partition_type &src, split)
simple_partition_type(const simple_partitioner &)
void execute(StartType &start, Range &range)
simplified algorithm
simple_partition_type(const simple_partition_type &, split)
static_partition_type(const static_partitioner &)
static_partition_type(static_partition_type &p, const proportional_split &split_obj)
static_partition_type(static_partition_type &p, split)
proportional_split split_type
tbb::internal::affinity_id * my_array
static const unsigned factor_power
affinity_partition_type(affinity_partition_type &p, split)
void note_affinity(task::affinity_id id)
affinity_partition_type(tbb::internal::affinity_partitioner_base_v3 &ap)
static const unsigned factor
proportional_split split_type
affinity_partition_type(affinity_partition_type &p, const proportional_split &split_obj)
void set_affinity(task &t)
Backward-compatible partition for auto and affinity partition objects.
old_auto_partition_type(const affinity_partitioner &)
old_auto_partition_type(old_auto_partition_type &pt, split)
old_auto_partition_type(const auto_partitioner &)
static const size_t VICTIM_CHUNKS
bool should_execute_range(const task &t)
interface9::internal::simple_partition_type task_partition_type
interface9::internal::simple_partition_type::split_type split_type
partition_type(const simple_partitioner &)
bool should_execute_range(const task &)
partition_type(const partition_type &, split)
interface9::internal::auto_partition_type::split_type split_type
interface9::internal::auto_partition_type task_partition_type
interface9::internal::old_auto_partition_type partition_type
interface9::internal::static_partition_type task_partition_type
interface9::internal::static_partition_type::split_type split_type
interface9::internal::old_auto_partition_type partition_type
interface9::internal::affinity_partition_type::split_type split_type
interface9::internal::affinity_partition_type task_partition_type
interface9::internal::old_auto_partition_type partition_type
Base class for user-defined tasks.
bool is_stolen_task() const
True if task was stolen from the task pool of another thread.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
int ref_count() const
The internal reference count.
void set_affinity(affinity_id id)
Set affinity for this task.
internal::affinity_id affinity_id
An id as used for specifying affinity.
static const int not_initialized
Base class for types that should not be copied or assigned.
Dummy type that distinguishes splitting constructor from copy constructor.
Type enables transmission of splitting proportion from partitioners to range objects.