libMesh
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. More...
 

Public Member Functions

 BlockedRange (const unsigned int new_grainsize=1000)
 Constructor. More...
 
 BlockedRange (const const_iterator first, const const_iterator last, const unsigned int new_grainsize=1000)
 Constructor. More...
 
 BlockedRange (const BlockedRange< T > &r)
 Copy constructor. More...
 
 BlockedRange (BlockedRange< T > &r, Threads::split)
 Splits the range r. More...
 
void reset (const const_iterator first, const const_iterator last)
 Resets the StoredRange to contain [first,last). More...
 
const_iterator begin () const
 Beginning of the range. More...
 
const_iterator end () const
 End of the range. More...
 
unsigned int grainsize () const
 The grain size for the range. More...
 
void grainsize (const unsigned int &gs)
 Set the grain size. More...
 
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 121 of file threads.h.

Member Typedef Documentation

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

Allows an StoredRange to behave like an STL container.

Definition at line 127 of file threads.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 134 of file threads.h.

134  :
135  _grainsize(new_grainsize)
136  {}
template<typename T>
libMesh::Threads::BlockedRange< T >::BlockedRange ( const const_iterator  first,
const const_iterator  last,
const unsigned int  new_grainsize = 1000 
)

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 144 of file threads.h.

146  :
147  _grainsize(new_grainsize)
148  {
149  this->reset(first, last);
150  }
void reset(const const_iterator first, const const_iterator last)
Resets the StoredRange to contain [first,last).
Definition: threads.h:192
template<typename T>
libMesh::Threads::BlockedRange< T >::BlockedRange ( const BlockedRange< T > &  r)

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 165 of file threads.h.

165  :
166  _end(r._end),
167  _begin(r._begin),
168  _grainsize(r._grainsize)
169  {}
template<typename T>
libMesh::Threads::BlockedRange< T >::BlockedRange ( BlockedRange< T > &  r,
Threads::split   
)

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 176 of file threads.h.

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

176  :
177  _end(r._end),
178  _begin(r._begin),
179  _grainsize(r._grainsize)
180  {
182  beginning = r._begin,
183  ending = r._end,
184  middle = beginning + (ending - beginning)/2u;
185 
186  r._end = _begin = middle;
187  }
T const_iterator
Allows an StoredRange to behave like an STL container.
Definition: threads.h:127

Member Function Documentation

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

Beginning of the range.

Definition at line 202 of file threads.h.

202 { return _begin; }
template<typename T>
bool libMesh::Threads::BlockedRange< T >::empty ( ) const
Returns
true if the range is empty.

Definition at line 232 of file threads.h.

232 { return (_begin == _end); }
template<typename T>
const_iterator libMesh::Threads::BlockedRange< T >::end ( ) const

End of the range.

Definition at line 207 of file threads.h.

207 { return _end; }
template<typename T>
unsigned int libMesh::Threads::BlockedRange< T >::grainsize ( ) const

The grain size for the range.

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

Definition at line 213 of file threads.h.

213 {return _grainsize;}
template<typename T>
void libMesh::Threads::BlockedRange< T >::grainsize ( const unsigned int gs)

Set the grain size.

Definition at line 218 of file threads.h.

218 {_grainsize = gs;}
template<typename T>
bool libMesh::Threads::BlockedRange< T >::is_divisible ( ) const
Returns
true if the range can be subdivided.

Definition at line 237 of file threads.h.

237 { return ((_begin + this->grainsize()) < _end); }
unsigned int grainsize() const
The grain size for the range.
Definition: threads.h:213
template<typename T>
void libMesh::Threads::BlockedRange< T >::reset ( const const_iterator  first,
const const_iterator  last 
)

Resets the StoredRange to contain [first,last).

Definition at line 192 of file threads.h.

194  {
195  _begin = first;
196  _end = last;
197  }
template<typename T>
int libMesh::Threads::BlockedRange< T >::size ( ) const
Returns
The size of the range.

Definition at line 223 of file threads.h.

223 { return (_end -_begin); }

Member Data Documentation

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

Definition at line 242 of file threads.h.

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

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

Definition at line 241 of file threads.h.

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

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

Definition at line 243 of file threads.h.


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