7 #include <fmt/format.h>
16 return {nodes, mechanisms};
24 for (
const auto&
t:
model.thread) {
29 for (
const auto& m:
model.mechanism) {
33 for (
const auto& pd: m.pdata) {
38 for (
const auto& pdd: m.pdata_hack) {
55 size_t per_element_size) {
57 size_t size =
v->size() * (
sizeof(T) + per_element_size);
58 size_t capacity = size + (
v->capacity() -
v->size()) *
sizeof(T);
60 return {size, capacity};
80 static std::vector<std::string> suffixes{
" ",
" kB",
" MB",
" GB",
" TB",
" PB"};
84 auto suffix = suffixes[suffix_id];
86 double value = double(bytes) /
std::pow(10.0, suffix_id * 3.0);
90 snprintf(formatted,
sizeof(formatted),
"% 6ld", bytes);
92 snprintf(formatted,
sizeof(formatted),
"%6.2f",
value);
109 std::stringstream os;
111 os <<
" size capacity \n";
116 os <<
" mechanisms \n";
120 os <<
"cache::Model \n";
123 os <<
"deferred deletion \n";
129 os <<
" required " <<
format_memory(summary.required) <<
"\n";
130 os <<
" convenient " <<
format_memory(summary.convenient) <<
"\n";
131 os <<
" oversized " <<
format_memory(summary.oversized) <<
"\n";
147 hoc_execerror(
"print_local_memory_usage doesn't support any arguments.",
nullptr);
void hoc_retpushx(double x)
static const char * mechanism[]
void hoc_execerror(const char *s1, const char *s2)
std::optional< Model > model
std::vector< void * > * defer_delete_storage
Defer deleting pointers to deallocated memory.
VectorMemoryUsage compute_defer_delete_storage_size()
void print_memory_usage(const MemoryUsage &usage)
MemoryUsage local_memory_usage()
Gather memory usage of this process.
std::string format_memory_usage(const VectorMemoryUsage &memory_usage)
Aligned, human readable representation of memory_usage.
std::string format_memory(size_t bytes)
Utility to format memory as a human readable string.
cache::ModelMemoryUsage memory_usage(const std::optional< neuron::cache::Model > &model)
Model & model()
Access the global Model instance.
void print_local_memory_usage()
HOC interpreter function declarations (included by hocdec.h)
void apply_to_mechanisms(Callable const &callable)
Apply a function to each non-null Mechanism.
container::Node::storage & node_data()
Access the structure containing the data of all Nodes.
Overall SoA datastructures related memory usage.
VectorMemoryUsage compute_total() const
cache::ModelMemoryUsage cache_model
VectorMemoryUsage stable_pointers
Memory usage of a neuron::Model.
Memory usage of a storage/soa container.
Size and capacity in bytes.
Memory usage of a neuron::cache::Model.
int Printf(const char *fmt, Args... args)