#ifndef iAN34Y9CxgHgVUyhhdYpI8Ynza8 #define iAN34Y9CxgHgVUyhhdYpI8Ynza8 #include #include #include #include #include "checkpoint.hpp" #include "index_spike.hpp" #include "property_instance.hpp" #include "simlimits.hpp" #include "template_helpers.hpp" namespace PLA_Debug_Space_Impl { template struct PLA_Debug_Space_Quant2Num; // PLA template struct PLA_Debug_Space { // action types & consts typedef Void result_t; template 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 inline void pre(_PropList &pc, _ContextData &data, LocalState &state) { int id = PLA_Debug_Space_Quant2Num::eval(); num[id] += 1; size[id] += LocalState::prop::size; if (!LocalState::write) { numRead[id] += 1; sizeRead[id] += LocalState::prop::size; } } template inline void post(PropComp &pc, Data &data, _LocalState &state) { } }; PLA_Debug_Space::PLA_Debug_Space() { for (int i=0; i::ptr_t) + sizeof(Time) * (num[cNeuron] + 1)) * maxNeurons // addend 2 and 4 account for Index::prevCache + (size[cSynapse] + sizeof(Time) * num[cSynapse]) * maxNeurons * maxSynapsesPerNeuron; pt /= chkpt_delta; ps = maxNeurons * (2*sizeof(Index::ptr_t) + sizeof(Index::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 { static int eval() { return PLA_Debug_Space::cGlobal; } }; template <> struct PLA_Debug_Space_Quant2Num { static int eval() { return PLA_Debug_Space::cNeuron; } }; template <> struct PLA_Debug_Space_Quant2Num { static int eval() { return PLA_Debug_Space::cSynapse; } }; template <> struct PLA_Debug_Space_Quant2Num { static int eval() { return PLA_Debug_Space::cGlobalMsg; } }; template <> struct PLA_Debug_Space_Quant2Num { static int eval() { return PLA_Debug_Space::cSpike; } }; template <> struct PLA_Debug_Space_Quant2Num { static int eval() { return PLA_Debug_Space::cSpikeArrival; } }; } // NS using PLA_Debug_Space_Impl::PLA_Debug_Space; #endif // iAN34Y9CxgHgVUyhhdYpI8Ynza8