Home ⌂Doc Index ◂Up ▴
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 45 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 50 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 53 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 62 of file blocked_range.h.

62  :
63  my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
64  {
65  __TBB_ASSERT( my_grainsize>0, "grainsize must be positive" );
66  }
size_type my_grainsize
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

◆ 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 98 of file blocked_range.h.

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

◆ 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 114 of file blocked_range.h.

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

Member Function Documentation

◆ begin()

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

Beginning of range.

Definition at line 69 of file blocked_range.h.

69 {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 131 of file blocked_range.h.

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

◆ 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 140 of file blocked_range.h.

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

◆ empty()

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

True if range is empty.

Definition at line 89 of file blocked_range.h.

89 {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 72 of file blocked_range.h.

72 {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 82 of file blocked_range.h.

82 {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 93 of file blocked_range.h.

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

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 76 of file blocked_range.h.

76  {
77  __TBB_ASSERT( !(end()<begin()), "size() unspecified if end()<begin()" );
78  return size_type(my_end-my_begin);
79  }
std::size_t size_type
Type for size of a range.
Definition: blocked_range.h:53
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:69
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:72

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 157 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 160 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 163 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 109 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 126 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-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.