tatami_stats
Matrix statistics for tatami
|
Local output buffers for running calculations. More...
#include <utils.hpp>
Public Member Functions | |
template<typename Index_ > | |
LocalOutputBuffers (size_t thread, size_t number, Index_ start, Index_ length, GetOutput_ outfun, Output_ fill) | |
template<typename Index_ > | |
LocalOutputBuffers (size_t thread, size_t number, Index_ start, Index_ length, GetOutput_ outfun) | |
LocalOutputBuffers ()=default | |
size_t | size () const |
Output_ * | data (size_t i) |
const Output_ * | data (size_t i) const |
void | transfer () |
Local output buffers for running calculations.
Zero, one or more local output buffers to be created in each thread to avoid false sharing. This class is equivalent to a vector of LocalOutputBuffer
instances, but is easier to initialize and more memory-efficient. In particular, no vector is created at all for the first thread, avoiding an unnecessary allocation in the serial case.
Output_ | Type of the result. |
GetOutput_ | Functor object that returns a pointer to the output buffer. |
|
inline |
Index_ | Type of the start index and length. |
thread | Identity of the thread, starting from zero to the total number of threads. |
number | Number of output buffers. |
start | Index of the first objective vector in the contiguous block for this thread. |
length | Number of objective vectors in the contiguous block for this thread. |
outfun | Function that accepts an Index_ specifying the index of an output buffer in [0, number) and returns a Output_* pointer to that buffer. |
fill | Initial value to fill the buffer. |
|
inline |
Overloaded constructor that sets the default fill = 0
.
Index_ | Type of the start index and length. |
thread | Identity of the thread, starting from zero to the total number of threads. |
number | Number of output buffers. |
start | Index of the first objective vector in the contiguous block for this thread. |
length | Number of objective vectors in the contiguous block for this thread. |
outfun | Function that accepts an Index_ specifying the index of an output buffer in [0, number) and returns a Output_* pointer to that buffer. |
|
default |
Default constructor.
|
inline |
number
in the constructor.
|
inline |
i | Index of the output buffer. |
i
-th output buffer to use in this thread. This contains at least length
addressable elements (see the argument of the same name in the constructor). For thread = 0
, this will be equal to outfun(i) + start
.
|
inline |
i | Index of the output buffer. |
i
-th output buffer to use for this thread. This contains at least length
addressable elements (see the argument of the same name in the constructor). For thread = 0
, this will be equal to outfun(i) + start
.
|
inline |
Transfer results from the local buffer to the global buffer (i.e., outfun(i)
for i
in [0, number)
from the constructor). For thread = 0
, this will be a no-op.