Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::Range1d< Iter > Class Template Reference

An iteration range over a 1D data set. Splits divide the range in two based unless the minimum size is reached. Splits are determined by a splitter object. Successive splits result in a binary tree where each leaf represents a unit of work. More...

#include <Range1d.h>

Public Types

using iter_type = Iter
 
using split_result = SplitResult< Range1d, MAX_SPLITS, DIMENSIONALITY >
 
using size_type = size_t
 

Public Member Functions

 Range1d (Range1d const &)=default
 
GTS_INLINE Range1d (iter_type xBegin, iter_type xEnd, size_type minSize, size_type splitOnMultiplesOf=1)
 Constructs a Range1d. More...
 
GTS_INLINE iter_type begin () const
 
GTS_INLINE iter_type end () const
 
GTS_INLINE iter_type & begin ()
 
GTS_INLINE iter_type & end ()
 
GTS_INLINE bool empty () const
 
GTS_INLINE size_type size () const
 
GTS_INLINE size_type initialSize () const
 
GTS_INLINE void resetInitialSize (size_type initSize)
 
GTS_INLINE size_type minSize () const
 
GTS_INLINE size_type splitOnMultiplesOf () const
 
GTS_INLINE bool isDivisible () const
 
template<typename TSplitter >
GTS_INLINE void split (split_result &result, TSplitter const &splitter)
 Divides the range based on the splitter. More...
 

Static Public Member Functions

static GTS_INLINE iter_type splitHelper (Range1d &range, EvenSplitter const &)
 
static GTS_INLINE iter_type splitHelper (Range1d &range, ProportionalSplitter const &proportions)
 
static GTS_INLINE uint16_t adjustDivisor (uint16_t initialSplitDepth, bool isStatic)
 
static GTS_INLINE uint16_t splitInitialDepth (uint16_t initialSplitDepth, bool isStatic)
 
static GTS_INLINE uint16_t finalSplitDivisor (uint16_t initialSplitDepth, bool isStatic)
 

Static Public Attributes

static constexpr size_t SPLIT_FACTOR = 2
 
static constexpr size_t MAX_SPLITS = SPLIT_FACTOR - 1
 
static constexpr size_t DIMENSIONALITY = 1
 

Detailed Description

template<typename Iter>
class gts::Range1d< Iter >

An iteration range over a 1D data set. Splits divide the range in two based unless the minimum size is reached. Splits are determined by a splitter object. Successive splits result in a binary tree where each leaf represents a unit of work.

Derivative of TBB blocked_range. https://github.com/intel/tbb

Constructor & Destructor Documentation

◆ Range1d()

template<typename Iter >
GTS_INLINE gts::Range1d< Iter >::Range1d ( iter_type  xBegin,
iter_type  xEnd,
size_type  minSize,
size_type  splitOnMultiplesOf = 1 
)
inline

Constructs a Range1d.

Parameters
xBeginAn iterator to the beginning of the range.
xEndAn iterator to the xEnd of the range.
minSizeThe smallest sub-range the range can be divided into. Must be >= splitOnMultiplesOf.
splitOnMultiplesOfTries to ensure that each sub-range is a multiple of this value. Useful for things like iterating items to be packed into SIMD vectors.

Member Function Documentation

◆ split()

template<typename Iter >
template<typename TSplitter >
GTS_INLINE void gts::Range1d< Iter >::split ( split_result result,
TSplitter const &  splitter 
)
inline

Divides the range based on the splitter.

Parameters
resultThe result of the split.
splitterDefines the split behavior.