deal.II version GIT relicensing-2351-gc320246289 2025-01-11 21:50:00+00:00
|
#include <deal.II/base/work_stream.h>
Public Types | |
using | ScratchDataList = std::list< ScratchDataObject< ScratchData > > |
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 270 of file work_stream.h.
using WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::ScratchDataList = std::list<ScratchDataObject<ScratchData> > |
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 276 of file work_stream.h.
|
inline |
Default constructor. Initialize everything that doesn't have a default constructor itself.
Definition at line 348 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 282 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 289 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 296 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 329 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 335 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 341 of file work_stream.h.