Loading [MathJax]/jax/input/TeX/config.js
CoreNEURON
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mech_report.cpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================
7 */
8 
9 #include <iostream>
10 #include <vector>
11 
14 #include "coreneuron/mpi/nrnmpi.h"
16 
17 namespace coreneuron {
18 /** display global mechanism count */
20  /// mechanim count across all gids, local to rank
21  const auto n_memb_func = corenrn.get_memb_funcs().size();
22  std::vector<long> local_mech_count(n_memb_func, 0);
23  std::vector<long> local_mech_size(n_memb_func, 0);
24 
25  /// each gid record goes on separate row, only check non-empty threads
26  for (int i = 0; i < nrn_nthread; i++) {
27  const auto& nt = nrn_threads[i];
28  for (auto* tml = nt.tml; tml; tml = tml->next) {
29  const int type = tml->index;
30  const auto& ml = tml->ml;
31  local_mech_count[type] += ml->nodecount;
32  local_mech_size[type] = memb_list_size(tml, true);
33  }
34  }
35 
36  std::vector<long> total_mech_count(n_memb_func);
37  std::vector<long> total_mech_size(n_memb_func);
38 
39 #if NRNMPI
41  /// get global sum of all mechanism instances
42  nrnmpi_long_allreduce_vec(&local_mech_count[0],
43  &total_mech_count[0],
44  local_mech_count.size(),
45  1);
46  nrnmpi_long_allreduce_vec(&local_mech_size[0],
47  &total_mech_size[0],
48  local_mech_size.size(),
49  1);
50  } else
51 #endif
52  {
53  total_mech_count = local_mech_count;
54  total_mech_size = local_mech_size;
55  }
56 
57  /// print global stats to stdout
58  if (nrnmpi_myid == 0) {
59  printf("\n============== MECHANISMS COUNT AND SIZE BY TYPE =============\n");
60  printf("%4s %20s %10s %25s\n", "Id", "Name", "Count", "Total memory size (KiB)");
61  for (size_t i = 0; i < total_mech_count.size(); i++) {
62  if (total_mech_count[i] > 0) {
63  printf("%4lu %20s %10ld %25.2lf\n",
64  i,
66  total_mech_count[i],
67  static_cast<double>(total_mech_size[i]) / 1024);
68  }
69  }
70  printf("==============================================================\n");
71  }
72 }
73 
74 } // namespace coreneuron
coreneuron::nrn_nthread
int nrn_nthread
Definition: multicore.cpp:55
coreneuron::write_mech_report
void write_mech_report()
display global mechanism count
Definition: mech_report.cpp:19
coreneuron.hpp
coreneuron::nrnmpi_long_allreduce_vec
mpi_function< cnrn_make_integral_constant_t(nrnmpi_long_allreduce_vec_impl)> nrnmpi_long_allreduce_vec
Definition: nrnmpidec.cpp:49
coreneuron
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
Definition: corenrn_parameters.cpp:12
corenrn_parameters.hpp
coreneuron::i
int i
Definition: cellorder.cpp:485
nrn_setup.hpp
coreneuron::CoreNeuron::get_memb_funcs
auto & get_memb_funcs()
Definition: coreneuron.hpp:134
coreneuron::corenrn_param
corenrn_parameters corenrn_param
Printing method.
Definition: corenrn_parameters.cpp:268
coreneuron::memb_list_size
size_t memb_list_size(NrnThreadMembList *tml, bool include_data)
Definition: nrn_setup.cpp:989
coreneuron::nrn_threads
NrnThread * nrn_threads
Definition: multicore.cpp:56
coreneuron::corenrn
CoreNeuron corenrn
Definition: multicore.cpp:53
coreneuron::nrn_get_mechname
const char * nrn_get_mechname(int type)
Definition: mk_mech.cpp:145
coreneuron::corenrn_parameters_data::mpi_enable
bool mpi_enable
Initialization seed for random number generator (int)
Definition: corenrn_parameters.hpp:59
coreneuron::nrnmpi_myid
int nrnmpi_myid
Definition: nrnmpi_def_cinc.cpp:11
nrnmpi.h