16#ifndef dealii_parallel_h
17#define dealii_parallel_h
32#ifdef DEAL_II_WITH_TBB
34# include <tbb/blocked_range.h>
35# include <tbb/parallel_for.h>
36# include <tbb/parallel_reduce.h>
37# include <tbb/partitioner.h>
55 template <
typename Number>
61#ifdef __INTEL_COMPILER
69 static const bool value =
false;
89 template <
typename Range>
93 for (
typename Range::const_iterator p = range.begin(); p != range.end();
107 template <
typename I1,
typename I2>
109 apply(
const F &
f,
const std::tuple<I1, I2> &p)
111 *std::get<1>(p) =
f(*std::get<0>(p));
117 template <
typename I1,
typename I2,
typename I3>
119 apply(
const F &
f,
const std::tuple<I1, I2, I3> &p)
121 *std::get<2>(p) =
f(*std::get<0>(p), *std::get<1>(p));
127 template <
typename I1,
typename I2,
typename I3,
typename I4>
129 apply(
const F &
f,
const std::tuple<I1, I2, I3, I4> &p)
131 *std::get<3>(p) =
f(*std::get<0>(p), *std::get<1>(p), *std::get<2>(p));
143 template <
typename F>
152#ifdef DEAL_II_WITH_TBB
156 template <
typename Iterator,
typename Functor>
160 const Functor & functor,
161 const unsigned int grainsize)
165 tbb::auto_partitioner());
173 template <
typename Iterator,
typename Functor>
177 const Functor & functor,
178 const unsigned int grainsize,
179 const std::shared_ptr<tbb::affinity_partitioner> &partitioner)
211 template <
typename InputIterator,
typename OutputIterator,
typename Predicate>
214 const InputIterator &end_in,
216 const Predicate & predicate,
217 const unsigned int grainsize)
219#ifndef DEAL_II_WITH_TBB
224 for (OutputIterator in = begin_in; in != end_in;)
225 *out++ = predicate(*in++);
227 using Iterators = std::tuple<InputIterator, OutputIterator>;
229 Iterators x_begin(begin_in, out);
230 Iterators x_end(end_in, OutputIterator());
232 SyncIterators(x_end),
263 template <
typename InputIterator1,
264 typename InputIterator2,
265 typename OutputIterator,
269 const InputIterator1 &end_in1,
272 const Predicate & predicate,
273 const unsigned int grainsize)
275#ifndef DEAL_II_WITH_TBB
280 for (OutputIterator in1 = begin_in1; in1 != end_in1;)
281 *out++ = predicate(*in1++, *in2++);
284 std::tuple<InputIterator1, InputIterator2, OutputIterator>;
286 Iterators x_begin(begin_in1, in2, out);
287 Iterators x_end(end_in1, InputIterator2(), OutputIterator());
289 SyncIterators(x_end),
320 template <
typename InputIterator1,
321 typename InputIterator2,
322 typename InputIterator3,
323 typename OutputIterator,
327 const InputIterator1 &end_in1,
331 const Predicate & predicate,
332 const unsigned int grainsize)
334#ifndef DEAL_II_WITH_TBB
339 for (OutputIterator in1 = begin_in1; in1 != end_in1;)
340 *out++ = predicate(*in1++, *in2++, *in3++);
342 using Iterators = std::
343 tuple<InputIterator1, InputIterator2, InputIterator3, OutputIterator>;
345 Iterators x_begin(begin_in1, in2, in3, out);
346 Iterators x_end(end_in1,
351 SyncIterators(x_end),
360#ifdef DEAL_II_WITH_TBB
365 template <
typename RangeType,
typename Function>
370 f(range.begin(), range.end());
445 template <
typename RangeType,
typename Function>
450 const unsigned int grainsize)
452#ifndef DEAL_II_WITH_TBB
461 [&f](
const tbb::blocked_range<RangeType> &range) {
462 internal::apply_to_subranges<RangeType, Function>(
516 const std::size_t
end,
533#ifdef DEAL_II_WITH_TBB
540 template <
typename ResultType,
typename Function>
557 template <
typename Reductor>
590 template <
typename RangeType>
614 const std::function<ResultType(ResultType, ResultType)>
reductor;
680 template <
typename ResultType,
typename RangeType,
typename Function>
683 const RangeType &
begin,
685 const unsigned int grainsize)
687#ifndef DEAL_II_WITH_TBB
695 f, std::plus<ResultType>(), 0);
698 tbb::auto_partitioner());
725#ifdef DEAL_II_WITH_TBB
738 std::shared_ptr<tbb::affinity_partitioner>
774 namespace VectorImplementation
794 namespace SparseMatrixImplementation
811#ifdef DEAL_II_WITH_TBB
826 operator()(
const tbb::blocked_range<std::size_t> &range)
const
840 const std::size_t
begin,
841 const std::size_t
end,
844#ifndef DEAL_II_WITH_TBB
std::shared_ptr< tbb::affinity_partitioner > acquire_one_partitioner()
std::shared_ptr< tbb::affinity_partitioner > my_partitioner
void release_one_partitioner(std::shared_ptr< tbb::affinity_partitioner > &p)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
std::vector< value_type > split(const typename ::Triangulation< dim, spacedim >::cell_iterator &parent, const value_type parent_value)
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
unsigned int minimum_parallel_grain_size
unsigned int minimum_parallel_grain_size
void parallel_reduce(const Operation &op, const size_type start, const size_type end, ResultType &result, const std::shared_ptr<::parallel::internal::TBBPartitioner > &partitioner)
void parallel_for(Iterator x_begin, Iterator x_end, const Functor &functor, const unsigned int grainsize)
void parallel_for(Iterator x_begin, Iterator x_end, const Functor &functor, const unsigned int grainsize, const std::shared_ptr< tbb::affinity_partitioner > &partitioner)
void apply_to_subranges(const tbb::blocked_range< RangeType > &range, const Function &f)
Body< F > make_body(const F &f)
ResultType accumulate_from_subranges(const Function &f, const RangeType &begin, const typename identity< RangeType >::type &end, const unsigned int grainsize)
void apply_to_subranges(const RangeType &begin, const typename identity< RangeType >::type &end, const Function &f, const unsigned int grainsize)
void transform(const InputIterator &begin_in, const InputIterator &end_in, OutputIterator out, const Predicate &predicate, const unsigned int grainsize)
virtual ~ParallelForInteger()=default
virtual void apply_to_subrange(const std::size_t, const std::size_t) const =0
void apply_parallel(const std::size_t begin, const std::size_t end, const std::size_t minimum_parallel_grain_size) const
static void apply(const F &f, const std::tuple< I1, I2, I3 > &p)
static void apply(const F &f, const std::tuple< I1, I2 > &p)
void operator()(const Range &range) const
static void apply(const F &f, const std::tuple< I1, I2, I3, I4 > &p)
const parallel::ParallelForInteger & worker_
void operator()(const tbb::blocked_range< std::size_t > &range) const
ParallelForWrapper(const parallel::ParallelForInteger &worker)
ReductionOnSubranges(const ReductionOnSubranges &r, tbb::split)
void operator()(const tbb::blocked_range< RangeType > &range)
const ResultType neutral_element
const std::function< ResultType(ResultType, ResultType)> reductor
void join(const ReductionOnSubranges &r)
ReductionOnSubranges(const Function &f, const Reductor &reductor, const ResultType neutral_element=ResultType())