libMesh
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
libMesh::Threads::BlockedRange< T > Class Template Reference

Blocked range which can be subdivided and executed in parallel. More...

#include <threads.h>

Public Types

typedef T const_iterator
 Allows an StoredRange to behave like an STL container.
 

Public Member Functions

 BlockedRange (const unsigned int new_grainsize=libMesh::default_grainsize())
 Constructor.
 
 BlockedRange (const const_iterator first, const const_iterator last, const unsigned int new_grainsize=libMesh::default_grainsize())
 Constructor.
 
 BlockedRange (const BlockedRange< T > &r)
 Copy constructor.
 
 BlockedRange (BlockedRange< T > &r, Threads::split)
 Splits the range r.
 
void reset (const const_iterator first, const const_iterator last)
 Resets the StoredRange to contain [first,last).
 
const_iterator begin () const
 Beginning of the range.
 
const_iterator end () const
 End of the range.
 
unsigned int grainsize () const
 The grain size for the range.
 
void grainsize (const unsigned int &gs)
 Set the grain size.
 
int size () const
 
bool empty () const
 
bool is_divisible () const
 

Private Attributes

const_iterator _end
 
const_iterator _begin
 
unsigned int _grainsize
 

Detailed Description

template<typename T>
class libMesh::Threads::BlockedRange< T >

Blocked range which can be subdivided and executed in parallel.

Definition at line 165 of file threads.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef T libMesh::Threads::BlockedRange< T >::const_iterator

Allows an StoredRange to behave like an STL container.

Definition at line 171 of file threads.h.

Constructor & Destructor Documentation

◆ BlockedRange() [1/4]

template<typename T >
libMesh::Threads::BlockedRange< T >::BlockedRange ( const unsigned int  new_grainsize = libMesh::default_grainsize())
inlineexplicit

Constructor.

Optionally takes the grainsize parameter, which is the smallest chunk the range may be broken into for parallel execution.

Definition at line 178 of file threads.h.

178 :
179 _grainsize(new_grainsize)
180 {}

◆ BlockedRange() [2/4]

template<typename T >
libMesh::Threads::BlockedRange< T >::BlockedRange ( const const_iterator  first,
const const_iterator  last,
const unsigned int  new_grainsize = libMesh::default_grainsize() 
)
inline

Constructor.

Takes the beginning and end of the range. Optionally takes the grainsize parameter, which is the smallest chunk the range may be broken into for parallel execution.

Definition at line 188 of file threads.h.

190 :
191 _grainsize(new_grainsize)
192 {
193 this->reset(first, last);
194 }
void reset(const const_iterator first, const const_iterator last)
Resets the StoredRange to contain [first,last).
Definition threads.h:236

References libMesh::Threads::BlockedRange< T >::reset().

◆ BlockedRange() [3/4]

template<typename T >
libMesh::Threads::BlockedRange< T >::BlockedRange ( const BlockedRange< T > &  r)
inline

Copy constructor.

The StoredRange can be copied into subranges for parallel execution. In this way the initial StoredRange can be thought of as the root of a binary tree. The root element is the only element which interacts with the user. It takes a specified range of objects and packs it into a contiguous vector which can be split efficiently. However, there is no need for the child ranges to contain this vector, so long as the parent outlives the children. So we implement the copy constructor to specifically omit the _objs vector.

Definition at line 209 of file threads.h.

209 :
210 _end(r._end),
211 _begin(r._begin),
212 _grainsize(r._grainsize)
213 {}

◆ BlockedRange() [4/4]

template<typename T >
libMesh::Threads::BlockedRange< T >::BlockedRange ( BlockedRange< T > &  r,
Threads::split   
)
inline

Splits the range r.

The first half of the range is left in place, the second half of the range is placed in *this.

Definition at line 220 of file threads.h.

220 :
221 _end(r._end),
222 _begin(r._begin),
223 _grainsize(r._grainsize)
224 {
226 beginning = r._begin,
227 ending = r._end,
228 middle = beginning + (ending - beginning)/2u;
229
230 r._end = _begin = middle;
231 }
T const_iterator
Allows an StoredRange to behave like an STL container.
Definition threads.h:171

References libMesh::Threads::BlockedRange< T >::_begin, and libMesh::Threads::BlockedRange< T >::_end.

Member Function Documentation

◆ begin()

template<typename T >
const_iterator libMesh::Threads::BlockedRange< T >::begin ( ) const
inline

Beginning of the range.

Definition at line 246 of file threads.h.

246{ return _begin; }

References libMesh::Threads::BlockedRange< T >::_begin.

◆ empty()

template<typename T >
bool libMesh::Threads::BlockedRange< T >::empty ( ) const
inline
Returns
true if the range is empty.

Definition at line 276 of file threads.h.

276{ return (_begin == _end); }

References libMesh::Threads::BlockedRange< T >::_begin, and libMesh::Threads::BlockedRange< T >::_end.

◆ end()

template<typename T >
const_iterator libMesh::Threads::BlockedRange< T >::end ( ) const
inline

End of the range.

Definition at line 251 of file threads.h.

251{ return _end; }

References libMesh::Threads::BlockedRange< T >::_end.

◆ grainsize() [1/2]

template<typename T >
unsigned int libMesh::Threads::BlockedRange< T >::grainsize ( ) const
inline

The grain size for the range.

The range will be subdivided into subranges not to exceed the grain size.

Definition at line 257 of file threads.h.

257{return _grainsize;}

References libMesh::Threads::BlockedRange< T >::_grainsize.

Referenced by libMesh::Threads::BlockedRange< T >::is_divisible().

◆ grainsize() [2/2]

template<typename T >
void libMesh::Threads::BlockedRange< T >::grainsize ( const unsigned int gs)
inline

Set the grain size.

Definition at line 262 of file threads.h.

262{_grainsize = gs;}

References libMesh::Threads::BlockedRange< T >::_grainsize.

◆ is_divisible()

template<typename T >
bool libMesh::Threads::BlockedRange< T >::is_divisible ( ) const
inline
Returns
true if the range can be subdivided.

Definition at line 281 of file threads.h.

281{ return ((_begin + this->grainsize()) < _end); }
unsigned int grainsize() const
The grain size for the range.
Definition threads.h:257

References libMesh::Threads::BlockedRange< T >::_begin, libMesh::Threads::BlockedRange< T >::_end, and libMesh::Threads::BlockedRange< T >::grainsize().

◆ reset()

template<typename T >
void libMesh::Threads::BlockedRange< T >::reset ( const const_iterator  first,
const const_iterator  last 
)
inline

Resets the StoredRange to contain [first,last).

Definition at line 236 of file threads.h.

238 {
239 _begin = first;
240 _end = last;
241 }

References libMesh::Threads::BlockedRange< T >::_begin, and libMesh::Threads::BlockedRange< T >::_end.

Referenced by libMesh::Threads::BlockedRange< T >::BlockedRange().

◆ size()

template<typename T >
int libMesh::Threads::BlockedRange< T >::size ( ) const
inline
Returns
The size of the range.

Definition at line 267 of file threads.h.

267{ return (_end -_begin); }

References libMesh::Threads::BlockedRange< T >::_begin, and libMesh::Threads::BlockedRange< T >::_end.

Member Data Documentation

◆ _begin

template<typename T >
const_iterator libMesh::Threads::BlockedRange< T >::_begin
private

◆ _end

template<typename T >
const_iterator libMesh::Threads::BlockedRange< T >::_end
private

◆ _grainsize

template<typename T >
unsigned int libMesh::Threads::BlockedRange< T >::_grainsize
private

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