CARLsim
4.1.0
CARLsim: a GPU-accelerated SNN simulator
|
Go to the documentation of this file.
59 monitorId_ = monitorId;
63 neuronMonLastUpdated_ = 0;
65 persistentData_ =
false;
66 userHasBeenWarned_ =
false;
67 needToWriteFileHeader_ =
true;
68 neuronFileSignature_ = 206661979;
69 neuronFileVersion_ = 0.1f;
75 void NeuronMonitorCore::init() {
80 vectorV_.resize(nNeurons_);
81 vectorU_.resize(nNeurons_);
82 vectorI_.resize(nNeurons_);
94 if (neuronFileId_!=NULL) {
95 fclose(neuronFileId_);
103 userHasBeenWarned_ =
false;
110 for (
int i=0; i<nNeurons_; i++){
120 vectorV_[neurId].push_back(V);
121 vectorU_[neurId].push_back(U);
122 vectorI_[neurId].push_back(I);
128 if (!persistentData_) {
140 if (persistentData_) {
143 startTime_ = (startTime_<0) ? currentTime : startTime_;
144 startTimeLast_ = currentTime;
145 accumTime_ = (totalTime_>0) ? totalTime_ : 0;
149 startTime_ = currentTime;
150 startTimeLast_ = currentTime;
157 assert(startTime_>-1 && startTimeLast_>-1 && accumTime_>-1);
164 userHasBeenWarned_ =
false;
168 totalTime_ = stopTime_-startTimeLast_ + accumTime_;
169 assert(totalTime_>=0);
181 if (neuronFileId_!=NULL) {
182 fclose(neuronFileId_);
183 neuronFileId_ = NULL;
187 neuronFileId_=neuronFileId;
189 if (neuronFileId_==NULL)
190 needToWriteFileHeader_ =
false;
193 needToWriteFileHeader_ =
true;
200 if (!needToWriteFileHeader_)
204 if (!fwrite(&neuronFileSignature_,
sizeof(
int),1,neuronFileId_))
205 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
208 if (!fwrite(&neuronFileVersion_,
sizeof(
float),1,neuronFileId_))
209 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
213 int tmpInt = grid.
numX;
214 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
215 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
218 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
219 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
222 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
223 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
226 needToWriteFileHeader_ =
false;
230 long int bufferSize=0;
231 for(
int i=0; i<vectorV_.size();i++){
232 bufferSize+=vectorV_[i].size()*
sizeof(int);
234 return 3 * bufferSize;
240 if(userHasBeenWarned_)
245 userHasBeenWarned_=
true;
273 int dispVoltsPerRow = 7;
277 KERNEL_INFO(
"|- - - - -|- - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - -")
279 for (
int i=0; i<nNeurons_; i++) {
281 #if defined(WIN32) || defined(WIN64)
282 _snprintf(buffer, 100,
"| %7d | ", i);
284 snprintf(buffer, 100,
"| %7d | ", i);
286 int nV = vectorV_[i].size();
287 for (
int j=0; j<nV; j++) {
289 #if defined(WIN32) || defined(WIN64)
290 _snprintf(volts, 10,
"%4.4f ", vectorV_[i][j]);
292 snprintf(volts, 10,
"%4.4f ", vectorV_[i][j]);
294 strcat(buffer, volts);
295 if (j%dispVoltsPerRow == dispVoltsPerRow-1 && j<nV-1) {
297 strcpy(buffer,
"| |");
#define MAX_NEURON_MON_BUFFER_SIZE
int getGroupNumNeurons(int gGrpId)
~NeuronMonitorCore()
destructor, cleans up all the memory upon object deletion
NeuronMonitorCore(SNN *snn, int monitorId, int grpId)
constructor (called by CARLsim::setNeuronMonitor)
void writeNeuronFileHeader()
void pushNeuronState(int neurId, float V, float U, float I)
inserts a (time,neurId) tupel into the D Neuron State vector
void stopRecording()
stops recording Neuron state
bool isRecording()
returns recording status
void updateNeuronMonitor(int grpId=ALL)
copy required neuron state values from ??? buffer to ??? buffer
long int getBufferSize()
returns the approximate size of the state vectors in bytes
std::vector< std::vector< float > > getVectorV()
returns the Neuron state vector
void setNeuronFileId(FILE *neuronFileId)
sets pointer to Neuron file
void print()
prints neuron states in human-readable format
#define KERNEL_ERROR(formatc,...)
#define KERNEL_INFO(formatc,...)
const FILE * getLogFpErr()
returns file pointer to error log
bool isBufferBig()
returns true if state buffers are close to maxAllowedBufferSize
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)
const FILE * getLogFpDeb()
returns file pointer to debug log
std::vector< std::vector< float > > getVectorU()
std::vector< std::vector< float > > getVectorI()
Contains all of CARLsim's core functionality.
long int getAccumTime()
returns the total accumulated time
void clear()
deletes data from the neuron state vector
Grid3D getGroupGrid3D(int grpId)
void startRecording()
starts recording Neuron state
const FILE * getLogFpLog()
returns file pointer to log file