summaryrefslogtreecommitdiff
path: root/core/pla_debug_space.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/pla_debug_space.hpp')
-rw-r--r--core/pla_debug_space.hpp172
1 files changed, 172 insertions, 0 deletions
diff --git a/core/pla_debug_space.hpp b/core/pla_debug_space.hpp
new file mode 100644
index 0000000..361f3d5
--- /dev/null
+++ b/core/pla_debug_space.hpp
@@ -0,0 +1,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
contact: Jan Huwald // Impressum