8 #include "DataStore.hpp" 9 #include "include/pv_common.h" 10 #include "utils/PVAssert.hpp" 11 #include "utils/PVLog.hpp" 17 DataStore::DataStore(
int numBuffers,
int numItems,
int numLevels,
bool isSparse_flag) {
18 assert(numLevels > 0 && numBuffers > 0);
23 mNumLevels = numLevels;
24 mNumBuffers = numBuffers;
26 mBuffer =
new RingBuffer<float>(numLevels, numBuffers * numItems);
27 mLastUpdateTimes =
new RingBuffer<double>(
28 numLevels, numBuffers, -std::numeric_limits<double>::infinity() );
30 mSparseFlag = isSparse_flag;
33 new RingBuffer<SparseList<float>::Entry>(numLevels, numBuffers * numItems, {0, 0});
34 mNumActive =
new RingBuffer<long>(numLevels, numBuffers);
38 void DataStore::markActiveIndicesOutOfSync(
int bufferId,
int level) {
42 long *numActiveBuf = numActiveBuffer(bufferId, level);
46 void DataStore::updateActiveIndices(
int bufferId,
int level) {
51 float *activity = buffer(bufferId, level);
53 SparseList<float>::Entry *activeIndices = activeIndicesBuffer(bufferId, level);
55 for (
int kex = 0; kex < getNumItems(); kex++) {
56 float a = activity[kex];
58 activeIndices[numActive].index = kex;
59 activeIndices[numActive].value = a;
64 long *numActiveBuf = numActiveBuffer(bufferId, level);
65 *numActiveBuf = numActive;
71 cube.numItems = mNumItems * mNumBuffers;
72 cube.data = buffer(0 , delay);
76 cube.isSparse = isSparse();
78 cube.numActive = numActiveBuffer(0, delay);
79 cube.activeIndices = activeIndicesBuffer(0, delay);
PVLayerCube createCube(PVLayerLoc const &loc, int delay)