15#ifndef dealii_parallel_h
16#define dealii_parallel_h
31#ifdef DEAL_II_WITH_TBB
32# include <tbb/blocked_range.h>
33# include <tbb/parallel_for.h>
34# include <tbb/parallel_reduce.h>
35# include <tbb/partitioner.h>
37# include <boost/range/iterator_range.hpp>
40#ifdef DEAL_II_HAVE_CXX20
58 template <
typename Number>
64#ifdef __INTEL_COMPILER
72 static const bool value =
false;
77#ifdef DEAL_II_WITH_TBB
81 template <
typename Iterator,
typename Functor>
85 const Functor &functor,
90 tbb::auto_partitioner());
98 template <
typename Iterator,
typename Functor>
102 const Functor &functor,
104 const std::shared_ptr<tbb::affinity_partitioner> &partitioner)
116 template <
typename Iterator,
typename Functor>
120 const Functor &functor,
123 functor(boost::iterator_range<Iterator>(
x_begin,
x_end));
158 template <
typename InputIterator,
typename OutputIterator,
typename Function>
160 (std::invocable<
Function,
decltype(*std::declval<InputIterator>())> &&
161 std::assignable_from<
162 decltype(*std::declval<OutputIterator>()),
164 decltype(*std::declval<InputIterator>())>>))
165 void transform(const InputIterator &begin_in,
171#ifndef DEAL_II_WITH_TBB
176 for (OutputIterator in = begin_in; in !=
end_in;)
179 using Iterators = std::tuple<InputIterator, OutputIterator>;
187 for (
const auto &p : range)
227 template <
typename InputIterator1,
228 typename InputIterator2,
229 typename OutputIterator,
233 decltype(*std::declval<InputIterator1>()),
234 decltype(*std::declval<InputIterator2>())> &&
235 std::assignable_from<
236 decltype(*std::declval<OutputIterator>()),
238 decltype(*std::declval<InputIterator1>()),
239 decltype(*std::declval<InputIterator2>())>>))
240 void transform(const InputIterator1 &begin_in1,
247#ifndef DEAL_II_WITH_TBB
252 for (OutputIterator in1 = begin_in1; in1 !=
end_in1;)
256 std::tuple<InputIterator1, InputIterator2, OutputIterator>;
264 for (
const auto &p : range)
306 template <
typename InputIterator1,
307 typename InputIterator2,
308 typename InputIterator3,
309 typename OutputIterator,
313 decltype(*std::declval<InputIterator1>()),
314 decltype(*std::declval<InputIterator2>()),
315 decltype(*std::declval<InputIterator3>())> &&
316 std::assignable_from<
317 decltype(*std::declval<OutputIterator>()),
319 decltype(*std::declval<InputIterator1>()),
320 decltype(*std::declval<InputIterator2>()),
321 decltype(*std::declval<InputIterator3>())>>))
322 void transform(const InputIterator1 &begin_in1,
330#ifndef DEAL_II_WITH_TBB
335 for (OutputIterator in1 = begin_in1; in1 !=
end_in1;)
338 using Iterators = std::
339 tuple<InputIterator1, InputIterator2, InputIterator3, OutputIterator>;
350 for (
const auto &p : range)
361#ifdef DEAL_II_WITH_TBB
368 template <
typename Iterator,
typename Function>
373 f(range.begin(), range.end());
450 template <
typename Iterator,
typename Function>
457#ifndef DEAL_II_WITH_TBB
467 [&f](
const tbb::blocked_range<Iterator> &range) {
468 internal::apply_to_subranges<Iterator, Function>(range, f);
521 const std::size_t
end,
522 const std::size_t minimum_parallel_grain_size)
const;
602 template <
typename ResultType,
typename Iterator,
typename Function>
604 (std::invocable<Function, Iterator, Iterator> &&
605 std::convertible_to<std::invoke_result_t<Function, Iterator, Iterator>,
608 accumulate_from_subranges(const
Function &f,
613#ifndef DEAL_II_WITH_TBB
620 return tbb::parallel_reduce(
623 [f](
const auto &range,
const ResultType &starting_value) {
624 ResultType value = starting_value;
625 value += f(range.begin(), range.end());
628 std::plus<ResultType>(),
629 tbb::auto_partitioner());
655#ifdef DEAL_II_WITH_TBB
668 std::shared_ptr<tbb::affinity_partitioner>
704 namespace VectorImplementation
724 namespace SparseMatrixImplementation
743 const std::size_t
begin,
744 const std::size_t
end,
745 const std::size_t minimum_parallel_grain_size)
const
747#ifndef DEAL_II_WITH_TBB
750 (void)minimum_parallel_grain_size;
757 [
this](
const tbb::blocked_range<std::size_t> &range) {
760 minimum_parallel_grain_size);
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_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
unsigned int minimum_parallel_grain_size
unsigned int minimum_parallel_grain_size
void parallel_for(Iterator x_begin, Iterator x_end, const Functor &functor, const unsigned int grainsize)
void apply_to_subranges(const tbb::blocked_range< Iterator > &range, const Function &f)
SynchronousIterators< Iterators > SyncIterators
Iterators x_end(end_in, OutputIterator())
const InputIterator OutputIterator out
const Iterator const std_cxx20::type_identity_t< Iterator > & end
const InputIterator1 InputIterator2 in2
void apply_to_subranges(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, const Function &f, const unsigned int grainsize)
const InputIterator1 & end_in1
const InputIterator OutputIterator const Function & function
const InputIterator OutputIterator const Function const unsigned int grainsize
const InputIterator1 InputIterator2 InputIterator3 in3
const InputIterator & end_in
Iterators x_begin(begin_in, out)
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