Reference documentation for deal.II version GIT relicensing-214-g6e74dec06b 2024-03-27 18:10:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
WorkStream::internal::tbb_no_coloring::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 > iterators
 
std::vector< CopyData > copy_datas
 
unsigned int n_iterators
 
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::tbb_no_coloring::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 197 of file work_stream.h.

Member Typedef Documentation

◆ ScratchDataList

template<typename Iterator , typename ScratchData , typename CopyData >
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.

Constructor & Destructor Documentation

◆ ItemType()

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

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

Definition at line 308 of file work_stream.h.

Member Data Documentation

◆ iterators

template<typename Iterator , typename ScratchData , typename CopyData >
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.

◆ copy_datas

template<typename Iterator , typename ScratchData , typename CopyData >
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.

◆ n_iterators

template<typename Iterator , typename ScratchData , typename CopyData >
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.

◆ scratch_data

template<typename Iterator , typename ScratchData , typename CopyData >
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.

◆ sample_scratch_data

template<typename Iterator , typename ScratchData , typename CopyData >
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.

◆ currently_in_use

template<typename Iterator , typename ScratchData , typename CopyData >
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.


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