-
Notifications
You must be signed in to change notification settings - Fork 0
/
DPSNN_stat.c
759 lines (688 loc) · 23.7 KB
/
DPSNN_stat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
// DPSNN_stat.c
// Distributed Plastic Spiking Neural Network, Simulation Engine
// DPSNN_*.*
// AUTHOR: Pier Stanislao Paolucci (Roma, Italy, 2011-...),
// AUTHOR: Elena Pastorelli (2013-...)
// AUTHOR: ...
// AUTHOR: plus other members of INFN Lab, Roma, Italy
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "DPSNN_parameters.h"
#include "DPSNN_stat.h"
#include "DPSNN_debug.h"
#include "DPSNN_chrono.h"
#include "DPSNN_dataStructDims.h"
int get_syn_pre_glob_n(const int i, const int j);
float get_syn_value(const int i, const int j);
int totalStat_fopen;
int max_totalStat_fopen;
void statBasicClass::test_prepCalled() {
if(lnp_par.loc_h==0) {
if(prepCalled != true) {
printf("ERROR stat_prep... not called\n");
fflush(stdout); exit(0);}
}
};
void statBasicClass::prep(
const struct DPSNN_parameters lnp_par_initValue,
const char prefixName_value[])
{
if(writeDisable==false) {
prepCalled = true;
lnp_par=lnp_par_initValue;
strcpy(prefixName, prefixName_value);
}
};
void statBasicClass::test_fopenStatus(const char methodName[],
const bool stat_booleanValue, const int sec, const int moduloSec) {
if(fopenStatus != stat_booleanValue) {
printf("ERROR on h=%d stat fopenStatus wrong, called by %s at sec=%d moduloSec=%d\n",
lnp_par.loc_h, methodName, sec, moduloSec);
fflush(stdout);
exit(0); }
};
void statBasicClass::openFile(const uint sec, const int moduloSec)
{
double totalSimTime;
totalSimTime = atoi(getenv("env_totalSimTime_ms"));
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if(sec % moduloSec == 0) {
test_prepCalled();
test_fopenStatus("openFile", false,sec, moduloSec);
if(lnp_par.howManyOutputFiles==longOutput_1){
sprintf(fName, "%s-sec%d-C%d-H%d-h%03d.dat",
prefixName,sec,
lnp_par.globCFT,lnp_par.globH,lnp_par.loc_h);
} else {
if(sec==0) {
sprintf(fName, "%s-start-C%d-H%d-h%d.dat",
prefixName,
lnp_par.globCFT,lnp_par.globH,lnp_par.loc_h);
//} else if(sec==((totalSimTime/1000)-2)){
} else if(sec % 2 == 0){
sprintf(fName, "%s-lasteven-C%d-H%d-h%d.dat",
prefixName,
lnp_par.globCFT,lnp_par.globH,lnp_par.loc_h);
} else {
sprintf(fName, "%s-lastodd-C%d-H%d-h%d.dat",
prefixName,
lnp_par.globCFT,lnp_par.globH,lnp_par.loc_h);
};
};
}
DPSNNverboseStart(false,1,0);
printf("openFile: %s at sec %d on loc_h %d\n",
fName, sec, lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
//3 because stdin, stdout, stderr are there
if( (totalStat_fopen + 3) <= DSD__FOPEN_MAX) {
fp = fopen(fName,"w");
if(fp == NULL) {printf("ERROR NULL fp\n"); fflush(stdout); exit(0);};
fopenStatus=true;
totalStat_fopen++;
if(totalStat_fopen > max_totalStat_fopen) {
max_totalStat_fopen = totalStat_fopen;
}
}else{
printf("ERROR too much fopen while opening %s DSD__FOPEN_MAX=%d\n",
fName,DSD__FOPEN_MAX);fflush(stdout);exit(0);
}
};
};
};
void statBasicClass::closeFile(const uint sec, const int moduloSec)
{
int status = 1;
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if(sec % moduloSec == 0) {
debugPrintStatStatus(sec, moduloSec);
test_prepCalled();
test_fopenStatus("closeFile", true, sec, moduloSec);
totalStat_fopen--;
#ifndef DALonlyEnvironmentSelected
if(totalStat_fopen<3) {
printf("ERROR totalStat_fopen < 3 in %s\n",prefixName);
fflush(stdout); exit(0);
};
#endif
status = fclose(fp);
DPSNNverboseStart(false,1,0);
printf("closeFile: %s \n",fName);
fflush(stdout);
DPSNNverboseEnd();
if(status!=0) { \
printf("ERROR fclose!=0 in stat_sfclose in %s\n",prefixName);
fflush(stdout); exit(0);
};
fopenStatus=false;
};
};
};
};
void statBasicClass::debugPrintStatStatus(const int sec, const int moduloSec)
{
DPSNNverboseStart(false,1,0);
printf("\n begin status report for statistic function\n");
printf("at sec=%d, moduloSec=%d writeDisable=%d, prepCalled=%d, fopenStatus=%d, ",
sec, moduloSec, writeDisable, prepCalled, fopenStatus);
if(prepCalled==true) {printf("prefixName=%s, ",prefixName);};
if(fopenStatus==true) {printf("fName=%s, ",fName);};
printf("\n end\n");
fflush(stdout);
DPSNNverboseEnd();
}
void statParametersClass::write(const uint32_t sec, const int moduloSec) {
int i;
FILE * locFp;
printf("statParameters.write called on lnp_par.loc_h=%03d\n", lnp_par.loc_h);
if(writeDisable==false) {
if(sec == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
for(i=0;i<2;i++) {
if(i==0) { locFp = stdout;
} else { locFp = fp;}
fprintf(locFp, "\n011- code rev : %s\n",lnp_par.codeRev); fflush(locFp);
fprintf(locFp, "012- neurons : %4d=globN %4d=locN %4d=globNe %4d=globNi\n",
lnp_par.globN, lnp_par.locN, lnp_par.globNe, lnp_par.globNi); fflush(locFp);
fprintf(locFp, "013- synapses : %4d=D %2.2f=M/D\n",
lnp_par.D, float(lnp_par.M)/float(lnp_par.D));fflush(locFp);
fprintf(locFp, "014- distribution : %4d=loc_h %4d=globH\n",
lnp_par.loc_h, lnp_par.globH);fflush(locFp);
fprintf(locFp, "016- programmed sim time: tot=%8d ms moduloSec=%3d\n",
lnp_par.totalSimTime_ms,lnp_par.moduloSec);fflush(locFp);
fprintf(locFp, "016a- start and stop SynPeriodicProbe_s: %d %d\n",
lnp_par.startSynPeriodicProbe_s, lnp_par.stopSynPeriodicProbe_s);fflush(locFp);
if(lnp_par.chrono==0) {
fprintf(locFp, "017- chrono performance : not active\n"); fflush(locFp);
} else if (lnp_par.chrono==1) {
fprintf(locFp, "017- chrono performance: ACTIVATED\n"); fflush(locFp);
} else { fprintf(locFp, "ERROR chrono env value unrecognized\n");
fflush(locFp);exit(0);};
};
};
};
};
double presentTime;
void statSpikingRatesClass::write(const uint32_t sec,
const int moduloSec,
const int N_firings,
const int N_thalamicInputs)
{
int writeCount;
double previousTime,deltaTime;
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
previousTime = presentTime;
presentTime = MPI_Wtime();
if (sec > 0)
deltaTime = presentTime - previousTime;
else
deltaTime = 0;
test_prepCalled();
test_fopenStatus("write",true, sec, moduloSec);
writeCount =
fprintf(fp,"sec=%d, firings=%06d, rates: tot %03.3f elapsedTime=%.3f sec\n",
sec, N_firings,float(N_firings)/float(lnp_par.locN),deltaTime);
fflush(fp);
if(writeCount<0) {
printf("ERROR fprintf returns negative in SpikingRates\n");
fflush(stdout);
exit(0);
};
};
};
};
void statSpikingRatesPerPopClass::write(const uint32_t sec,
const uint32_t milliSec,
const uint32_t moduloSec,
const uint32_t ratesSampling,
uint32_t *N_firingsPerPop,
const uint32_t *neuSubPopCount,
const uint32_t neuSubPopTotal)
{
int writeCount;
uint32_t subPop,subPopTot;
if(writeDisable==false) {
if( (sec >= lnp_par.startStatFiles_s) &&
(sec <= lnp_par.stopStatFiles_s ) ) {
if((sec % moduloSec) == 0) {
if ((sec >= lnp_par.startRatesPerPop_s)&&
(sec <= lnp_par.stopRatesPerPop_s) ) {
if((milliSec % ratesSampling) == 0) {
test_prepCalled();
test_fopenStatus("write",true,sec,moduloSec);
fprintf(fp,"%d ",milliSec-ratesSampling);
for(subPopTot=0; subPopTot<lnp_par.locCFT*neuSubPopTotal;
subPopTot+=neuSubPopTotal){
for(subPop=0;subPop<neuSubPopTotal;subPop++){
writeCount =
fprintf(fp,"%.7g ",((float)(N_firingsPerPop[subPopTot+subPop])*1000.0) /
((float)(neuSubPopCount[subPop])*(float)(ratesSampling)));
}
}
fprintf(fp," \n");
fflush(fp);
if(writeCount<0) {
printf("ERROR fprintf returns negative in SpikingRatesPerPop\n");
fflush(stdout);
exit(0);
}
//Clear array of firings per population for the next usage
for(uint32_t i=0;i<lnp_par.globCFT*neuSubPopTotal;i++)
N_firingsPerPop[i] = 0;
}
}
}
};
};
};
void statSpikesClass::write(const uint32_t sec, const int moduloSec,
const int N_firings,
const int thisMs,
const int *data,
const double *emissionTime)
{
int i;
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
for (i=0;i < N_firings;i++)
{
fprintf(fp, "%d %.7g\n", data[i], emissionTime[i]);
fflush(fp);
};
};
};
};
};
void statSpikeCountPerMsClass::write(const uint32_t sec, const int moduloSec,
const int thisMs,
const int numberOfSpikesInMs)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
fprintf(fp, "%07d %6d\n", thisMs, numberOfSpikesInMs);
fflush(fp);
};
};
};
};
void statThalamicInputClass::write(const uint32_t sec, const int moduloSec,
const int thisMs,
const int numberOfTargetNeu)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
fprintf(fp, "%07d %6d\n", thisMs, numberOfTargetNeu);
fflush(fp);
};
};
};
};
void statFloatEvery_msClass::write(const uint32_t sec, const int moduloSec,
const uint32_t t_ms,
const int neuron_id,
const float value)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
if( lnp_par.debugPrintEnable_ms == 0 ||
((t_ms >= lnp_par.debugPrintEnable_ms) &&
(t_ms <= (lnp_par.debugPrintEnable_ms + 20) )))
{
fprintf(fp, "%05d %03d %04d %03.2f\n",sec, t_ms, neuron_id, value);
fflush(fp);
};
};
};
};
};
void stat3FloatsEvery_msClass::write(const uint32_t sec, const int moduloSec,
const uint32_t t_ms,
const int neuron_id,
const float value0,
const float value1,
const float value2)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
if( lnp_par.debugPrintEnable_ms == 0 ||
((t_ms >= lnp_par.debugPrintEnable_ms) &&
(t_ms <= (lnp_par.debugPrintEnable_ms + 20) )))
{
fprintf(fp, "%05d %03u %04d %03.2f %03.2f %03.2f\n",
sec, t_ms%1000, neuron_id, value0, value1, value2);
fflush(fp);
};
};
};
};
};
void stat_LIFCAivu_Class::write(const uint32_t sec, const int moduloSec,
const uint32_t t_ms,
const double currentTime,
const int neuron_id,
const double value0,
const double value1,
const double value2)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
if( lnp_par.debugPrintEnable_ms == 0 ||
((t_ms >= lnp_par.debugPrintEnable_ms) &&
(t_ms <= (lnp_par.debugPrintEnable_ms + 20) )))
{
fprintf(fp, "%05u %03.9f %04d %03.7f %03.7f %03.7f \n",
sec, currentTime, neuron_id, value0, value1, value2);
fflush(fp);
};
};
};
};
void statSynClass::write(const uint32_t sec, const int moduloSec,
const int this_ms, const int synIndex,
const int preSynNeu, const int postSynNeu,
const int synDelay,
const float synWeight, const float synDeriv)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)) {
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
fprintf(fp,"%04d %04d %02d %2.4f %2.4f %05d %03d\n",
preSynNeu, postSynNeu,
synDelay, synWeight, synDeriv,
sec, this_ms % 1000);
fflush(fp);
};
};
};
};
void statSynPeriodicProbeClass::write(const uint32_t sec,
const int moduloSec,
const synapseClass synToBeReported)
{
instrumentedSynapse instrumentedSynapseDummy;
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)) {
if((sec % moduloSec) == 0) {
if ((sec >= lnp_par.startSynPeriodicProbe_s)&&
(sec <= lnp_par.stopSynPeriodicProbe_s) ){
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
instrumentedSynapseDummy.report(synToBeReported,fp,
lnp_par.locN,lnp_par.factorWeightType_2_Float);
fflush(fp);
};
};
};
};
};
void statSTDPeventClass::write(const uint32_t sec, const int moduloSec,
const uint32_t t_ms,
const int pre_glob_n, const int post_glob_n,
const float contribute)
{
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)) {
if((sec % moduloSec) == 0) {
if ((sec >= lnp_par.startSTDPevent_s)&&
(sec <= lnp_par.stopSTDPevent_s) ) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
if( lnp_par.debugPrintEnable_ms == 0 ||
((t_ms >= lnp_par.debugPrintEnable_ms) &&
(t_ms <= (lnp_par.debugPrintEnable_ms + 20) )))
{
fprintf(fp,"%8u %7d %7d %2.7f \n",
t_ms, pre_glob_n, post_glob_n, contribute);
fflush(fp);
};
};
};
};
};
};
void statMessageTrafficClass::write(const uint32_t sec, const int moduloSec,
const uint32_t t_ms, uint32_t *forwardAxonalSpikesCount)
{
uint32_t target_h;
if(writeDisable==false) {
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)) {
if((sec % moduloSec) == 0) {
test_prepCalled();
test_fopenStatus("write", true, sec, moduloSec);
if( lnp_par.debugPrintEnable_ms == 0 ||
((t_ms >= lnp_par.debugPrintEnable_ms) &&
(t_ms <= (lnp_par.debugPrintEnable_ms + 20) ))) {
fprintf(fp,"%04u",t_ms);
for(target_h=0;target_h<lnp_par.globH;target_h++)
fprintf(fp," %6d",forwardAxonalSpikesCount[target_h]);
fprintf(fp,"\n");
fflush(fp);
};
};
};
};
};
void statClass::prep(struct DPSNN_parameters lnp_par_initValue) {
lnp_par=lnp_par_initValue;
//printf("on this system DSD__FOPEN_MAX value is %d\n",DSD__FOPEN_MAX);
totalStat_fopen = 3; //stdin, stdout, stderr included
max_totalStat_fopen = totalStat_fopen;
fflush(stdout);
//set the set of active statistic collectors
spikes.writeDisable = lnp_par.spikes_writeDisable;
spikePerMs.writeDisable = true;
parameters.writeDisable = true;
DPSNNverboseStart(false,1,0);
if(lnp_par.globH <= 4) {
parameters.writeDisable = false;
};
DPSNNverboseEnd();
syn.writeDisable = true;
DPSNNverboseStart(false,1,0);
if(lnp_par.loc_h == 0) {
syn.writeDisable = false;
};
DPSNNverboseEnd();
spikingRates.writeDisable = true;
DPSNNverboseStart(false,1,0);
if(lnp_par.loc_h < 8 || (lnp_par.loc_h == (lnp_par.globH-1))) {
spikingRates.writeDisable = false;
};
DPSNNverboseEnd();
spikingRatesPerPop.writeDisable = lnp_par.statRatesPerPop_writeDisable;
thalamicInput.writeDisable = true;
inputCurrent.writeDisable = true;
ivu0.writeDisable = true;
ivu1.writeDisable = true;
ivu2.writeDisable = true;
ivu999.writeDisable = true;
statSTDPevent.writeDisable = true;
DPSNNverboseStart(true,1,0);
if(lnp_par.loc_h == 0) {
statSTDPevent.writeDisable =lnp_par.statSTDPevent_writeDisable;
};
DPSNNverboseEnd();
statSynPeriodicProbeA.writeDisable = true;
statSynPeriodicProbeB.writeDisable = true;
DPSNNverboseStart(true,1,0);
if(lnp_par.loc_h == 0) {
statSynPeriodicProbeA.writeDisable =
lnp_par.statSynPeriodicProbe_writeDisable;
statSynPeriodicProbeB.writeDisable =
lnp_par.statSynPeriodicProbe_writeDisable;
};
DPSNNverboseEnd();
LIFCAivu0.writeDisable = true;
LIFCAivu1.writeDisable = true;
LIFCAivu2.writeDisable = true;
LIFCAivu999.writeDisable = true;
messageTraffic.writeDisable = true;
//and calls the statistic preparation functions
//if writeDisable==true nothing is done
parameters.prep(lnp_par,"params");
spikingRates.prep(lnp_par,"rates");
spikingRatesPerPop.prep(lnp_par,"ratesPerPop");
spikes.prep(lnp_par,"spikes");
spikePerMs.prep(lnp_par,"spikePerMs");
thalamicInput.prep(lnp_par,"thalInput");
inputCurrent.prep(lnp_par,"inputCurrent");
ivu0.prep(lnp_par,"ivu0");
ivu1.prep(lnp_par,"ivu1");
ivu2.prep(lnp_par,"ivu2");
ivu999.prep(lnp_par,"ivu999");
syn.prep(lnp_par,"syn");
statSTDPevent.prep(lnp_par,"STDPevent");
statSynPeriodicProbeA.prep(lnp_par, "synPeriodicProbe_A");
statSynPeriodicProbeB.prep(lnp_par, "synPeriodicProbe_B");
LIFCAivu0.prep(lnp_par,"LIFCAivu0");
LIFCAivu1.prep(lnp_par,"LIFCAivu1");
LIFCAivu2.prep(lnp_par,"LIFCAivu2");
LIFCAivu999.prep(lnp_par,"LIFCAivu999");
messageTraffic.prep(lnp_par,"messageTraffic");
};
void statClass::openFiles_forThisSecond(const uint32_t sec, const int moduloSec) {
currentStat_sec=sec;
//where writeDisable is set in statClass:prep()
//nothing is done
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec)==0) {
DPSNNverboseStart(false,1,0);
printf(
"openFiles_forThisSecond at sec=%d moduloSec=%d START on loc_h=%d\n",
sec,moduloSec,lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
if(spikes.writeDisable == false)
spikes.openFile(sec,moduloSec);
if(spikePerMs.writeDisable == false)
spikePerMs.openFile(sec,moduloSec);
if ((sec >= lnp_par.startRatesPerPop_s)&&
(sec <= lnp_par.stopRatesPerPop_s) ) {
if(spikingRatesPerPop.writeDisable == false)
spikingRatesPerPop.openFile(sec,moduloSec);
};
if(thalamicInput.writeDisable == false)
thalamicInput.openFile(sec,moduloSec);
if(inputCurrent.writeDisable == false)
inputCurrent.openFile(sec,moduloSec);
if(ivu0.writeDisable == false)
ivu0.openFile(sec,moduloSec);
if(ivu1.writeDisable == false)
ivu1.openFile(sec,moduloSec);
if(ivu2.writeDisable == false)
ivu2.openFile(sec,moduloSec);
if(ivu999.writeDisable == false)
ivu999.openFile(sec,moduloSec);
if(syn.writeDisable == false)
syn.openFile(sec,moduloSec);
if ((sec >= lnp_par.startSTDPevent_s)&&
(sec <= lnp_par.stopSTDPevent_s) ) {
if(statSTDPevent.writeDisable == false)
statSTDPevent.openFile(sec,moduloSec);
};
if ((sec >= lnp_par.startSynPeriodicProbe_s)&&
(sec <= lnp_par.stopSynPeriodicProbe_s) ) {
if(statSynPeriodicProbeA.writeDisable == false)
statSynPeriodicProbeA.openFile(sec,moduloSec);
if(statSynPeriodicProbeB.writeDisable == false)
statSynPeriodicProbeB.openFile(sec,moduloSec);
};
if(LIFCAivu0.writeDisable == false)
LIFCAivu0.openFile(sec,moduloSec);
if(LIFCAivu1.writeDisable == false)
LIFCAivu1.openFile(sec,moduloSec);
if(LIFCAivu2.writeDisable == false)
LIFCAivu2.openFile(sec,moduloSec);
if(LIFCAivu999.writeDisable == false)
LIFCAivu999.openFile(sec,moduloSec);
if(messageTraffic.writeDisable == false)
messageTraffic.openFile(sec,moduloSec);
DPSNNverboseStart(false,1,0);
printf(
"openFiles_forThisSecond at sec=%d moduloSec=%d END on loc_h=%d\n",
sec,moduloSec,lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
};
};
};
void statClass::closeFiles_forThisSecond(const uint32_t sec, const int moduloSec) {
if(currentStat_sec != sec) {
printf("ERROR statClass::closeFiles_forThisSecond sec%d!=currentStat_sec%d\n",
currentStat_sec,sec); fflush(stdout);exit(0);}
DPSNNverboseStart(false,1,0);
printf("closeFiles_forThisSecond at sec=%d START on loc_h=%d\n",
sec,lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
//where writeDisable is set in statClass:prep()
//nothing is done
if ((sec >= lnp_par.startStatFiles_s)&&
(sec <= lnp_par.stopStatFiles_s)){
if((sec % moduloSec)==0) {
if(spikes.writeDisable == false)
spikes.closeFile(sec,moduloSec);
if(spikePerMs.writeDisable == false)
spikePerMs.closeFile(sec,moduloSec);
if ((sec >= lnp_par.startRatesPerPop_s)&&
(sec <= lnp_par.stopRatesPerPop_s) ) {
if(spikingRatesPerPop.writeDisable == false)
spikingRatesPerPop.closeFile(sec,moduloSec);
};
if(thalamicInput.writeDisable == false)
thalamicInput.closeFile(sec,moduloSec);
if(inputCurrent.writeDisable == false)
inputCurrent.closeFile(sec,moduloSec);
if(ivu0.writeDisable == false)
ivu0.closeFile(sec,moduloSec);
if(ivu1.writeDisable == false)
ivu1.closeFile(sec,moduloSec);
if(ivu2.writeDisable == false)
ivu2.closeFile(sec,moduloSec);
if(ivu999.writeDisable == false)
ivu999.closeFile(sec,moduloSec);
if(syn.writeDisable == false)
syn.closeFile(sec,moduloSec);
if ((sec >= lnp_par.startSTDPevent_s)&&
(sec <= lnp_par.stopSTDPevent_s) ) {
if(statSTDPevent.writeDisable == false)
statSTDPevent.closeFile(sec,moduloSec);
};
if ((sec >= lnp_par.startSynPeriodicProbe_s)&&
(sec <= lnp_par.stopSynPeriodicProbe_s) ) {
if(statSynPeriodicProbeA.writeDisable == false)
statSynPeriodicProbeA.closeFile(sec,moduloSec);
if(statSynPeriodicProbeB.writeDisable == false)
statSynPeriodicProbeB.closeFile(sec,moduloSec);
};
if(LIFCAivu0.writeDisable == false)
LIFCAivu0.closeFile(sec,moduloSec);
if(LIFCAivu1.writeDisable == false)
LIFCAivu1.closeFile(sec,moduloSec);
if(LIFCAivu2.writeDisable == false)
LIFCAivu2.closeFile(sec,moduloSec);
if(LIFCAivu999.writeDisable == false)
LIFCAivu999.closeFile(sec,moduloSec);
if(messageTraffic.writeDisable == false)
messageTraffic.closeFile(sec,moduloSec);
}
}
DPSNNverboseStart(false,1,0);
printf("closeFiles_forThisSecond at sec=%d DONE on loc_h=%d\n",
sec, lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
};
void statClass::check_fileClosure(const int sec, const int moduloSec) {
DPSNNverboseStart(false,1,0);
printf("checking file closure max_totalStat_fopen = %d should be 3 on loc_h=%d\n",
max_totalStat_fopen,lnp_par.loc_h);
fflush(stdout);
DPSNNverboseEnd();
DPSNNverboseStart(true,1,0);
if(totalStat_fopen != 3) {
printf("ERROR in stat check_fclose totalStat_fopen!=3 at %d sec %d moduloSec\n",sec, moduloSec);
fflush(stdout); exit(0); };
DPSNNverboseEnd();
};