Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::internal::range_vector< T, MaxCapacity > Class Template Reference

Range pool stores ranges of type T in a circular buffer with MaxCapacity. More...

#include <partitioner.h>

Collaboration diagram for tbb::interface9::internal::range_vector< T, MaxCapacity >:

Public Member Functions

 range_vector (const T &elem)
 initialize via first range in pool More...
 
 ~range_vector ()
 
bool empty () const
 
depth_t size () const
 
void split_to_fill (depth_t max_depth)
 
void pop_back ()
 
void pop_front ()
 
T & back ()
 
T & front ()
 
depth_t front_depth ()
 similarly to front(), returns depth of the first range in the pool More...
 
depth_t back_depth ()
 
bool is_divisible (depth_t max_depth)
 

Private Attributes

depth_t my_head
 
depth_t my_tail
 
depth_t my_size
 
depth_t my_depth [MaxCapacity]
 
tbb::aligned_space< T, MaxCapacity > my_pool
 

Detailed Description

template<typename T, depth_t MaxCapacity>
class tbb::interface9::internal::range_vector< T, MaxCapacity >

Range pool stores ranges of type T in a circular buffer with MaxCapacity.

Definition at line 154 of file partitioner.h.

Constructor & Destructor Documentation

◆ range_vector()

template<typename T, depth_t MaxCapacity>
tbb::interface9::internal::range_vector< T, MaxCapacity >::range_vector ( const T &  elem)
inline

initialize via first range in pool

Definition at line 163 of file partitioner.h.

163  : my_head(0), my_tail(0), my_size(1) {
164  my_depth[0] = 0;
165  new( static_cast<void *>(my_pool.begin()) ) T(elem);//TODO: std::move?
166  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159

◆ ~range_vector()

template<typename T, depth_t MaxCapacity>
tbb::interface9::internal::range_vector< T, MaxCapacity >::~range_vector ( )
inline

Definition at line 167 of file partitioner.h.

167  {
168  while( !empty() ) pop_back();
169  }

Member Function Documentation

◆ back()

template<typename T, depth_t MaxCapacity>
T& tbb::interface9::internal::range_vector< T, MaxCapacity >::back ( )
inline

Definition at line 197 of file partitioner.h.

197  {
198  __TBB_ASSERT(my_size > 0, "range_vector::back() with empty size");
199  return my_pool.begin()[my_head];
200  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ back_depth()

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::back_depth ( )
inline

Definition at line 210 of file partitioner.h.

210  {
211  __TBB_ASSERT(my_size > 0, "range_vector::back_depth() with empty size");
212  return my_depth[my_head];
213  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

◆ empty()

template<typename T, depth_t MaxCapacity>
bool tbb::interface9::internal::range_vector< T, MaxCapacity >::empty ( ) const
inline

Definition at line 170 of file partitioner.h.

170 { return my_size == 0; }

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ front()

template<typename T, depth_t MaxCapacity>
T& tbb::interface9::internal::range_vector< T, MaxCapacity >::front ( )
inline

Definition at line 201 of file partitioner.h.

201  {
202  __TBB_ASSERT(my_size > 0, "range_vector::front() with empty size");
203  return my_pool.begin()[my_tail];
204  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ front_depth()

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::front_depth ( )
inline

similarly to front(), returns depth of the first range in the pool

Definition at line 206 of file partitioner.h.

206  {
207  __TBB_ASSERT(my_size > 0, "range_vector::front_depth() with empty size");
208  return my_depth[my_tail];
209  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ is_divisible()

template<typename T, depth_t MaxCapacity>
bool tbb::interface9::internal::range_vector< T, MaxCapacity >::is_divisible ( depth_t  max_depth)
inline

Definition at line 214 of file partitioner.h.

214  {
215  return back_depth() < max_depth && back().is_divisible();
216  }

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ pop_back()

template<typename T, depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::pop_back ( )
inline

Definition at line 185 of file partitioner.h.

185  {
186  __TBB_ASSERT(my_size > 0, "range_vector::pop_back() with empty size");
187  my_pool.begin()[my_head].~T();
188  my_size--;
189  my_head = (my_head + MaxCapacity - 1) % MaxCapacity;
190  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ pop_front()

template<typename T, depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::pop_front ( )
inline

Definition at line 191 of file partitioner.h.

191  {
192  __TBB_ASSERT(my_size > 0, "range_vector::pop_front() with empty size");
193  my_pool.begin()[my_tail].~T();
194  my_size--;
195  my_tail = (my_tail + 1) % MaxCapacity;
196  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ size()

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::size ( ) const
inline

Definition at line 171 of file partitioner.h.

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

◆ split_to_fill()

template<typename T, depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::split_to_fill ( depth_t  max_depth)
inline

Populates range pool via ranges up to max depth or while divisible max_depth starts from 0, e.g. value 2 makes 3 ranges in the pool up to two 1/4 pieces

Definition at line 174 of file partitioner.h.

174  {
175  while( my_size < MaxCapacity && is_divisible(max_depth) ) {
176  depth_t prev = my_head;
177  my_head = (my_head + 1) % MaxCapacity;
178  new(my_pool.begin()+my_head) T(my_pool.begin()[prev]); // copy TODO: std::move?
179  my_pool.begin()[prev].~T(); // instead of assignment
180  new(my_pool.begin()+prev) T(my_pool.begin()[my_head], split()); // do 'inverse' split
181  my_depth[my_head] = ++my_depth[prev];
182  my_size++;
183  }
184  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:159
bool is_divisible(depth_t max_depth)
Definition: partitioner.h:214

Referenced by tbb::interface9::internal::dynamic_grainsize_mode< linear_affinity_mode< affinity_partition_type > >::work_balance().

Here is the caller graph for this function:

Member Data Documentation

◆ my_depth

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_depth[MaxCapacity]
private

Definition at line 158 of file partitioner.h.

◆ my_head

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_head
private

Definition at line 155 of file partitioner.h.

◆ my_pool

template<typename T, depth_t MaxCapacity>
tbb::aligned_space<T, MaxCapacity> tbb::interface9::internal::range_vector< T, MaxCapacity >::my_pool
private

Definition at line 159 of file partitioner.h.

◆ my_size

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_size
private

Definition at line 157 of file partitioner.h.

◆ my_tail

template<typename T, depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_tail
private

Definition at line 156 of file partitioner.h.


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.