Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::blocked_range< Value > Class Template Reference

A range over which to iterate. More...

#include <blocked_range.h>

Inheritance diagram for tbb::blocked_range< Value >:
Collaboration diagram for tbb::blocked_range< Value >:

Public Types

typedef Value const_iterator
 Type of a value. More...
 
typedef std::size_t size_type
 Type for size of a range. More...
 

Public Member Functions

 blocked_range (Value begin_, Value end_, size_type grainsize_=1)
 Construct range over half-open interval [begin,end), with the given grainsize. More...
 
const_iterator begin () const
 Beginning of range. More...
 
const_iterator end () const
 One past last value in range. More...
 
size_type size () const
 Size of the range. More...
 
size_type grainsize () const
 The grain size for this range. More...
 
bool empty () const
 True if range is empty. More...
 
bool is_divisible () const
 True if range is divisible. More...
 
 blocked_range (blocked_range &r, split)
 Split range. More...
 
 blocked_range (blocked_range &r, proportional_split &proportion)
 Split range. More...
 

Static Public Attributes

static const bool is_splittable_in_proportion = true
 Static field to support proportional split. More...
 

Static Private Member Functions

static Value do_split (blocked_range &r, split)
 Auxiliary function used by the splitting constructor. More...
 
static Value do_split (blocked_range &r, proportional_split &proportion)
 

Private Attributes

Value my_end
 
Value my_begin
 
size_type my_grainsize
 

Friends

template<typename RowValue , typename ColValue >
class blocked_range2d
 
template<typename RowValue , typename ColValue , typename PageValue >
class blocked_range3d
 
template<typename DimValue , unsigned int N, typename >
class internal::blocked_rangeNd_impl
 

Detailed Description

template<typename Value>
class tbb::blocked_range< Value >

A range over which to iterate.

Definition at line 49 of file blocked_range.h.

Member Typedef Documentation

◆ const_iterator

template<typename Value>
typedef Value tbb::blocked_range< Value >::const_iterator

Type of a value.

Called a const_iterator for sake of algorithms that need to treat a blocked_range as an STL container.

Definition at line 54 of file blocked_range.h.

◆ size_type

template<typename Value>
typedef std::size_t tbb::blocked_range< Value >::size_type

Type for size of a range.

Definition at line 57 of file blocked_range.h.

Constructor & Destructor Documentation

◆ blocked_range() [1/3]

template<typename Value>
tbb::blocked_range< Value >::blocked_range ( Value  begin_,
Value  end_,
size_type  grainsize_ = 1 
)
inline

Construct range over half-open interval [begin,end), with the given grainsize.

Definition at line 66 of file blocked_range.h.

