The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::statistics::SIValuesBuffer Class Reference

This class helps organize contiguous blocks of SI values. These values are buffered at each report update, and they are organized in the buffer so that individual SI's have their values right next to each other. To illustrate, say we had the following CSV file: More...

#include <SIValuesBuffer.hpp>

Public Member Functions

 SIValuesBuffer (const std::vector< const StatisticInstance * > &stats, const Clock &root_clk)
 
void useRowMajorOrdering ()
 
void useColumnMajorOrdering ()
 
db::MajorOrdering getMajorOrdering () const
 
void initializeNumSIBuffers (const size_t num_si_buffers)
 
void updateNumSIBuffers (const size_t num_si_buffers)
 
bool buffersAreFilled () const
 
bool buffersAreEmpty () const
 Ask if this buffer is completely empty.
 
size_t getNumBufferedSIBlocks () const
 
void resetSIBuffers (const bool fill_with_nans=true)
 
void bufferCurrentSIValues ()
 
const std::vector< double > & getBufferedSIValues ()
 
void getBeginningAndEndingTimestampsForBufferedSIs (uint64_t &starting_picoseconds, uint64_t &ending_picoseconds, uint64_t &starting_cycles, uint64_t &ending_cycles) const
 

Detailed Description

This class helps organize contiguous blocks of SI values. These values are buffered at each report update, and they are organized in the buffer so that individual SI's have their values right next to each other. To illustrate, say we had the following CSV file:

si_foo si_bar si_biz si_baz 1.2 450 1000 12 1.4 453 1001 12 1.4 460 1005 14

An SIValuesBuffer could be used so that these 12 values appear in this order in a single vector:

[1.2, 1.4, 1.4, 450, 453, 460, 1000, 1001, 1005, 12, 12, 14]

This is useful when SI values are compressed since data streams with lower entropy tend to compress better than those with higher entropy (depends on compression scheme used). Adjacent SI's will usually display smaller changes from one update to the next, which is why this class buffers them together in column-major format. The equivalent buffer in row-major format would be much more random and would likely show more modest benefits from compression:

[1.2, 450, 1000, 12, 1.4, 453, 1001, 12, 1.4, 460, 1005, 14]

Definition at line 47 of file SIValuesBuffer.hpp.

Constructor & Destructor Documentation

◆ SIValuesBuffer()

sparta::statistics::SIValuesBuffer::SIValuesBuffer ( const std::vector< const StatisticInstance * > &  stats,
const Clock root_clk 
)
inline

Construct an empty buffer for a given set of SI's, and the scheduler & root clock the simulation is tied to.

Definition at line 52 of file SIValuesBuffer.hpp.

Member Function Documentation

◆ bufferCurrentSIValues()

void sparta::statistics::SIValuesBuffer::bufferCurrentSIValues ( )
inline

Loop over this container's SI's and put their current values into the buffer. Each SI value will go just to the right of its previous value. For example:

Say the container has 4 SI's, can hold a maximum of three report update's worth of SI data, and currently 2 of those 3 report updates have already hit.

[1.2, 1.4, —, 450, 453, —, 1000, 1001, —, 12, 12, —]


| | | | | | | | --------------------------------------------— | | | | | | | | | Update #1 |

| | | |

| Update #2

Then we call 'bufferCurrentSIValues()', and our SI's have values 1.4, 460, 1005, and 14 at this moment.

We would then have the following SI values at the end of the third report update:

[1.2, 1.4, 1.4, 450, 453, 460, 1000, 1001, 1005, 12, 12, 14]


| | | |

| Update #3

Definition at line 215 of file SIValuesBuffer.hpp.

Here is the call graph for this function:

◆ buffersAreEmpty()

bool sparta::statistics::SIValuesBuffer::buffersAreEmpty ( ) const
inline

Ask if this buffer is completely empty.

Definition at line 151 of file SIValuesBuffer.hpp.

◆ buffersAreFilled()

bool sparta::statistics::SIValuesBuffer::buffersAreFilled ( ) const
inline

Ask if this buffer has any room for another SI block. You should call this before bufferCurrentSIValues() is called during each report update. If you try to call bufferCurrentSIValues() and the buffer is full, it will assert.

Definition at line 146 of file SIValuesBuffer.hpp.

◆ getBeginningAndEndingTimestampsForBufferedSIs()

void sparta::statistics::SIValuesBuffer::getBeginningAndEndingTimestampsForBufferedSIs ( uint64_t &  starting_picoseconds,
uint64_t &  ending_picoseconds,
uint64_t &  starting_cycles,
uint64_t &  ending_cycles 
) const
inline

Get the starting and ending simulated picoseconds and root clock cycle for the SI's in this buffer.

This will assert if the buffer is empty. Call either buffersAreFilled(), buffersAreEmpty(), or getNumBufferedSIBlocks() first to see if calling this method here is even valid.

Definition at line 312 of file SIValuesBuffer.hpp.

◆ getBufferedSIValues()

const std::vector< double > & sparta::statistics::SIValuesBuffer::getBufferedSIValues ( )
inline

Ask this container for all of its buffered SI values. If this container is empty, it will return a vector of NaN's. If it is partially filled, it will squeeze the SI values like so:

Say we have 4 SI's, a maximum of 3 report updates before
this container is filled, and 2 of those updates have hit.

[1.2, 1.4, —, 450, 453, —, 1000, 1001, —, 12, 12, —]

If you called this method at this time, it would return a vector of size 8 (2 report updates * 4 SI's)

[1.2, 1.4, 450, 453, 1000, 1001, 12, 12]

This is more expensive than asking for the buffered data when the container is full, and we only do this at the end of the simulation when we need to get any leftover report updates' SI values out of the buffer and written to disk.

Definition at line 268 of file SIValuesBuffer.hpp.

Here is the call graph for this function:

◆ getMajorOrdering()

db::MajorOrdering sparta::statistics::SIValuesBuffer::getMajorOrdering ( ) const
inline

Ask this buffer if it is using row-major or column- major SI ordering

Definition at line 94 of file SIValuesBuffer.hpp.

◆ getNumBufferedSIBlocks()

size_t sparta::statistics::SIValuesBuffer::getNumBufferedSIBlocks ( ) const
inline

Ask this container how many blocks of SI values it currently has buffered.

Definition at line 157 of file SIValuesBuffer.hpp.

◆ initializeNumSIBuffers()

void sparta::statistics::SIValuesBuffer::initializeNumSIBuffers ( const size_t  num_si_buffers)
inline

Initialize the number of SI buffers this container should be able to hold. In the comment above this class, that string of SI values had three buffers for four SI's.

The number of SI buffers you choose will dictate how many report updates can hit before this container is full and needs to be consumed (written to disk).

Definition at line 108 of file SIValuesBuffer.hpp.

◆ resetSIBuffers()

void sparta::statistics::SIValuesBuffer::resetSIBuffers ( const bool  fill_with_nans = true)
inline

Typically, you will only call this method right after you get all the buffered SI data out of this container and consume it first.

This applies any pending updated # of SI blocks that you set if you previously called updateNumSIBuffers()

Definition at line 167 of file SIValuesBuffer.hpp.

Here is the call graph for this function:

◆ updateNumSIBuffers()

void sparta::statistics::SIValuesBuffer::updateNumSIBuffers ( const size_t  num_si_buffers)
inline

Tell this SIValuesBuffer to update how many contiguous blocks of SI's it can hold. This will not take effect until right after this container is reset/cleared.

SIValuesBuffer buf(stats); buf.initializeNumSIBuffers(3); ... buf.bufferCurrentSIValues(); <– report update buf.bufferCurrentSIValues(); <– report update buf.updateNumSIBuffers(2); <– no effect yet buf.bufferCurrentSIValues(); <– report update

if (buf.buffersAreFilled()) { //call getBufferedSIValues() and flush the data buf.resetSIBuffers(); <– resized to 2 SI blocks }

buf.bufferCurrentSIValues(); <– report update buf.bufferCurrentSIValues(); <– report update buf.bufferCurrentSIValues(); <– ASSERT! We don't have space for a third SI block!

Definition at line 135 of file SIValuesBuffer.hpp.

◆ useColumnMajorOrdering()

void sparta::statistics::SIValuesBuffer::useColumnMajorOrdering ( )
inline

Switch this buffer to start using column-major ordering as it fills its internal SI buffers.

Note
Must be called when buffersAreEmpty()

Definition at line 83 of file SIValuesBuffer.hpp.

Here is the call graph for this function:

◆ useRowMajorOrdering()

void sparta::statistics::SIValuesBuffer::useRowMajorOrdering ( )
inline

Switch this buffer to start using row-major ordering as it fills its internal SI buffers. This is the default behavior.

Note
Must be called when buffersAreEmpty()

Definition at line 71 of file SIValuesBuffer.hpp.

Here is the call graph for this function:

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