BufferManager provides single-buffered or asynchronous double-buffered read access to the data in a collection of DistrArray objects. At construction, an amount of memory is allocated as a buffer, and the buffer is divided into one or more chunks that are independent windows on the data. Sequential access to the data is provided through iterators. More...
#include <BufferManager.h>
BufferManager provides single-buffered or asynchronous double-buffered read access to the data in a collection of DistrArray objects. At construction, an amount of memory is allocated as a buffer, and the buffer is divided into one or more chunks that are independent windows on the data. Sequential access to the data is provided through iterators.
| T | a class that inherits from DistrArray |
Classes | |
| struct | Iterator |
| Custom iterator for the BufferManager. This iterator is responsible for loading data into the buffers and providing access to that data. More... | |
Public Member Functions | |
| BufferManager (const CVecRef &arrays, size_t buffer_size=8192, int number_of_buffers=2) | |
| Construct a new Buffer Manager object and allocate memory for the chunks. More... | |
| BufferManager (const std::vector< T > &arrays, size_t buffer_size=8192, int number_of_buffers=2) | |
| BufferManager (const T &array, size_t buffer_size=8192, int number_of_buffers=2) | |
| size_t | buffer_size () const |
| size_t | buffer_stride () const |
| size_t | buffer_offset () const |
| Iterator | begin () |
| Iterator | end () |
Protected Types | |
| using | value_type = typename T::value_type |
Protected Member Functions | |
| Span< value_type > | next (bool initial=false) |
| Move to the next segment of the arrays and complete loading of the buffer. More... | |
Protected Attributes | |
| const CVecRef & | m_arrays |
| const size_t | m_buffer_size = 8192 |
| const int | m_number_of_buffers = 2 |
| size_t | m_current_buffer_size |
| size_t | m_current_segment = 0 |
| const std::pair< size_t, size_t > | m_range |
| std::vector< typename T::value_type > | m_buffer |
| std::future< void > | m_read_future |
|
protected |
|
inline |
Construct a new Buffer Manager object and allocate memory for the chunks.
| arrays | the DistrArray objects that this BufferManager will access data from. They must have the same distribution. |
| buffer_size | number of array elements in each chunk. |
| number_of_buffers | how many buffers. |
|
inline |
|
inline |
|
inline |
|
inline |
Offset of the current buffer
|
inline |
The current buffer size
|
inline |
The distance between buffers
|
inline |
|
inlineprotected |
Move to the next segment of the arrays and complete loading of the buffer.
| initial | whether this is the first iteration |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |