16 #ifndef dealii_parallel_h
17 #define dealii_parallel_h
32 #ifdef DEAL_II_WITH_THREADS
33 # include <tbb/blocked_range.h>
34 # include <tbb/parallel_for.h>
35 # include <tbb/parallel_reduce.h>
36 # include <tbb/partitioner.h>
53 template <
typename Number>
59 #ifdef __INTEL_COMPILER
67 static const bool value =
false;
87 template <
typename Range>
91 for (
typename Range::const_iterator p = range.begin(); p != range.end();
105 template <
typename I1,
typename I2>
107 apply(
const F &
f,
const std::tuple<I1, I2> &p)
109 *std::get<1>(p) =
f(*std::get<0>(p));
115 template <
typename I1,
typename I2,
typename I3>
117 apply(
const F &
f,
const std::tuple<I1, I2, I3> &p)
119 *std::get<2>(p) =
f(*std::get<0>(p), *std::get<1>(p));
125 template <
typename I1,
typename I2,
typename I3,
typename I4>
127 apply(
const F &
f,
const std::tuple<I1, I2, I3, I4> &p)
129 *std::get<3>(p) =
f(*std::get<0>(p), *std::get<1>(p), *std::get<2>(p));
141 template <
typename F>
150 #ifdef DEAL_II_WITH_THREADS
154 template <
typename Iterator,
typename Functor>
158 const Functor & functor,
159 const unsigned int grainsize)
163 tbb::auto_partitioner());
171 template <
typename Iterator,
typename Functor>
175 const Functor & functor,
176 const unsigned int grainsize,
177 const std::shared_ptr<tbb::affinity_partitioner> &partitioner)
209 template <
typename InputIterator,
typename OutputIterator,
typename Predicate>
212 const InputIterator &end_in,
214 const Predicate & predicate,
215 const unsigned int grainsize)
217 #ifndef DEAL_II_WITH_THREADS
222 for (OutputIterator in = begin_in; in != end_in;)
223 *out++ = predicate(*in++);
225 using Iterators = std::tuple<InputIterator, OutputIterator>;
227 Iterators x_begin(begin_in, out);
228 Iterators x_end(end_in, OutputIterator());
230 SyncIterators(x_end),
261 template <
typename InputIterator1,
262 typename InputIterator2,
263 typename OutputIterator,
267 const InputIterator1 &end_in1,
270 const Predicate & predicate,
271 const unsigned int grainsize)
273 #ifndef DEAL_II_WITH_THREADS
278 for (OutputIterator in1 = begin_in1; in1 != end_in1;)
279 *out++ = predicate(*in1++, *in2++);
282 std::tuple<InputIterator1, InputIterator2, OutputIterator>;
284 Iterators x_begin(begin_in1, in2, out);
285 Iterators x_end(end_in1, InputIterator2(), OutputIterator());
287 SyncIterators(x_end),
318 template <
typename InputIterator1,
319 typename InputIterator2,
320 typename InputIterator3,
321 typename OutputIterator,
325 const InputIterator1 &end_in1,
329 const Predicate & predicate,
330 const unsigned int grainsize)
332 #ifndef DEAL_II_WITH_THREADS
337 for (OutputIterator in1 = begin_in1; in1 != end_in1;)
338 *out++ = predicate(*in1++, *in2++, *in3++);
340 using Iterators = std::
341 tuple<InputIterator1, InputIterator2, InputIterator3, OutputIterator>;
343 Iterators x_begin(begin_in1, in2, in3, out);
344 Iterators x_end(end_in1,
349 SyncIterators(x_end),
358 #ifdef DEAL_II_WITH_THREADS
363 template <
typename RangeType,
typename Function>
368 f(range.begin(), range.end());
443 template <
typename RangeType,
typename Function>
448 const unsigned int grainsize)
450 #ifndef DEAL_II_WITH_THREADS
455 # ifndef DEAL_II_BIND_NO_CONST_OP_PARENTHESES
466 [&f](
const tbb::blocked_range<RangeType> &range) {
467 internal::apply_to_subranges<RangeType, Function>(
521 const std::size_t
end,
538 #ifdef DEAL_II_WITH_THREADS
545 template <
typename ResultType,
typename Function>
562 template <
typename Reductor>
595 template <
typename RangeType>
619 const std::function<ResultType(ResultType, ResultType)>
reductor;
685 template <
typename ResultType,
typename RangeType,
typename Function>
688 const RangeType &
begin,
690 const unsigned int grainsize)
692 #ifndef DEAL_II_WITH_THREADS
697 # ifndef DEAL_II_BIND_NO_CONST_OP_PARENTHESES
707 f, std::plus<ResultType>(), 0);
710 tbb::auto_partitioner());
737 #ifdef DEAL_II_WITH_THREADS
750 std::shared_ptr<tbb::affinity_partitioner>
786 namespace VectorImplementation
806 namespace SparseMatrixImplementation
823 #ifdef DEAL_II_WITH_THREADS
838 operator()(
const tbb::blocked_range<std::size_t> &range)
const
852 const std::size_t
begin,
853 const std::size_t
end,
856 #ifndef DEAL_II_WITH_THREADS