![]() |
Reference documentation for deal.II version 9.6.0
|
#include <deal.II/base/work_stream.h>
Classes | |
struct | ScratchDataObject |
Public Types | |
using | ScratchDataList = std::list<ScratchDataObject> |
Public Member Functions | |
ItemType () | |
Public Attributes | |
std::vector< Iterator > | iterators |
std::vector< CopyData > | copy_datas |
unsigned int | n_iterators |
Threads::ThreadLocalStorage< ScratchDataList > * | scratch_data |
const ScratchData * | sample_scratch_data |
bool | currently_in_use |
A data type that we use to identify items to be worked on. This is the structure that is passed around between the different parts of the WorkStream implementation to identify what needs to be done by the various stages of the pipeline.
Definition at line 197 of file work_stream.h.
using WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::ScratchDataList = std::list<ScratchDataObject> |
Typedef to a list of scratch data objects. The rationale for this list is provided in the variables that use these lists.
Definition at line 236 of file work_stream.h.
|
inline |
Default constructor. Initialize everything that doesn't have a default constructor itself.
Definition at line 308 of file work_stream.h.
std::vector<Iterator> WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::iterators |
A list of iterators that need to be worked on. Only the first n_iterators are relevant.
Definition at line 242 of file work_stream.h.
std::vector<CopyData> WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::copy_datas |
The CopyData objects that the Worker part of the pipeline fills for each work item. Again, only the first n_iterators elements are what we care about.
Definition at line 249 of file work_stream.h.
unsigned int WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::n_iterators |
Number of items identified by the iterators array that the Worker and Copier pipeline stage need to work on. The maximum value of this variable will be chunk_size.
Definition at line 256 of file work_stream.h.
Threads::ThreadLocalStorage<ScratchDataList>* WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::scratch_data |
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 unique_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 289 of file work_stream.h.
const ScratchData* WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::sample_scratch_data |
Pointer to a sample scratch data object, to be used to initialize the scratch data objects created for each individual thread.
Definition at line 295 of file work_stream.h.
bool WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::currently_in_use |
Flag is true if the buffer is used and false if the buffer can be used.
Definition at line 301 of file work_stream.h.