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
|
#ifndef iAN34Y9CxgHgVUyhhdYpI8Ynza8
#define iAN34Y9CxgHgVUyhhdYpI8Ynza8
#include <iostream>
#include <sstream>
#include <string>
#include <boost/type_traits/is_same.hpp>
#include "checkpoint.hpp"
#include "index_spike.hpp"
#include "property_instance.hpp"
#include "simlimits.hpp"
#include "template_helpers.hpp"
namespace PLA_Debug_Space_Impl {
template <class Quant>
struct PLA_Debug_Space_Quant2Num;
// PLA template
struct PLA_Debug_Space {
// action types & consts
typedef Void result_t;
template<typename _ContextProp, bool doWriteResults> struct local_state_t {
typedef _ContextProp prop;
static const bool write = doWriteResults;
};
// action state
result_t result;
// tmp type const; to do: change to quant::runtimeID
static const int cGlobal = 0;
static const int cNeuron = 1;
static const int cSynapse = 2;
static const int cGlobalMsg = 3;
static const int cSpike = 4;
static const int cSpikeArrival = 5;
static const int propCount = 6;
// result storage
// * set by action methods
int num[propCount],
numRead[propCount],
size[propCount],
sizeRead[propCount];
// * set by generateReport()
int totalNum,
totalNumRead,
totalSize;
// methods
PLA_Debug_Space();
std::string generateReport();
// action methods
template<typename _PropList, typename _ContextData, typename LocalState>
inline void pre(_PropList &pc, _ContextData &data, LocalState &state) {
int id = PLA_Debug_Space_Quant2Num<typename LocalState::prop::quant>::eval();
num[id] += 1;
size[id] += LocalState::prop::size;
if (!LocalState::write) {
numRead[id] += 1;
sizeRead[id] += LocalState::prop::size;
}
}
template<typename PropComp, typename Data, typename _LocalState>
inline void post(PropComp &pc, Data &data, _LocalState &state) { }
};
PLA_Debug_Space::PLA_Debug_Space() {
for (int i=0; i<propCount; i++) {
num[i] = 0;
numRead[i] = 0;
size[i] = 0;
sizeRead[i] = 0;
}
}
using namespace std;
string PLA_Debug_Space::generateReport() {
ostringstream &result = *(new ostringstream());
double chkpt_delta = checkpointInterval;
result
<< "Simulation\n"
<< "==========\n\n"
<<"neurons:\t" << maxNeurons << "\n"
<< "synapses:\t" << maxSynapsesPerNeuron * maxNeurons << "\t(" << (int) maxSynapsesPerNeuron << " per neuron)\n"
<< "\n"
<< "max. # spikes:\t\t" << maxSpikes << "\n"
<< "max. # global messages:\t" << maxGlobalMsg << "\n"
<< "max. # checkpojts:\t" << maxCheckpoints << "\n"
<< "checkpoint every\t" << chkpt_delta << " s\n"
<< "\n"
<< "max. run-time:\n"
<< "\t" << min( chkpt_delta * maxCheckpoints, (double) maxSpikes / maxNeurons / 1.0 ) << " s \t@ 1 Hz\n"
<< "\t" << min( chkpt_delta * maxCheckpoints, (double) maxSpikes / maxNeurons / 10.0 ) << " s \t@ 10 Hz\n"
<< "\t" << min( chkpt_delta * maxCheckpoints, (double) maxSpikes / maxNeurons / 100.0 ) << " s \t@ 100 Hz\n"
<< "\n\n";
totalNum = 0;
totalSize = 0;
for (int i=0; i<propCount; i++) {
totalNum += num[i];
totalSize += size[i];
}
result
<< "Properties\n"
<< "==========\n\n"
<< "| Quantor\t| # of \t| size (per\t| size (all \t|\n"
<< "| \t| props\t| instance)\t| instances)\t|\n"
<< "+---------------+-------+---------------+---------------+\n"
<< "| Global \t| " << num[cGlobal] << "\t| " << size[cGlobal] << "\t\t| " << size[cGlobal] << "\t\t|\n"
<< "| Neuron \t| " << num[cNeuron] << "\t| " << size[cNeuron] << "\t\t| " << maxNeurons * size[cNeuron] << "\t\t|\n"
<< "| Synapse \t| " << num[cSynapse] << "\t| " << size[cSynapse] << "\t\t| " << maxNeurons * maxSynapsesPerNeuron * size[cSynapse] << "\t|\n"
<< "| GlobalMsg \t| " << num[cGlobalMsg] << "\t| " << size[cGlobalMsg] << "\t\t| - \t|\n"
<< "| Spike \t| " << num[cSpike] << "\t| " << size[cSpike] << "\t\t| - \t|\n"
<< "| SpikeArrival \t| " << num[cSpikeArrival] << "\t| " << size[cSpikeArrival] << "\t\t| - \t|\n"
<< "+---------------+-------+---------------+---------------+\n"
<< "| Total \t| " << totalNum << "\t| " << totalSize << "\t\t| - \t|\n"
<< "\n\n";
double pt, ps; // per time / spike space requirement
pt = size[cGlobal] + sizeof(Time) * num[cGlobal]
+ (size[cNeuron] + sizeof(Index<Spike>::ptr_t) + sizeof(Time) * (num[cNeuron] + 1)) * maxNeurons // addend 2 and 4 account for Index<Spike>::prevCache
+ (size[cSynapse] + sizeof(Time) * num[cSynapse]) * maxNeurons * maxSynapsesPerNeuron;
pt /= chkpt_delta;
ps = maxNeurons * (2*sizeof(Index<Spike>::ptr_t) + sizeof(Index<Spike>::neuron_ptr_t) + size[cNeuron] + maxSynapsesPerNeuron * size[cSpikeArrival]);
result
<< "Space Requirements\n"
<< "==================\n\n"
<< "These are strict minimum numbers. Global messages, additional managment information (in-app and in-kernel) and many small vars have not been taken into account.\n\n"
<< "\t: 1 s\t\t| 1 h\t\t| 1 d\t\t|\n"
<< "--------+---------------+---------------+---------------+\n"
<< " 1 Hz\t: " << SISuffixify(1 * ( 1 * ps + pt), 1024) << "B\t| " << SISuffixify(3600 * ( 1 * ps + pt), 1024) << "B\t| " << SISuffixify(86400 * ( 1 * ps + pt), 1024) << "B\t|\n"
<< " 10 Hz\t: " << SISuffixify(1 * ( 10 * ps + pt), 1024) << "B\t| " << SISuffixify(3600 * ( 10 * ps + pt), 1024) << "B\t| " << SISuffixify(86400 * ( 10 * ps + pt), 1024) << "B\t|\n"
<< " 100 Hz\t: " << SISuffixify(1 * (100 * ps + pt), 1024) << "B\t| " << SISuffixify(3600 * (100 * ps + pt), 1024) << "B\t| " << SISuffixify(86400 * (100 * ps + pt), 1024) << "B\t|\n"
<< "";
return result.str();
}
// PLA_Debug_Space_Quant2Num implementation
// TODO: overhaul
template <> struct PLA_Debug_Space_Quant2Num<Global> { static int eval() { return PLA_Debug_Space::cGlobal; } };
template <> struct PLA_Debug_Space_Quant2Num<Neuron> { static int eval() { return PLA_Debug_Space::cNeuron; } };
template <> struct PLA_Debug_Space_Quant2Num<Synapse> { static int eval() { return PLA_Debug_Space::cSynapse; } };
template <> struct PLA_Debug_Space_Quant2Num<GlobalMsg> { static int eval() { return PLA_Debug_Space::cGlobalMsg; } };
template <> struct PLA_Debug_Space_Quant2Num<Spike> { static int eval() { return PLA_Debug_Space::cSpike; } };
template <> struct PLA_Debug_Space_Quant2Num<SpikeArrival> { static int eval() { return PLA_Debug_Space::cSpikeArrival; } };
} // NS
using PLA_Debug_Space_Impl::PLA_Debug_Space;
#endif // iAN34Y9CxgHgVUyhhdYpI8Ynza8
|