Reference documentation for deal.II version 9.5.0
|
#include <deal.II/lac/vector_operations_internal.h>
Public Member Functions | |
TBBReduceFunctor (const Operation &op, const size_type start, const size_type end) | |
void | operator() (const tbb::blocked_range< size_type > &range) const |
ResultType | do_sum () const |
Public Attributes | |
const Operation & | op |
const size_type | start |
const size_type | end |
unsigned int | n_chunks |
unsigned int | chunk_size |
ResultType | small_array [threshold_array_allocate] |
std::vector< ResultType > | large_array |
ResultType * | array_ptr |
Static Public Attributes | |
static const unsigned int | threshold_array_allocate = 512 |
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 1320 of file vector_operations_internal.h.
|
inline |
Definition at line 1324 of file vector_operations_internal.h.
|
inline |
An operator used by TBB to work on a given range
of chunks [range.begin(), range.end()).
Definition at line 1366 of file vector_operations_internal.h.
|
inline |
Definition at line 1376 of file vector_operations_internal.h.
|
static |
Definition at line 1322 of file vector_operations_internal.h.
const Operation& internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::op |
Definition at line 1389 of file vector_operations_internal.h.
const size_type internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::start |
Definition at line 1390 of file vector_operations_internal.h.
const size_type internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::end |
Definition at line 1391 of file vector_operations_internal.h.
|
mutable |
Definition at line 1393 of file vector_operations_internal.h.
unsigned int internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::chunk_size |
Definition at line 1394 of file vector_operations_internal.h.
ResultType internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::small_array[threshold_array_allocate] |
Definition at line 1395 of file vector_operations_internal.h.
std::vector<ResultType> internal::VectorOperations::TBBReduceFunctor< Operation, ResultType >::large_array |
Definition at line 1396 of file vector_operations_internal.h.
|
mutable |
Definition at line 1399 of file vector_operations_internal.h.