CARLsim
5.0.0
CARLsim: a GPU-accelerated SNN simulator
|
Go to the documentation of this file.
60 monitorId_ = monitorId;
64 neuronMonLastUpdated_ = 0;
66 persistentData_ =
false;
67 userHasBeenWarned_ =
false;
68 needToWriteFileHeader_ =
true;
69 neuronFileSignature_ = 206661979;
70 neuronFileVersion_ = 0.1f;
76 void NeuronMonitorCore::init() {
81 vectorV_.resize(nNeurons_);
82 vectorU_.resize(nNeurons_);
83 vectorI_.resize(nNeurons_);
95 if (neuronFileId_!=NULL) {
96 fclose(neuronFileId_);
104 userHasBeenWarned_ =
false;
111 for (
int i=0; i<nNeurons_; i++){
121 vectorV_[neurId].push_back(V);
122 vectorU_[neurId].push_back(U);
123 vectorI_[neurId].push_back(I);
129 if (!persistentData_) {
141 if (persistentData_) {
144 startTime_ = (startTime_<0) ? currentTime : startTime_;
145 startTimeLast_ = currentTime;
146 accumTime_ = (totalTime_>0) ? totalTime_ : 0;
150 startTime_ = currentTime;
151 startTimeLast_ = currentTime;
158 assert(startTime_>-1 && startTimeLast_>-1 && accumTime_>-1);
165 userHasBeenWarned_ =
false;
169 totalTime_ = stopTime_-startTimeLast_ + accumTime_;
170 assert(totalTime_>=0);
182 if (neuronFileId_!=NULL) {
183 fclose(neuronFileId_);
184 neuronFileId_ = NULL;
188 neuronFileId_=neuronFileId;
190 if (neuronFileId_==NULL)
191 needToWriteFileHeader_ =
false;
194 needToWriteFileHeader_ =
true;
201 if (!needToWriteFileHeader_)
205 if (!fwrite(&neuronFileSignature_,
sizeof(
int),1,neuronFileId_))
206 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
209 if (!fwrite(&neuronFileVersion_,
sizeof(
float),1,neuronFileId_))
210 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
214 int tmpInt = grid.
numX;
215 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
216 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
219 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
220 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
223 if (!fwrite(&tmpInt,
sizeof(
int),1,neuronFileId_))
224 KERNEL_ERROR(
"NeuronMonitorCore: writeNeuronFileHeader has fwrite error");
227 needToWriteFileHeader_ =
false;
231 long int bufferSize=0;
232 for(
int i=0; i<vectorV_.size();i++){
233 bufferSize+=vectorV_[i].size()*
sizeof(int);
235 return 3 * bufferSize;
241 if(userHasBeenWarned_)
246 userHasBeenWarned_=
true;
274 int dispVoltsPerRow = 7;
278 KERNEL_INFO(
"|- - - - -|- - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - -")
280 for (
int i=0; i<nNeurons_; i++) {
282 #if defined(WIN32) || defined(WIN64)
283 _snprintf(buffer, 100,
"| %7d | ", i);
285 snprintf(buffer, 100,
"| %7d | ", i);
287 int nV = vectorV_[i].size();
288 for (
int j=0; j<nV; j++) {
290 #if defined(WIN32) || defined(WIN64)
291 _snprintf(volts, 10,
"%4.4f ", vectorV_[i][j]);
293 snprintf(volts, 10,
"%4.4f ", vectorV_[i][j]);
295 strcat(buffer, volts);
296 if (j%dispVoltsPerRow == dispVoltsPerRow-1 && j<nV-1) {
298 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