43 #if ! (_WIN32 || _WIN64)
45 #define strcmpi(s1,s2) strcasecmp(s1,s2)
57 fprintf(fp,
"*************Memory Info *************\n");
58 int totMemSize = cpuSnnSz.networkInfoSize+cpuSnnSz.synapticInfoSize+cpuSnnSz.neuronInfoSize+cpuSnnSz.spikingInfoSize;
59 fprintf(fp,
"Neuron Info Size: %3.2f (%f MB)\n", cpuSnnSz.neuronInfoSize*100.0/totMemSize, cpuSnnSz.neuronInfoSize/(1024.0*1024));
60 fprintf(fp,
"Synaptic Info Size: %3.2f (%f MB)\n", cpuSnnSz.synapticInfoSize*100.0/totMemSize, cpuSnnSz.synapticInfoSize/(1024.0*1024));
61 fprintf(fp,
"Network Size: %3.2f (%f MB)\n", cpuSnnSz.networkInfoSize*100.0/totMemSize, cpuSnnSz.networkInfoSize/(1024.0*1024));
62 fprintf(fp,
"Firing Info Size: %3.2f (%f MB)\n", cpuSnnSz.spikingInfoSize*100.0/totMemSize, cpuSnnSz.spikingInfoSize/(1024.0*1024));
63 fprintf(fp,
"Additional Info: %3.2f (%f MB)\n", cpuSnnSz.addInfoSize*100.0/totMemSize, cpuSnnSz.addInfoSize/(1024.0*1024));
64 fprintf(fp,
"DebugInfo Info: %3.2f (%f MB)\n", cpuSnnSz.debugInfoSize*100.0/totMemSize, cpuSnnSz.debugInfoSize/(1024.0*1024));
65 fprintf(fp,
"**************************************\n\n");
67 fprintf(fp,
"************* Connection Info *************\n");
68 for(
int g=0; g < numGrp; g++) {
72 for(
int i=grp_Info[g].StartN; i <= grp_Info[g].EndN; i++) {
75 TNpre_plastic += Npre_plastic[i];
77 fprintf(fp,
"%s Group (num_neurons=%5d): \n\t\tNpost[%2d] = %3d, Npre[%2d]=%3d Npre_plastic[%2d]=%3d \n\t\tcumPre[%5d]=%5d cumPre[%5d]=%5d cumPost[%5d]=%5d cumPost[%5d]=%5d \n",
78 grp_Info2[g].Name.c_str(), grp_Info[g].SizeN, g, TNpost/grp_Info[g].SizeN, g, TNpre/grp_Info[g].SizeN, g, TNpre_plastic/grp_Info[g].SizeN,
79 grp_Info[g].StartN, cumulativePre[grp_Info[g].StartN], grp_Info[g].EndN, cumulativePre[grp_Info[g].EndN],
80 grp_Info[g].StartN, cumulativePost[grp_Info[g].StartN], grp_Info[g].EndN, cumulativePost[grp_Info[g].EndN]);
82 fprintf(fp,
"**************************************\n\n");
91 void CpuSNN::printState(
const char *str)
93 fprintf(stderr,
"%s", str);
94 for(
int g=0; g < numGrp; g++) {
95 if(grp_Info2[g].enablePrint) {
96 printNeuronState(g, stderr);
102 void CpuSNN::printGroupInfo(FILE* fp)
106 for(
int g=0; g < numGrp; g++) {
108 fprintf(fp,
"Group %s: \n", grp_Info2[g].Name.c_str());
109 fprintf(fp,
"------------\n");
110 fprintf(fp,
"\t Size = %d\n", grp_Info[g].SizeN);
111 fprintf(fp,
"\t Start = %d\n", grp_Info[g].StartN);
112 fprintf(fp,
"\t End = %d\n", grp_Info[g].EndN);
113 fprintf(fp,
"\t numPostSynapses = %d\n", grp_Info[g].numPostSynapses);
114 fprintf(fp,
"\t numPreSynapses = %d\n", grp_Info[g].numPreSynapses);
115 fprintf(fp,
"\t Average Post Connections = %f\n", 1.0*grp_Info2[g].numPostConn/grp_Info[g].SizeN);
116 fprintf(fp,
"\t Average Pre Connections = %f\n", 1.0*grp_Info2[g].numPreConn/grp_Info[g].SizeN);
118 if(grp_Info[g].Type&POISSON_NEURON) {
119 fprintf(fp,
"\t Refractory-Period = %f\n", grp_Info[g].RefractPeriod);
122 fprintf(fp,
"\t FIXED_WTS = %s\n", grp_Info[g].FixedInputWts?
"FIXED_WTS":
"PLASTIC_WTS");
124 if (grp_Info[g].WithSTP) {
125 fprintf(fp,
"\t STP_U = %f\n", grp_Info[g].STP_U);
126 fprintf(fp,
"\t STP_tD = %f\n", grp_Info[g].STP_tD);
127 fprintf(fp,
"\t STP_tF = %f\n", grp_Info[g].STP_tF);
130 if(grp_Info[g].WithSTDP) {
131 fprintf(fp,
"\t ALPHA_LTP = %f\n", grp_Info[g].ALPHA_LTP);
132 fprintf(fp,
"\t ALPHA_LTD = %f\n", grp_Info[g].ALPHA_LTD);
133 fprintf(fp,
"\t TAU_LTP_INV = %f\n", grp_Info[g].TAU_LTP_INV);
134 fprintf(fp,
"\t TAU_LTD_INV = %f\n", grp_Info[g].TAU_LTD_INV);
141 void CpuSNN::printGroupInfo2(FILE* fpg)
143 fprintf(fpg,
"#Group Information\n");
144 for(
int g=0; g < numGrp; g++) {
145 fprintf(fpg,
"group %d: name %s : type %s %s %s %s %s: size %d : start %d : end %d \n",
146 g, grp_Info2[g].Name.c_str(),
147 (grp_Info[g].Type&POISSON_NEURON) ?
"poisson " :
"",
148 (grp_Info[g].Type&TARGET_AMPA) ?
"AMPA" :
"",
149 (grp_Info[g].Type&TARGET_NMDA) ?
"NMDA" :
"",
150 (grp_Info[g].Type&TARGET_GABAa) ?
"GABAa" :
"",
151 (grp_Info[g].Type&TARGET_GABAb) ?
"GABAb" :
"",
160 void CpuSNN::printConnectionInfo2(FILE *fpg)
164 fprintf(fpg,
"#Connection Information \n");
165 fprintf(fpg,
"#(e.g. from => to : approx. # of post (numPostSynapses) : approx. # of pre-synaptic (numPreSynapses) : weights.. : type plastic or fixed : max and min axonal delay\n");
167 bool synWtType = GET_FIXED_PLASTIC(newInfo->connProp);
168 fprintf(fpg,
" %d => %d : %s => %s : numPostSynapses %d : numPreSynapses %d : initWeight %f : maxWeight %3.3f : type %s : maxDelay %d : minDelay %d\n",
169 newInfo->grpSrc, newInfo->grpDest, grp_Info2[newInfo->grpSrc].Name.c_str(), grp_Info2[newInfo->grpDest].Name.c_str(),
170 newInfo->numPostSynapses, newInfo->numPreSynapses, newInfo->initWt, newInfo->maxWt,
171 (synWtType == SYN_PLASTIC)?
"plastic":
"fixed", newInfo->maxDelay, newInfo->minDelay);
172 newInfo = newInfo->next;
178 void CpuSNN::printConnectionInfo(FILE *fp)
186 fprintf(fp,
"\nConnections: \n");
187 fprintf(fp,
"------------\n");
189 bool synWtType = GET_FIXED_PLASTIC(newInfo->connProp);
190 fprintf(fp,
" // (%s => %s): numPostSynapses=%d, numPreSynapses=%d, iWt=%3.3f, mWt=%3.3f, ty=%x, maxD=%d, minD=%d %s\n",
191 grp_Info2[newInfo->grpSrc].Name.c_str(), grp_Info2[newInfo->grpDest].Name.c_str(),
192 newInfo->numPostSynapses, newInfo->numPreSynapses, newInfo->initWt, newInfo->maxWt,
193 newInfo->connProp, newInfo->maxDelay, newInfo->minDelay, (synWtType == SYN_PLASTIC)?
"(*)":
"");
199 newInfo = newInfo->next;
205 void CpuSNN::printParameters(FILE* fp)
207 #ifdef USE_EXCEPTIONS
209 throw std::runtime_error(
"print parmaters file was not specified.\n");
215 printConnectionInfo(fp);
218 void CpuSNN::printGroupInfo(
string& strName)
220 fprintf(stderr,
"String Name : %s\n", strName.c_str());
221 for(
int g=0; g < numGrp; g++) {
222 if(grp_Info[g].Type&POISSON_NEURON)
223 fprintf(stderr,
"Poisson Group %d: %s\n", g, grp_Info2[g].Name.c_str());
230 if(fp) fprintf(fp,
"PRINTING POST-SYNAPTIC CONNECTION TOPOLOGY\n");
231 if(fp) fprintf(fp,
"(((((((((((((((((((((())))))))))))))))))))))\n");
232 for(
int i=0; i < numGrp; i++)
237 void CpuSNN::printPreConnection(FILE *fp)
239 if(fp) fprintf(fp,
"PRINTING PRE-SYNAPTIC CONNECTION TOPOLOGY\n");
240 if(fp) fprintf(fp,
"(((((((((((((((((((((())))))))))))))))))))))\n");
241 for(
int i=0; i < numGrp; i++)
242 printPreConnection(i,fp);
246 int CpuSNN::printPostConnection2(
int grpId, FILE* fpg)
249 for(
int i=grp_Info[grpId].StartN; i<=grp_Info[grpId].EndN; i++) {
250 fprintf(fpg,
" id %d : group %d : postlength %d ", i, findGrpId(i), Npost[i]);
252 post_info_t* postIds = &postSynapticIds[cumulativePost[i]];
253 for(
int j=0; j <= D; j++) {
254 int len = postDelayInfo[i*(D+1)+j].delay_length;
255 int start = postDelayInfo[i*(D+1)+j].delay_index_start;
256 for(
int k=start; k < len; k++) {
257 int post_nid = GET_CONN_NEURON_ID((*postIds));
259 fprintf(fpg,
" : %d,%d ", post_nid, j);
262 if (Npost[i] > maxLength)
263 maxLength = Npost[i];
264 if ((start+len) >= Npost[i])
273 void CpuSNN::printNetworkInfo()
275 int maxLengthPost = -1;
276 int maxLengthPre = -1;
277 FILE *fpg = fopen(
"net_info.txt",
"w");
278 printGroupInfo2(fpg);
279 printConnectionInfo2(fpg);
280 fprintf(fpg,
"#Flat Network Info Format \n");
281 fprintf(fpg,
"#(neuron id : length (number of connections) : neuron_id0,delay0 : neuron_id1,delay1 : ... \n");
282 for(
int g=0; g < numGrp; g++) {
283 int postM = printPostConnection2(g, fpg);
284 int numPreSynapses = printPreConnection2(g, fpg);
285 if (postM > maxLengthPost)
286 maxLengthPost = postM;
287 if (numPreSynapses > maxLengthPre)
288 maxLengthPre = numPreSynapses;
292 fprintf(stdout,
"Max post-synaptic length = %d\n", maxLengthPost);
293 fprintf(stdout,
"Max pre-synaptic length = %d\n", maxLengthPre);
296 void CpuSNN::printFiringRate(
char *fname)
298 static int printCnt = 0;
302 strFname = networkName;
308 fpg = fopen(strFname.c_str(),
"w");
310 fpg = fopen(strFname.c_str(),
"a");
312 fprintf(fpg,
"#Average Firing Rate\n");
314 fprintf(fpg,
"#network %s: size = %d\n", networkName.c_str(), numN);
315 for(
int grpId=0; grpId < numGrp; grpId++) {
316 fprintf(fpg,
"#group %d: name %s : size = %d\n", grpId, grp_Info2[grpId].Name.c_str(), grp_Info[grpId].SizeN);
319 fprintf(fpg,
"Time %d ms\n", simTime);
320 fprintf(fpg,
"#activeNeurons ( <= 1.0) = fraction of neuron in the given group that are firing more than 1Hz\n");
321 fprintf(fpg,
"#avgFiring (in Hz) = Average firing rate of activeNeurons in given group\n");
322 for(
int grpId=0; grpId < numGrp; grpId++) {
323 fprintf(fpg,
"group %d : \t", grpId);
326 for(
int i=grp_Info[grpId].StartN; i<=grp_Info[grpId].EndN; i++) {
327 if (nSpikeCnt[i] >= 1.0) {
328 totSpike += nSpikeCnt[i];
332 fprintf(fpg,
" activeNeurons = %3.3f : avgFiring = %3.3f \n", activeCnt*1.0/grp_Info[grpId].SizeN, (activeCnt==0)?0.0:totSpike*1.0/activeCnt);
342 for(
int i=grp_Info[grpId].StartN; i<=grp_Info[grpId].EndN; i++) {
343 if(fp) fprintf(fp,
" %3d ( %3d ) : \t", i, Npost[i]);
345 post_info_t* postIds = &postSynapticIds[cumulativePost[i]];
346 int offset = cumulativePost[i];
347 for(
int j=0; j < Npost[i]; j++, postIds++) {
348 int post_nid = GET_CONN_NEURON_ID((*postIds));
349 int post_gid = GET_CONN_GRP_ID((*postIds));
351 #ifdef USE_EXCEPTIONS
352 if(findGrpId(post_nid) != post_gid)
353 throw std::runtime_error(
"findGrpId(post_nid) != post_gid.\n");
355 assert( findGrpId(post_nid) == post_gid);
358 if(fp) fprintf(fp,
" %3d ( D=%3d, Grp=%3d) ", post_nid, tmp_SynapticDelay[offset+j], post_gid);
360 if(fp) fprintf(fp,
"\n");
361 if(fp) fprintf(fp,
" Delay ( %3d ) : ", i);
362 for(
int j=0; j < D; j++) {
363 if(fp) fprintf(fp,
" %d,%d ", postDelayInfo[i*(D+1)+j].delay_length,
364 postDelayInfo[i*(D+1)+j].delay_index_start);
366 if(fp) fprintf(fp,
"\n");
370 int CpuSNN::printPreConnection2(
int grpId, FILE* fpg)
373 for(
int i=grp_Info[grpId].StartN; i<=grp_Info[grpId].EndN; i++) {
374 fprintf(fpg,
" id %d : group %d : prelength %d ", i, findGrpId(i), Npre[i]);
375 post_info_t* preIds = &preSynapticIds[cumulativePre[i]];
376 for(
int j=0; j < Npre[i]; j++, preIds++) {
377 if (doneReorganization && (!memoryOptimized))
378 fprintf(fpg,
": %d,%s", GET_CONN_NEURON_ID((*preIds)), (j < Npre_plastic[i])?
"P":
"F");
380 if ( Npre[i] > maxLength)
387 void CpuSNN::printPreConnection(
int grpId, FILE* fp)
389 for(
int i=grp_Info[grpId].StartN; i<=grp_Info[grpId].EndN; i++) {
390 if(fp) fprintf(fp,
" %d ( preCnt=%d, prePlastic=%d ) : (id => (wt, maxWt),(preId, P/F)\n\t", i, Npre[i], Npre_plastic[i]);
391 post_info_t* preIds = &preSynapticIds[cumulativePre[i]];
392 int pos_i = cumulativePre[i];
393 for(
int j=0; j < Npre[i]; j++, pos_i++, preIds++) {
394 if(fp) fprintf(fp,
" %d => (%f, %f)", j, wt[pos_i], maxSynWt[pos_i]);
395 if(doneReorganization && (!memoryOptimized))
396 if(fp) fprintf(fp,
",(%d, %s)",
397 GET_CONN_NEURON_ID((*preIds)),
398 (j < Npre_plastic[i])?
"P":
"F");
400 if(fp) fprintf(fp,
"\n");
507 void CpuSNN::printNeuronState(
int grpId, FILE*fp)
509 if (currentMode==GPU_MODE) {
510 copyNeuronState(&cpuNetPtrs, &cpu_gpuNetPtrs, cudaMemcpyDeviceToHost,
false, grpId);
513 fprintf(fp,
"[MODE=%s] ", (currentMode==GPU_MODE)?
"GPU_MODE":
"CPU_MODE");
514 fprintf(fp,
"Group %s (%d) Neuron State Information (totSpike=%d, poissSpike=%d)\n",
515 grp_Info2[grpId].Name.c_str(), grpId, spikeCountAll, nPoissonSpikes);
518 if(grp_Info[grpId].Type&POISSON_NEURON) {
519 fprintf(fp,
"t=%d msec ", simTime);
521 for (
int nid=grp_Info[grpId].StartN; nid <= grp_Info[grpId].EndN; nid++) {
523 fprintf(fp,
"%d ", cpuNetPtrs.
nSpikeCnt[nid]);
526 fprintf(fp,
"TotalSpikes [grp=%d, %s]= %d\n", grpId, grp_Info2[grpId].Name.c_str(), totSpikes);
531 for (
int nid=grp_Info[grpId].StartN; nid <= grp_Info[grpId].EndN; nid++) {
534 if(!sim_with_conductances) {
535 if(cpuNetPtrs.current[nid] != 0.0)
536 fprintf(fp,
"t=%d id=%d v=%+3.3f u=%+3.3f I=%+3.3f nSpikes=%d\n", simTime, nid,
537 cpuNetPtrs.voltage[nid], cpuNetPtrs.recovery[nid], cpuNetPtrs.current[nid],
541 if (cpuNetPtrs.gAMPA[nid]+ cpuNetPtrs.gNMDA[nid]+cpuNetPtrs.gGABAa[nid]+cpuNetPtrs.gGABAb[nid] != 0.0)
542 fprintf(fp,
"t=%d id=%d v=%+3.3f u=%+3.3f I=%+3.3f gAMPA=%2.5f gNMDA=%2.5f gGABAa=%2.5f gGABAb=%2.5f nSpikes=%d\n", simTime, nid,
543 cpuNetPtrs.voltage[nid], cpuNetPtrs.recovery[nid], cpuNetPtrs.current[nid], cpuNetPtrs.gAMPA[nid],
544 cpuNetPtrs.gNMDA[nid], cpuNetPtrs.gGABAa[nid], cpuNetPtrs.gGABAb[nid], cpuNetPtrs.
nSpikeCnt[nid]);
547 fprintf(fp,
"TotalSpikes [grp=%d, %s] = %d\n", grpId, grp_Info2[grpId].Name.c_str(), totSpikes);
unsigned int * nSpikeCnt
homeostatic plasticity variables
void printMemoryInfo(FILE *fp=stdout)
prints memory info to file
void printPostConnection(FILE *fp=stdout)
print all the connections...