tbb::blocked_range< Value > Class Template Reference
Algorithms

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.

:
my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
{
__TBB_ASSERT( my_grainsize>0, "grainsize must be positive" );
}

## 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.

:
my_end(r.my_end),
my_begin(do_split(r, split())),
my_grainsize(r.my_grainsize)
{
// only comparison 'less than' is required from values of blocked_range objects
__TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
}

## 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.

:
my_end(r.my_end),
my_begin(do_split(r, proportion)),
my_grainsize(r.my_grainsize)
{
// only comparison 'less than' is required from values of blocked_range objects
__TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
}

## 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.

{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,
|  | proportional_split & | proportion
| ) |  |

inline static private

Definition at line 140 of file blocked_range.h.

{
__TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
// usage of 32-bit floating point arithmetic is not enough to handle ranges of
// more than 2^24 iterations accurately. However, even on ranges with 2^64
// iterations the computational error approximately equals to 0.000001% which
// makes small impact on uniform distribution of such range's iterations (assuming
// all iterations take equal time to complete). See 'test_partitioner_whitebox'
// for implementation of an exact split algorithm
size_type right_part = size_type(float(r.size()) * float(proportion.right())
/ float(proportion.left() + proportion.right()) + 0.5f);
return r.my_end = Value(r.my_end - right_part);
}

## do_split() [2/2]

template<typename Value>

static Value tbb::blocked_range< Value >::do_split | ( | blocked_range< Value > & | r,
|  | split |
| ) |  |

inline static private

Auxiliary function used by the splitting constructor.

Definition at line 131 of file blocked_range.h.

{
__TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
Value middle = r.my_begin + (r.my_end - r.my_begin) / 2u;
r.my_end = middle;
return middle;
}

## 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.

{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.

{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.

{return 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.

{return my_grainsize<size();}

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.

{
__TBB_ASSERT( !(end()<begin()), "size() unspecified if end()<begin()" );
return size_type(my_end-my_begin);
}

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

template<typename Value>

Value tbb::blocked_range< Value >::my_begin

private

Definition at line 127 of file blocked_range.h.

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

## 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

Definition at line 128 of file blocked_range.h.

Referenced by tbb::blocked_range< I >::blocked_range(), tbb::blocked_range< I >::grainsize(), and tbb::blocked_range< I >::is_divisible().

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

- blocked_range.h

__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::blocked_range::my_end
Value my_end
Definition: blocked_range.h:126
tbb::blocked_range::size_type
std::size_t size_type
Type for size of a range.
Definition: blocked_range.h:53
tbb::blocked_range::my_begin
Value my_begin
Definition: blocked_range.h:127
tbb::blocked_range::do_split
static Value do_split(blocked_range &r, split)
Auxiliary function used by the splitting constructor.
Definition: blocked_range.h:131
tbb::blocked_range::begin
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:69
tbb::blocked_range::size
size_type size() const
Size of the range.
Definition: blocked_range.h:76
tbb::blocked_range::my_grainsize
size_type my_grainsize
Definition: blocked_range.h:128
tbb::blocked_range::end
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:72

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.