dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
dispenso::ChunkedRange< IntegerT > Struct Template Reference

#include <parallel_for.h>

Classes

struct  Auto
 
struct  Static
 

Public Types

using size_type = std::conditional_t< std::is_signed< IntegerT >::value, int64_t, uint64_t >
 

Public Member Functions

 ChunkedRange (IntegerT s, IntegerT e, IntegerT c)
 
 ChunkedRange (IntegerT s, IntegerT e, Static)
 
 ChunkedRange (IntegerT s, IntegerT e, Auto)
 
bool isStatic () const
 
bool isAuto () const
 
bool empty () const
 
size_type size () const
 
template<typename OtherInt >
std::tuple< size_type, size_type > calcChunkSize (OtherInt numLaunched, bool oneOnCaller, size_type minChunkSize) const
 

Public Attributes

IntegerT start
 
IntegerT end
 
IntegerT chunk
 

Static Public Attributes

static constexpr IntegerT kStatic = std::numeric_limits<IntegerT>::max()
 

Detailed Description

template<typename IntegerT = ssize_t>
struct dispenso::ChunkedRange< IntegerT >

A helper class for parallel_for. It provides various configuration parameters to describe how to break up work for parallel processing. ChunkedRanges can be created with Auto chunking, Static chunking, or specific chunking. Auto chunking makes large chunks for better cache utilization, but tries to make enough chunks to provide some dynamic load balancing. Static chunking makes N chunks given N threads to run the loop on. User-specified chunking can be useful for ensuring e.g. that at least a multiple of SIMD width is provided per chunk. parallel_for calls that don't accept a ChunkedRange will create a ChunkedRange internally using Auto chunking.

Definition at line 87 of file parallel_for.h.

Member Typedef Documentation

◆ size_type

template<typename IntegerT = ssize_t>
using dispenso::ChunkedRange< IntegerT >::size_type = std::conditional_t<std::is_signed<IntegerT>::value, int64_t, uint64_t>

Definition at line 94 of file parallel_for.h.

Constructor & Destructor Documentation

◆ ChunkedRange() [1/3]

template<typename IntegerT = ssize_t>
dispenso::ChunkedRange< IntegerT >::ChunkedRange ( IntegerT  s,
IntegerT  e,
IntegerT  c 
)
inline

Create a ChunkedRange with specific chunk size

Parameters
sThe start of the range.
eThe end of the range.
cThe chunk size.

Definition at line 107 of file parallel_for.h.

◆ ChunkedRange() [2/3]

template<typename IntegerT = ssize_t>
dispenso::ChunkedRange< IntegerT >::ChunkedRange ( IntegerT  s,
IntegerT  e,
Static   
)
inline

Create a ChunkedRange with chunk size equal to total items divided by number of threads.

Parameters
sThe start of the range.
eThe end of the range.

Definition at line 114 of file parallel_for.h.

◆ ChunkedRange() [3/3]

template<typename IntegerT = ssize_t>
dispenso::ChunkedRange< IntegerT >::ChunkedRange ( IntegerT  s,
IntegerT  e,
Auto   
)
inline

Create a ChunkedRange with chunk size determined automatically to enable some dynamic load balancing.

Parameters
sThe start of the range.
eThe end of the range.

Definition at line 122 of file parallel_for.h.

Member Function Documentation

◆ calcChunkSize()

template<typename IntegerT = ssize_t>
template<typename OtherInt >
std::tuple< size_type, size_type > dispenso::ChunkedRange< IntegerT >::calcChunkSize ( OtherInt  numLaunched,
bool  oneOnCaller,
size_type  minChunkSize 
) const
inline

Definition at line 142 of file parallel_for.h.

◆ empty()

template<typename IntegerT = ssize_t>
bool dispenso::ChunkedRange< IntegerT >::empty ( ) const
inline

Definition at line 132 of file parallel_for.h.

◆ isAuto()

template<typename IntegerT = ssize_t>
bool dispenso::ChunkedRange< IntegerT >::isAuto ( ) const
inline

Definition at line 128 of file parallel_for.h.

◆ isStatic()

template<typename IntegerT = ssize_t>
bool dispenso::ChunkedRange< IntegerT >::isStatic ( ) const
inline

Definition at line 124 of file parallel_for.h.

◆ size()

template<typename IntegerT = ssize_t>
size_type dispenso::ChunkedRange< IntegerT >::size ( ) const
inline

Definition at line 136 of file parallel_for.h.

Member Data Documentation

◆ chunk

template<typename IntegerT = ssize_t>
IntegerT dispenso::ChunkedRange< IntegerT >::chunk

Definition at line 165 of file parallel_for.h.

◆ end

Definition at line 164 of file parallel_for.h.

◆ kStatic

template<typename IntegerT = ssize_t>
constexpr IntegerT dispenso::ChunkedRange< IntegerT >::kStatic = std::numeric_limits<IntegerT>::max()
staticconstexpr

Definition at line 98 of file parallel_for.h.

◆ start

template<typename IntegerT = ssize_t>
IntegerT dispenso::ChunkedRange< IntegerT >::start

Definition at line 163 of file parallel_for.h.


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