Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::ParallelReduce Class Reference

A construct that maps parallel-reduce behavior to a MicroScheduler. More...

#include <ParallelReduce.h>

Public Member Functions

GTS_INLINE ParallelReduce (MicroScheduler &scheduler, uint32_t priority=0)
 
template<typename TRange , typename TResultValue , typename TMapReduceFunc , typename TJoinFunc , typename TPartitioner = AdaptivePartitioner>
GTS_INLINE TResultValue operator() (TRange const &range, TMapReduceFunc mapReduceFunc, TJoinFunc joinFunc, TResultValue identityValue, TPartitioner partitioner=AdaptivePartitioner(), void *userData=nullptr)
 

Detailed Description

A construct that maps parallel-reduce behavior to a MicroScheduler.

Constructor & Destructor Documentation

◆ ParallelReduce()

GTS_INLINE gts::ParallelReduce::ParallelReduce ( MicroScheduler scheduler,
uint32_t  priority = 0 
)
inline

Creates a ParallelReduce object bound to the specified 'scheduler'. All parallel-reduce operations will be scheduled with the specified 'priority'.

Member Function Documentation

◆ operator()()

template<typename TRange , typename TResultValue , typename TMapReduceFunc , typename TJoinFunc , typename TPartitioner = AdaptivePartitioner>
GTS_INLINE TResultValue gts::ParallelReduce::operator() ( TRange const &  range,
TMapReduceFunc  mapReduceFunc,
TJoinFunc  joinFunc,
TResultValue  identityValue,
TPartitioner  partitioner = AdaptivePartitioner(),
void *  userData = nullptr 
)
inline

Combines all the values in 'range' via 'reduceFunc'.

Parameters
rangeThe divisible range to iterate over.
mapReduceFuncThe function to execute on 'range'. Requires the signature: TResultValue mapReduceFunc(TRange range, void* userData, TaskContext const&). NOTE: This can be more that just a reduction operation. For instance one could fuse map-reduce here.
joinFuncThe function that joins the results of mapReduceFunc to produce the final reduction value. Requires the signature: TResultValue joinFunc(TResultValue const& lhs, TResultValue const& rhs, void* userData, TaskContext const&).
identityValueAn identity value for the join function.
partitionerThe partitioner object that determines when work is subdivided during scheduling.
userDataOptional data to be used in the passed in functions.
Returns
The combined result.