Reference documentation for deal.II version GIT relicensing-437-g81ec864850 2024-04-19 07:30:02+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 Member Functions | Private Attributes | List of all members
WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData > Class Template Reference

#include <deal.II/base/work_stream.h>

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)
 
ItemTypeget_item ()
 

Private Attributes

std::pair< Iterator, Iterator > remaining_iterator_range
 
std::vector< ItemTypeitem_buffer
 
Threads::ThreadLocalStorage< typename ItemType::ScratchDataListthread_local_scratch
 
const ScratchData & sample_scratch_data
 
const unsigned int chunk_size
 

Detailed Description

template<typename Iterator, typename ScratchData, typename CopyData>
class WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >

A class that creates a sequence of items from a range of iterators.

Definition at line 188 of file work_stream.h.

Constructor & Destructor Documentation

◆ IteratorRangeToItemStream()

template<typename Iterator , typename ScratchData , typename CopyData >
WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::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 
)
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 322 of file work_stream.h.

Member Function Documentation

◆ get_item()

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

Create an item and return a pointer to it.

Definition at line 352 of file work_stream.h.

Member Data Documentation

◆ remaining_iterator_range

template<typename Iterator , typename ScratchData , typename CopyData >
std::pair<Iterator, Iterator> WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::remaining_iterator_range
private

The interval of iterators still to be worked on. This range will shrink over time.

Definition at line 407 of file work_stream.h.

◆ item_buffer

template<typename Iterator , typename ScratchData , typename CopyData >
std::vector<ItemType> WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::item_buffer
private

A buffer that will store items.

Definition at line 412 of file work_stream.h.

◆ thread_local_scratch

template<typename Iterator , typename ScratchData , typename CopyData >
Threads::ThreadLocalStorage<typename ItemType::ScratchDataList> WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::thread_local_scratch
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 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 445 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 >::sample_scratch_data
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 452 of file work_stream.h.

◆ chunk_size

template<typename Iterator , typename ScratchData , typename CopyData >
const unsigned int WorkStream::internal::tbb_no_coloring::IteratorRangeToItemStream< Iterator, ScratchData, CopyData >::chunk_size
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 460 of file work_stream.h.


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