Graphitti
A toolkit/software architecture to ease creating high-performance neural network simulators
Loading...
Searching...
No Matches
EventBuffer< T > Class Template Reference
Inheritance diagram for EventBuffer< T >:
Collaboration diagram for EventBuffer< T >:

Public Member Functions

 EventBuffer (int maxEvents=0)
 
int getBufferFront () const
 Accessor for the buffer front value.
 
int getBufferEnd () const
 Accessor for the buffer end value.
 
int getEpochStart () const
 Accessor for the epoch start value.
 
int getNumElementsInEpoch () const
 
void setBufferFront (int bufferFront)
 Mutator for the buffer front value.
 
void setBufferEnd (int bufferEnd)
 Mutator for the buffer end value.
 
void setEpochStart (int epochStart)
 Mutator for the epoch start value.
 
void setNumElementsInEpoch (int numElementsInEpoch)
 Sets number of events in the current/preceding epoch.
 
void resize (int maxEvents)
 }
 
operator[] (int i) const
 
template<class Archive >
void serialize (Archive &archive)
 Cereal serialization method.
 
Recorder Interface

virtual methods in RecordableBase for use by Recorder classes

variantTypes getElement (int index) const
 
int getNumElements () const
 Get the number of elements that needs to be recorded.
 
void startNewEpoch ()
 
Vertex and Edge Interface

EventBuffer interface for use by the Vertex and Edge classes

void clear ()
 
int size ()
 
void insertEvent (T timeStep)
 
getPastEvent (int offset) const
 
- Public Member Functions inherited from RecordableVector< T >
 RecordableVector ()
 Constructor.
 
virtual void setDataType () override
 
virtual const std::string & getDataType () const override
 Get a string representing the data type of the recordable variable.
 
virtual void assign (size_t size, const T &value)
 Assigns the given value to the vector for the specified size.
 
T & operator[] (int index)
 Overload the operator to set the value at a specific index.
 
void push_back (const T &value)
 Add a new value to recordable vector.
 
const std::vector< T > & getVector () const
 Method to retrieve the underlying std::vector<T>
 
T * data ()
 Gets pointer to contiguous host memory array.
 
const T * data () const
 Gets const pointer to contiguous host memory array.
 
template<class Archive >
void serialize (Archive &archive)
 Cereal serialization method.
 
- Public Member Functions inherited from RecordableBase
template<class Archive >
void serialize (Archive &archive)
 Cereal serialization method.
 

Additional Inherited Members

- Protected Member Functions inherited from RecordableBase
 RecordableBase ()=default
 prevents any code outside this class from creating a RecordableBase object
 
- Protected Attributes inherited from RecordableVector< T >
vector< T > dataSeries_
 Holds the event time steps.
 
- Protected Attributes inherited from RecordableBase
std::string basicDataType_
 the basic data type in the recorded variable
 

Detailed Description

template<typename T>
class EventBuffer< T >

Definition at line 31 of file EventBuffer.h.

Constructor & Destructor Documentation

◆ EventBuffer()

template<typename T >
EventBuffer< T >::EventBuffer ( int maxEvents = 0)
inline

Create EventBuffer that is sized appropriately

Create and size the buffer so that it can hold a set number of events. Once an EventBuffer is created with a nonzero size, it should not be resized (generally, doing that will cause a major bug in the simulator). Note that the buffer size will be set to maxEvents+1, to distinguish between an empty and a full buffer.

Parameters
maxEventsDefaults to zero; otherwise, buffer size is set

Definition at line 41 of file EventBuffer.h.

Member Function Documentation

◆ clear()

template<typename T >
void EventBuffer< T >::clear ( )
inline

Reset member variables consistent with an empty buffer

Definition at line 172 of file EventBuffer.h.

◆ getBufferEnd()

template<typename T >
int EventBuffer< T >::getBufferEnd ( ) const
inline

Accessor for the buffer end value.

Returns
Returns index of the last event in the queue.

Definition at line 91 of file EventBuffer.h.

◆ getBufferFront()

template<typename T >
int EventBuffer< T >::getBufferFront ( ) const
inline

Accessor for the buffer front value.

Returns
Returns index of the first event in the queue.

Definition at line 84 of file EventBuffer.h.

◆ getElement()

template<typename T >
variantTypes EventBuffer< T >::getElement ( int index) const
inlinevirtual

Set up a string representing the basic data type Get the value of the recordable variable at the specified index.

