Reference documentation for deal.II version 9.0.0
|
#include <deal.II/base/work_stream.h>
Inherits filter.
Classes | |
struct | ItemType |
Public Member Functions | |
IteratorRangeToItemStream (const Iterator &begin, const Iterator &end, const unsigned int buffer_size, const unsigned int chunk_size, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data) | |
virtual void * | operator() (void *) |
Private Attributes | |
std::pair< Iterator, Iterator > | remaining_iterator_range |
std::vector< ItemType > | item_buffer |
Threads::ThreadLocalStorage< typename ItemType::ScratchDataList > | thread_local_scratch |
const ScratchData & | sample_scratch_data |
const unsigned int | chunk_size |
A class that creates a sequence of items from a range of iterators.
Definition at line 178 of file work_stream.h.
|
inline |
Constructor. Take an iterator range, the size of a buffer that can hold items, and the sample additional data object that will be passed to each worker and copier function invocation.
Definition at line 321 of file work_stream.h.
|
inlinevirtual |
Create an item and return a pointer to it.
Definition at line 354 of file work_stream.h.
|
private |
The interval of iterators still to be worked on. This range will shrink over time.
Definition at line 409 of file work_stream.h.
|
private |
A buffer that will store items.
Definition at line 414 of file work_stream.h.
|
private |
Pointer to a thread local variable identifying the scratch data objects this thread will use. The initial implementation of this class using thread local variables provided only a single scratch object per thread. This doesn't work, because the worker functions may start tasks itself and then call Threads::TaskGroup::join_all() or a similar function, which the TBB scheduler may use to run something else on the current thread – for example another instance of the worker function. Consequently, there would be two instances of the worker function that use the same scratch object if we only provided a single scratch object per thread. The solution is to provide a list of scratch objects for each thread, together with a flag indicating whether this scratch object is currently used. If a thread needs a scratch object, it walks this list until it finds an unused object, or, if there is none, creates one itself. Note that we need not use synchronization primitives for this process since the lists are thread-local and we are guaranteed that only a single thread accesses them as long as we have no yield point in between the accesses to the list.
The pointers to scratch objects stored in each of these lists must be so that they are deleted on all threads when the thread local object is destroyed. This is achieved by using shared_ptr.
Note that when a worker needs to create a scratch object, it allocates it using sample_scratch_data to copy from. This has the advantage of a first-touch initialization, i.e., the memory for the scratch data object is allocated and initialized by the same thread that will later use it.
Definition at line 446 of file work_stream.h.
|
private |
A reference to a sample scratch data that will be used to initialize the thread-local pointers to a scratch data object each of the worker tasks uses.
Definition at line 453 of file work_stream.h.
|
private |
Number of elements of the iterator range that each thread should work on sequentially; a large number makes sure that each thread gets a significant amount of work before the next task switch happens, whereas a small number is better for load balancing.
Definition at line 461 of file work_stream.h.