HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
loops.h File Reference
#include "pxr/pxr.h"
#include "pxr/base/work/api.h"
#include "pxr/base/work/dispatcher.h"
#include "pxr/base/work/impl.h"
#include "pxr/base/work/threadLimits.h"
#include "pxr/base/tf/errorTransport.h"
#include "pxr/base/tf/mallocTag.h"
#include <algorithm>
+ Include dependency graph for loops.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Work_LoopsTaskWrapper< Fn >
 
class  Work_MallocTagsLoopsTaskWrapper< Fn >
 
class  Work_LoopsForEachTaskWrapper< Fn >
 
class  Work_MallocTagsLoopsForEachTaskWrapper< Fn >
 

Typedefs

using Work_ErrorTransports = tbb::concurrent_vector< TfErrorTransport >
 

Functions

template<typename Fn >
void WorkSerialForN (size_t n, Fn &&fn)
 
template<typename Fn >
void WorkParallelForN (size_t n, Fn &&callback, size_t grainSize)
 
template<typename Fn >
void WorkParallelForN (size_t n, Fn &&callback)
 
template<typename RangeType , typename Fn >
void WorkParallelForTBBRange (const RangeType &range, Fn &&callback)
 
template<typename InputIterator , typename Fn >
void WorkParallelForEach (InputIterator first, InputIterator last, Fn &&fn)
 

Typedef Documentation

using Work_ErrorTransports = tbb::concurrent_vector<TfErrorTransport>

Definition at line 24 of file loops.h.

Function Documentation

template<typename InputIterator , typename Fn >
void WorkParallelForEach ( InputIterator  first,
InputIterator  last,
Fn &&  fn 
)
inline

WorkParallelForEach(Iterator first, Iterator last, CallbackType callback)

Callback must be of the form:

void LoopCallback(T elem);

where the type T is deduced from the type of the InputIterator template argument.

Definition at line 315 of file loops.h.

template<typename Fn >
void WorkParallelForN ( size_t  n,
Fn &&  callback,
size_t  grainSize 
)

WorkParallelForN(size_t n, CallbackType callback, size_t grainSize = 1)

Runs callback in parallel over the range 0 to n.

Callback must be of the form:

void LoopCallback(size_t begin, size_t end);

grainSize specifies a minimum amount of work to be done per-thread. There is overhead to launching a thread (or task) and a typical guideline is that you want to have at least 10,000 instructions to count for the overhead of launching a thread.

Definition at line 168 of file loops.h.

template<typename Fn >
void WorkParallelForN ( size_t  n,
Fn &&  callback 
)

WorkParallelForN(size_t n, CallbackType callback, size_t grainSize = 1)

Runs callback in parallel over the range 0 to n.

Callback must be of the form:

void LoopCallback(size_t begin, size_t end);

Definition at line 210 of file loops.h.

template<typename RangeType , typename Fn >
void WorkParallelForTBBRange ( const RangeType &  range,
Fn &&  callback 
)

WorkParallelForTBBRange(const RangeType &r, Fn &&callback)

Runs callback in parallel over a RangeType that adheres to TBB's splittable range requirements: https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/named_requirements/algorithms/range

Callback must be of the form:

void LoopCallback(RangeType range);

Definition at line 230 of file loops.h.

template<typename Fn >
void WorkSerialForN ( size_t  n,
Fn &&  fn 
)

WorkSerialForN(size_t n, CallbackType callback)

A serial version of WorkParallelForN as a drop in replacement to selectively turn off multithreading for a single parallel loop for easier debugging.

Callback must be of the form:

void LoopCallback(size_t begin, size_t end);

Definition at line 146 of file loops.h.