66  :
67  my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
68  {
69  __TBB_ASSERT( my_grainsize>0, "grainsize must be positive" );
70  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
size_type my_grainsize

◆ blocked_range() [2/3]

template<typename Value>
tbb::blocked_range< Value >::blocked_range ( blocked_range< Value > &  r,
split   
)
inline

Split range.

The new Range *this has the second part, the old range r has the first part. Unspecified if end()<begin() or !is_divisible().

Definition at line 102 of file blocked_range.h.

102  :
103  my_end(r.my_end),
104  my_begin(do_split(r, split())),
105  my_grainsize(r.my_grainsize)
106  {
107  // only comparison 'less than' is required from values of blocked_range objects
108  __TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
109  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
static Value do_split(blocked_range &r, split)
Auxiliary function used by the splitting constructor.
size_type my_grainsize

◆ blocked_range() [3/3]

template<typename Value>
tbb::blocked_range< Value >::blocked_range ( blocked_range< Value > &  r,
proportional_split proportion 
)
inline

Split range.

The new Range *this has the second part split according to specified proportion, the old range r has the first part. Unspecified if end()<begin() or !is_divisible().

Definition at line 118 of file blocked_range.h.

118  :
119  my_end(r.my_end),
120  my_begin(do_split(r, proportion)),
121  my_grainsize(r.my_grainsize)
122  {
123  // only comparison 'less than' is required from values of blocked_range objects
124  __TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
125  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
static Value do_split(blocked_range &r, split)
Auxiliary function used by the splitting constructor.
size_type my_grainsize

Member Function Documentation

◆ begin()

template<typename Value>
const_iterator tbb::blocked_range< Value >::begin ( ) const
inline

Beginning of range.

Definition at line 73 of file blocked_range.h.

73 {return my_begin;}

Referenced by tbb::internal::parallel_for_each_body_for< Function, Iterator >::operator()(), tbb::interface9::internal::quick_sort_pretest_body< RandomAccessIterator, Compare >::operator()(), tbb::internal::parallel_for_body< Function, Index >::operator()(), and tbb::blocked_range< I >::size().

Here is the caller graph for this function:

◆ do_split() [1/2]

template<typename Value>
static Value tbb::blocked_range< Value >::do_split ( blocked_range< Value > &  r,
split   
)
inlinestaticprivate

Auxiliary function used by the splitting constructor.

Definition at line 135 of file blocked_range.h.

136  {
137  __TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
138  Value middle = r.my_begin + (r.my_end - r.my_begin) / 2u;
139  r.my_end = middle;
140  return middle;
141  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

◆ do_split() [2/2]

template<typename Value>
static Value tbb::blocked_range< Value >::do_split ( blocked_range< Value > &  r,
proportional_split proportion 
)
inlinestaticprivate

Definition at line 144 of file blocked_range.h.

145  {
146  __TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
147 
148  // usage of 32-bit floating point arithmetic is not enough to handle ranges of
149  // more than 2^24 iterations accurately. However, even on ranges with 2^64
150  // iterations the computational error approximately equals to 0.000001% which
151  // makes small impact on uniform distribution of such range's iterations (assuming
152  // all iterations take equal time to complete). See 'test_partitioner_whitebox'
153  // for implementation of an exact split algorithm
154  size_type right_part = size_type(float(r.size()) * float(proportion.right())
155  / float(proportion.left() + proportion.right()) + 0.5f);
156  return r.my_end = Value(r.my_end - right_part);
157  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
std::size_t size_type
Type for size of a range.
Definition: blocked_range.h:57

◆ empty()

template<typename Value>
bool tbb::blocked_range< Value >::empty ( ) const
inline

True if range is empty.

Definition at line 93 of file blocked_range.h.

93 {return !(my_begin<my_end);}

Referenced by tbb::blocked_range2d< RowValue, ColValue >::empty(), and tbb::blocked_range3d< PageValue, RowValue, ColValue >::empty().

Here is the caller graph for this function:

◆ end()

template<typename Value>
const_iterator tbb::blocked_range< Value >::end ( ) const
inline

One past last value in range.

Definition at line 76 of file blocked_range.h.

76 {return my_end;}

Referenced by tbb::internal::parallel_for_each_body_for< Function, Iterator >::operator()(), tbb::interface9::internal::quick_sort_pretest_body< RandomAccessIterator, Compare >::operator()(), tbb::internal::parallel_for_body< Function, Index >::operator()(), and tbb::blocked_range< I >::size().

Here is the caller graph for this function:

◆ grainsize()

template<typename Value>
size_type tbb::blocked_range< Value >::grainsize ( ) const
inline

The grain size for this range.

Definition at line 86 of file blocked_range.h.

86 {return my_grainsize;}
size_type my_grainsize

Referenced by tbb::blocked_range2d< RowValue, ColValue >::do_split(), and tbb::blocked_range3d< PageValue, RowValue, ColValue >::do_split().

Here is the caller graph for this function:

◆ is_divisible()

template<typename Value>
bool tbb::blocked_range< Value >::is_divisible ( ) const
inline

True if range is divisible.

Unspecified if end()<begin().

Definition at line 97 of file blocked_range.h.

97 {return my_grainsize<size();}
size_type size() const
Size of the range.
Definition: blocked_range.h:80
size_type my_grainsize

Referenced by tbb::blocked_range< I >::do_split(), tbb::blocked_range2d< RowValue, ColValue >::is_divisible(), and tbb::blocked_range3d< PageValue, RowValue, ColValue >::is_divisible().

Here is the caller graph for this function:

◆ size()

template<typename Value>
size_type tbb::blocked_range< Value >::size ( ) const
inline

Size of the range.

Unspecified if end()<begin().

Definition at line 80 of file blocked_range.h.

80  {
81  __TBB_ASSERT( !(end()<begin()), "size() unspecified if end()<begin()" );
82  return size_type(my_end-my_begin);
83  }
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:73
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:76
std::size_t size_type
Type for size of a range.
Definition: blocked_range.h:57

Referenced by tbb::blocked_range2d< RowValue, ColValue >::do_split(), tbb::blocked_range3d< PageValue, RowValue, ColValue >::do_split(), tbb::blocked_range< I >::do_split(), and tbb::blocked_range< I >::is_divisible().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ blocked_range2d

template<typename Value>
template<typename RowValue , typename ColValue >
friend class blocked_range2d
friend

Definition at line 161 of file blocked_range.h.

◆ blocked_range3d

template<typename Value>
template<typename RowValue , typename ColValue , typename PageValue >
friend class blocked_range3d
friend

Definition at line 164 of file blocked_range.h.

◆ internal::blocked_rangeNd_impl

template<typename Value>
template<typename DimValue , unsigned int N, typename >
friend class internal::blocked_rangeNd_impl
friend

Definition at line 167 of file blocked_range.h.

Member Data Documentation

◆ is_splittable_in_proportion

template<typename Value>
const bool tbb::blocked_range< Value >::is_splittable_in_proportion = true
static

Static field to support proportional split.

Definition at line 113 of file blocked_range.h.

◆ my_begin

◆ my_end

template<typename Value>
Value tbb::blocked_range< Value >::my_end
private

NOTE: my_end MUST be declared before my_begin, otherwise the splitting constructor will break.

Definition at line 130 of file blocked_range.h.

Referenced by tbb::blocked_range< I >::blocked_range(), tbb::blocked_range< I >::do_split(), tbb::blocked_range< I >::empty(), tbb::blocked_range< I >::end(), and tbb::blocked_range< I >::size().

◆ my_grainsize

template<typename Value>
size_type tbb::blocked_range< Value >::my_grainsize
private

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