Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify more code in parallel.h via lambda functions. #13153

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 7 additions & 29 deletions include/deal.II/base/parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,33 +808,6 @@ namespace internal

namespace parallel
{
#ifdef DEAL_II_WITH_TBB

namespace internal
{
/**
* This is the function actually called by TBB for the ParallelForInteger
* class.
*/
struct ParallelForWrapper
{
ParallelForWrapper(const parallel::ParallelForInteger &worker)
: worker_(worker)
{}

void
operator()(const tbb::blocked_range<std::size_t> &range) const
{
worker_.apply_to_subrange(range.begin(), range.end());
}

const parallel::ParallelForInteger &worker_;
};
} // namespace internal

#endif


inline void
ParallelForInteger::apply_parallel(
const std::size_t begin,
Expand All @@ -848,8 +821,13 @@ namespace parallel

apply_to_subrange(begin, end);
#else
internal::ParallelForWrapper worker(*this);
internal::parallel_for(begin, end, worker, minimum_parallel_grain_size);
internal::parallel_for(
begin,
end,
[this](const tbb::blocked_range<std::size_t> &range) {
apply_to_subrange(range.begin(), range.end());
},
minimum_parallel_grain_size);
#endif
}

Expand Down