Gromacs
2025-dev-20241008-cf8b9ef
|
#include <gromacs/analysisdata/framelocaldata.h>
Container for an array of frame-local values that supports parallel data processing.
ValueType | Type of values to store. |
This class provides a convenient interface to create an array of frame-local data for use in analysis data modules that support parallel processing. The object is initialized by setting the desired dimensionality with setDataSetCount() and setColumnCount(), followed by a call to init(), typically in IAnalysisDataModule::parallelDataStarted(),
After initialization, frameData() can be used to access the data for a given frame, independently from other frames. This works if the assumptions about parallelism hold: if N
is the parallelization factor given for init() with AnalysisDataParallelOptions::parallelizationFactor(), then frame i+N
must not be accessed before all processing for frame i
is finished. Technically, the data for different frames is kept in a ring buffer of size N
.
The data for a frame is not cleared after it is reused for a new frame (but is initially cleared). This allows using the data for accumulating values over all frames in a lock-free manner.
frameDataSet() is provided for convenience when only a single data set needs to be accessed (typically in IAnalysisDataModule::pointsAdded()).
Methods in this class do not throw except where indicated.
Public Types | |
typedef std::vector< ValueType > | ValueArray |
Shorthand for the internal array of values for a frame. | |
typedef AnalysisDataFrameLocalDataHandle < ValueType > | FrameHandle |
Shorthand for a handle to a single frame. | |
typedef AnalysisDataFrameLocalDataSetHandle < ValueType > | DataSetHandle |
Shorthand for a handle to a single data set. | |
Public Member Functions | |
AnalysisDataFrameLocalData () | |
Constructs an empty container with a single data set. | |
bool | isInitialized () const |
Whether init() has been called. | |
int | frameCount () const |
Returns number of independent data frames in this object. More... | |
void | setDataSetCount (int dataSetCount) |
Sets the number of data sets stored for each frame. More... | |
void | setColumnCount (int dataSet, int columnCount) |
Sets the number of columns stored for a data set. More... | |
void | init (const AnalysisDataParallelOptions &opt) |
Initializes the storage to support specified parallelism. More... | |
FrameHandle | frameData (int frameIndex) |
Returns a handle to access data for a frame. | |
DataSetHandle | frameDataSet (int frameIndex, int dataSet) |
Returns a handle to access a single data set within a frame. | |
|
inline |
Returns number of independent data frames in this object.
This supports looping over all the frame arrays to, e.g., sum them up at the end in accumulation scenarios.
|
inline |
Initializes the storage to support specified parallelism.
std::bad_alloc | if out of memory. |
|
inline |
Sets the number of columns stored for a data set.
Must be called for each data set that needs to have values, otherwise there will be zero columns for that data set. Cannot be called after init().
|
inline |
Sets the number of data sets stored for each frame.
std::bad_alloc | if out of memory. |
If not called, there is a single data set in the object. Cannot be called after init().