Reference documentation for deal.II version Git 35565f205e 2019-09-24 08:33:37 +0200
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
WorkStream::internal::Implementation2::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType Struct Reference

#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 > work_items
 
std::vector< CopyData > copy_datas
 
unsigned int n_items
 
Threads::ThreadLocalStorage< ScratchDataList > * scratch_data
 
const ScratchData * sample_scratch_data
 
bool currently_in_use
 

Detailed Description

template<typename Iterator, typename ScratchData, typename CopyData>
struct WorkStream::internal::Implementation2::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType

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 187 of file work_stream.h.

Member Typedef Documentation

◆ ScratchDataList

template<typename Iterator, typename ScratchData, typename CopyData>
using WorkStream::internal::Implementation2::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 232 of file work_stream.h.

Constructor & Destructor Documentation

◆ ItemType()

template<typename Iterator, typename ScratchData, typename CopyData>
WorkStream::internal::Implementation2::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::ItemType ( )
inline

Default constructor. Initialize everything that doesn't have a default constructor itself.

Definition at line 304 of file work_stream.h.

Member Data Documentation

◆ work_items

template<typename Iterator, typename ScratchData, typename CopyData>
std::vector<Iterator> WorkStream::internal::Implementation2::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::work_items

A list of iterators that need to be worked on. Only the first n_items are relevant.

Definition at line 238 of file work_stream.h.

◆ copy_datas

template<typename Iterator, typename ScratchData, typename CopyData>
std::vector<CopyData> WorkStream::internal::Implementation2::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_items elements are what we care about.

Definition at line 245 of file work_stream.h.

◆ n_items

template<typename Iterator, typename ScratchData, typename CopyData>
unsigned int WorkStream::internal::Implementation2::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::ItemType::n_items

Number of items identified by the work_items 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 252 of file work_stream.h.

◆ scratch_data

template<typename Iterator, typename ScratchData, typename CopyData>
Threads::ThreadLocalStorage<ScratchDataList>* WorkStream::internal::Implementation2::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 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 285 of file work_stream.h.

◆ sample_scratch_data

template<typename Iterator, typename ScratchData, typename CopyData>
const ScratchData* WorkStream::internal::Implementation2::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 291 of file work_stream.h.

◆ currently_in_use

template<typename Iterator, typename ScratchData, typename CopyData>
bool WorkStream::internal::Implementation2::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 297 of file work_stream.h.


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