Reference documentation for deal.II version Git d9b14c2d54 2019-09-14 18:13:29 -0600
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Public Member Functions | List of all members
internal::VectorOperations::TBBReduceFunctor< Operation, ResultType > Struct Template Reference

#include <deal.II/lac/vector_operations_internal.h>

Public Member Functions

void operator() (const tbb::blocked_range< size_type > &range) const
 

Detailed Description

template<typename Operation, typename ResultType>
struct internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >

This struct takes the loop range from the tbb parallel for loop and translates it to the actual ranges of the reduction loop inside the vector. It encodes the grain size but might choose larger values of chunks than the minimum grain size. The minimum grain size given to tbb is 1. For affinity reasons, the layout in this loop must be kept in sync with the respective class for plain for loops further up.

Due to this construction, TBB usually only sees a loop of length 4*num_threads with grain size 1. The actual ranges inside the vector are computed outside of TBB because otherwise TBB would split the ranges in some unpredictable position which destroys exact bitwise reproducibility. An important part of this is that inside TBBReduceFunctor::operator() the recursive calls to accumulate are done sequentially on one item a time (even though we could directly run it on the whole range given through the tbb::blocked_range times the chunk size

To sum up: Once the number of threads and the vector size are fixed, we have an exact layout of how the calls into the recursive function will happen. Inside the recursive function, we again only depend on the length. Finally, the concurrent threads write into different positions in a result vector in a thread-safe way and the addition in the short array is again serial.

Definition at line 1286 of file vector_operations_internal.h.

Member Function Documentation

◆ operator()()

template<typename Operation, typename ResultType>
void internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::operator() ( const tbb::blocked_range< size_type > &  range) const
inline

An operator used by TBB to work on a given range of chunks [range.begin(), range.end()).

Definition at line 1332 of file vector_operations_internal.h.


The documentation for this struct was generated from the following file: