24 #include "gts/micro_scheduler/WorkerPool.h"
25 #include "gts/micro_scheduler/MicroScheduler.h"
26 #include "gts/micro_scheduler/patterns/ParallelReduce.h"
27 #include "gts/micro_scheduler/patterns/Partitioners.h"
28 #include "gts/micro_scheduler/patterns/Range1d.h"
32 namespace gts_examples {
35 void fullParallelReduce()
37 printf (
"================\n");
38 printf (
"fullParallelReduce\n");
39 printf (
"================\n");
46 result = microScheduler.
initialize(&workerPool);
49 size_t const elementCount = 1 << 2;
52 std::vector<uint32_t> vec(elementCount);
53 for (
size_t ii = 0; ii < elementCount; ++ii)
55 vec[ii] = uint32_t(ii);
64 uint32_t reduction = parallelReduce(
67 Range1d<std::vector<uint32_t>::iterator>(vec.begin(), vec.end(), 1),
71 [](
Range1d<std::vector<uint32_t>::iterator>& range,
void*,
TaskContext const&) -> uint32_t
74 for (auto ii = range.begin(); ii != range.end(); ++ii)
82 [](uint32_t
const& lhs, uint32_t
const& rhs,
void*,
TaskContext const&) -> uint32_t
Adaptively subdivides a TRange based on demand from the scheduler.
Definition: AdaptivePartitioner.h:28
A work-stealing task scheduler. The scheduler is executed by the WorkerPool it is initialized with.
Definition: MicroScheduler.h:81
bool initialize(WorkerPool *pWorkerPool)
Initializes the MicroScheduler and attaches it to pWorkPool, where each worker in pWorkPool will exec...
void shutdown()
Stops the MicroScheduler and destroys all resources. The TaskSchuduler is now in an unusable state....
A construct that maps parallel-reduce behavior to a MicroScheduler.
Definition: ParallelReduce.h:48
An iteration range over a 1D data set. Splits divide the range in two based unless the minimum size i...
Definition: Range1d.h:56
A collection of running Worker threads that a MicroScheduler can be run on.
Definition: WorkerPool.h:54
bool initialize(uint32_t threadCount=0)
#define GTS_ASSERT(expr)
Causes execution to break when expr is false.
Definition: Assert.h:144
The context associated with the task being executed.
Definition: MicroSchedulerTypes.h:54