Parameters
indexThe index of the recorded value to retrieve.
Returns
A variant representing the recorded value (uint64_t, double, or string).

Reimplemented from RecordableVector< T >.

Definition at line 57 of file EventBuffer.h.

◆ getEpochStart()

template<typename T >
int EventBuffer< T >::getEpochStart ( ) const
inline

Accessor for the epoch start value.

Returns
Returns index of the start of the events in the current epoch.

Definition at line 98 of file EventBuffer.h.

◆ getNumElements()

template<typename T >
int EventBuffer< T >::getNumElements ( ) const
inlinevirtual

Get the number of elements that needs to be recorded.

Reimplemented from RecordableVector< T >.

Definition at line 63 of file EventBuffer.h.

◆ getNumElementsInEpoch()

template<typename T >
int EventBuffer< T >::getNumElementsInEpoch ( ) const
inline

Get number of events in the current/preceding epoch

Getting the number of events in the current epoch (or, in between epochs, the number of events in the preceding epoch) is not the same as the number of events in the buffer, because the buffer retains events from the previous epoch, too.

Definition at line 108 of file EventBuffer.h.

◆ getPastEvent()

template<typename T >
T EventBuffer< T >::getPastEvent ( int offset) const
inline

Get an event from a time in the past

Get the time step for an event in the past. An offset of -1 means the last event placed in the buffer; -2 means two events ago.

Parameters
offsetHow many events ago. Must be negative. If that event isn't in the buffer, or if the buffer is empty, returns ULONG_MAX.

Definition at line 212 of file EventBuffer.h.

◆ insertEvent()

template<typename T >
void EventBuffer< T >::insertEvent ( T timeStep)
inline

Insert an event time step

Insert an event time step into the buffer (i.e., enqueue it in the circular array implementation of the queue).

Precondition
The buffer is not full
Parameters
timeStepValue to store in buffer

Definition at line 194 of file EventBuffer.h.

◆ operator[]()

template<typename T >
T EventBuffer< T >::operator[] ( int i) const
inline

Access event from current epoch

Access an element of the buffer as though it is an array or vector with element 0 being the first event in the epoch (element numElementsInEpoch_ - 1 would be the last element in the epoch).

Parameters
ielement number

Definition at line 162 of file EventBuffer.h.

◆ resize()

template<typename T >
void EventBuffer< T >::resize ( int maxEvents)
inlinevirtual

}

Resize event buffer

Note that the buffer size will be set to maxEvents+1, to distinguish between an empty and a full buffer.

Precondition
current buffer must be empty
Parameters
maxEventsBuffer size

Reimplemented from RecordableVector< T >.

Definition at line 147 of file EventBuffer.h.

◆ serialize()

template<typename T >
template<class Archive >
void EventBuffer< T >::serialize ( Archive & archive)
inline

Cereal serialization method.

Definition at line 242 of file EventBuffer.h.

◆ setBufferEnd()

template<typename T >
void EventBuffer< T >::setBufferEnd ( int bufferEnd)
inline

Mutator for the buffer end value.

Definition at line 122 of file EventBuffer.h.

◆ setBufferFront()

template<typename T >
void EventBuffer< T >::setBufferFront ( int bufferFront)
inline

Mutator for the buffer front value.

Setters are needed for copying from the GPU. Allows us to remove the friend keyword requirement. {

Definition at line 116 of file EventBuffer.h.

◆ setEpochStart()

template<typename T >
void EventBuffer< T >::setEpochStart ( int epochStart)
inline

Mutator for the epoch start value.

Definition at line 128 of file EventBuffer.h.

◆ setNumElementsInEpoch()

template<typename T >
void EventBuffer< T >::setNumElementsInEpoch ( int numElementsInEpoch)
inline

Sets number of events in the current/preceding epoch.

Definition at line 134 of file EventBuffer.h.

◆ size()

template<typename T >
int EventBuffer< T >::size ( )
inline
Returns
Returns the size of the buffer.

Definition at line 182 of file EventBuffer.h.

◆ startNewEpoch()

template<typename T >
void EventBuffer< T >::startNewEpoch ( )
inlinevirtual

Start a new epoch

Resets the internal variables associated with tracking the events in a epoch. Note that this doesn't affect the contents of the buffer; it just resets things so that the epoch start is the index of the next event to be enqueued and that the number of events in the epoch is 0.

Reimplemented from RecordableVector< T >.

Definition at line 73 of file EventBuffer.h.


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