Parallel.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_PARALLEL_HPP
12 #define CUBBYFLOW_PARALLEL_HPP
13 
14 namespace CubbyFlow
15 {
17 enum class ExecutionPolicy
18 {
19  Serial,
20  Parallel
21 };
22 
38 template <typename RandomIterator, typename T>
39 void ParallelFill(const RandomIterator& begin, const RandomIterator& end,
40  const T& value,
42 
58 template <typename IndexType, typename Function>
59 void ParallelFor(IndexType beginIndex, IndexType endIndex,
60  const Function& function,
62 
80 template <typename IndexType, typename Function>
81 void ParallelRangeFor(IndexType beginIndex, IndexType endIndex,
82  const Function& function,
84 
103 template <typename IndexType, typename Function>
104 void ParallelFor(IndexType beginIndexX, IndexType endIndexX,
105  IndexType beginIndexY, IndexType endIndexY,
106  const Function& function,
108 
128 template <typename IndexType, typename Function>
129 void ParallelRangeFor(IndexType beginIndexX, IndexType endIndexX,
130  IndexType beginIndexY, IndexType endIndexY,
131  const Function& function,
133 
154 template <typename IndexType, typename Function>
155 void ParallelFor(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(IndexType beginIndexX, IndexType endIndexX,
184  IndexType beginIndexY, IndexType endIndexY,
185  IndexType beginIndexZ, IndexType endIndexZ,
186  const Function& function,
188 
206 template <typename IndexType, typename Value, typename Function,
207  typename Reduce>
208 Value ParallelReduce(IndexType beginIndex, IndexType endIndex,
209  const Value& identity, const Function& function,
210  const Reduce& reduce,
212 
224 template <typename RandomIterator>
225 void ParallelSort(RandomIterator begin, RandomIterator end,
227 
243 template <typename RandomIterator, typename CompareFunction>
244 void ParallelSort(RandomIterator begin, RandomIterator end,
245  CompareFunction compare,
247 
249 void SetMaxNumberOfThreads(unsigned int numThreads);
250 
252 unsigned int GetMaxNumberOfThreads();
253 } // namespace CubbyFlow
254 
256 
257 #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.hpp:307
void SetMaxNumberOfThreads(unsigned int numThreads)
Sets maximum number of threads to use.
Definition: pybind11Utils.hpp:20
void ParallelFor(IndexType beginIndex, IndexType endIndex, const Function &function, ExecutionPolicy policy)
Makes a for-loop from beginIndex to endIndex in parallel.
Definition: Parallel-Impl.hpp:212
void ParallelSort(RandomIterator begin, RandomIterator end, ExecutionPolicy policy)
Sorts a container in parallel.
Definition: Parallel-Impl.hpp:523
ExecutionPolicy
Execution policy tag.
Definition: Parallel.hpp:17
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.hpp:191
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.hpp:436