Parallel.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: Parallel.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Parallel functions for CubbyFlow.
6 > Created Time: 2017/02/05
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PARALLEL_H
10 #define CUBBYFLOW_PARALLEL_H
11 
12 namespace CubbyFlow
13 {
15  enum class ExecutionPolicy { Serial, Parallel };
16 
32  template <typename RandomIterator, typename T>
33  void ParallelFill(
34  const RandomIterator& begin, const RandomIterator& end,
35  const T& value,
37 
53  template <typename IndexType, typename Function>
54  void ParallelFor(
55  IndexType beginIndex, IndexType endIndex,
56  const Function& function,
58 
76  template <typename IndexType, typename Function>
77  void ParallelRangeFor(
78  IndexType beginIndex, IndexType endIndex,
79  const Function& function,
81 
100  template <typename IndexType, typename Function>
101  void ParallelFor(
102  IndexType beginIndexX, IndexType endIndexX,
103  IndexType beginIndexY, IndexType endIndexY,
104  const Function& function,
106 
126  template <typename IndexType, typename Function>
127  void ParallelRangeFor(
128  IndexType beginIndexX, IndexType endIndexX,
129  IndexType beginIndexY, IndexType endIndexY,
130  const Function& function,
132 
153  template <typename IndexType, typename Function>
154  void ParallelFor(
155  IndexType beginIndexX, IndexType endIndexX,
156  IndexType beginIndexY, IndexType endIndexY,
157  IndexType beginIndexZ, IndexType endIndexZ,
158  const Function& function,
160 
182  template <typename IndexType, typename Function>
183  void ParallelRangeFor(
184  IndexType beginIndexX, IndexType endIndexX,
185  IndexType beginIndexY, IndexType endIndexY,
186  IndexType beginIndexZ, IndexType endIndexZ,
187  const Function& function,
189 
207  template <typename IndexType, typename Value, typename Function, typename Reduce>
208  Value ParallelReduce(
209  IndexType beginIndex, IndexType endIndex,
210  const Value& identity, const Function& function,
211  const Reduce& reduce,
213 
225  template<typename RandomIterator>
226  void ParallelSort(
227  RandomIterator begin, RandomIterator end,
229 
245  template<typename RandomIterator, typename CompareFunction>
246  void ParallelSort(
247  RandomIterator begin, RandomIterator end,
248  CompareFunction compare,
250 
252  void SetMaxNumberOfThreads(unsigned int numThreads);
253 
255  unsigned int GetMaxNumberOfThreads();
256 }
257 
259 
260 #endif
unsigned int GetMaxNumberOfThreads()
Returns maximum number of threads to use.
void ParallelRangeFor(IndexType beginIndex, IndexType endIndex, const Function &function, ExecutionPolicy policy)
Makes a range-loop from beginIndex to endIndex in parallel.
Definition: Parallel-Impl.h:283
void SetMaxNumberOfThreads(unsigned int numThreads)
Sets maximum number of threads to use.
Definition: pybind11Utils.h:24
void ParallelFor(IndexType beginIndex, IndexType endIndex, const Function &function, ExecutionPolicy policy)
Makes a for-loop from beginIndex to endIndex in parallel.
Definition: Parallel-Impl.h:201
void ParallelSort(RandomIterator begin, RandomIterator end, ExecutionPolicy policy)
Sorts a container in parallel.
Definition: Parallel-Impl.h:492
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
void ParallelFill(const RandomIterator &begin, const RandomIterator &end, const T &value, ExecutionPolicy policy)
Fills from begin to end with value in parallel.
Definition: Parallel-Impl.h:182
Value ParallelReduce(IndexType beginIndex, IndexType endIndex, const Value &identity, const Function &function, const Reduce &reduce, ExecutionPolicy policy)
Performs reduce operation in parallel.
Definition: Parallel-Impl.h:407