Skip to content
Snippets Groups Projects
Commit c2adfeb4 authored by Sam Yates's avatar Sam Yates Committed by GitHub
Browse files

Merge pull request #59 from bcumming/profiler

reduce verbosity of profiler instrumentation
parents cf33c0d2 1477e9b2
No related branches found
No related tags found
No related merge requests found
...@@ -43,29 +43,29 @@ struct model { ...@@ -43,29 +43,29 @@ struct model {
mc::threading::parallel_for::apply( mc::threading::parallel_for::apply(
0, num_groups(), 0, num_groups(),
[&](int i) { [&](int i) {
mc::util::profiler_enter("stepping","events"); PE("stepping","events");
cell_groups[i].enqueue_events(communicator.queue(i)); cell_groups[i].enqueue_events(communicator.queue(i));
mc::util::profiler_leave(); PL();
cell_groups[i].advance(std::min(t+delta, tfinal), dt); cell_groups[i].advance(std::min(t+delta, tfinal), dt);
mc::util::profiler_enter("events"); PE("events");
communicator.add_spikes(cell_groups[i].spikes()); communicator.add_spikes(cell_groups[i].spikes());
cell_groups[i].clear_spikes(); cell_groups[i].clear_spikes();
mc::util::profiler_leave(2); PL(2);
} }
); );
mc::util::profiler_enter("stepping", "exchange"); PE("stepping", "exchange");
communicator.exchange(); communicator.exchange();
mc::util::profiler_leave(2); PL(2);
t += delta; t += delta;
} }
} }
void init_communicator() { void init_communicator() {
mc::util::profiler_enter("setup", "communicator"); PE("setup", "communicator");
// calculate the source and synapse distribution serially // calculate the source and synapse distribution serially
std::vector<id_type> target_counts(num_groups()); std::vector<id_type> target_counts(num_groups());
...@@ -81,11 +81,11 @@ struct model { ...@@ -81,11 +81,11 @@ struct model {
// create connections // create connections
communicator = communicator_type(num_groups(), target_counts); communicator = communicator_type(num_groups(), target_counts);
mc::util::profiler_leave(2); PL(2);
} }
void update_gids() { void update_gids() {
mc::util::profiler_enter("setup", "globalize"); PE("setup", "globalize");
auto com_policy = communicator.communication_policy(); auto com_policy = communicator.communication_policy();
auto global_source_map = com_policy.make_map(source_map.back()); auto global_source_map = com_policy.make_map(source_map.back());
auto domain_idx = communicator.domain_id(); auto domain_idx = communicator.domain_id();
...@@ -97,7 +97,7 @@ struct model { ...@@ -97,7 +97,7 @@ struct model {
target_map[i]+communicator.target_gid_from_group_lid(0) target_map[i]+communicator.target_gid_from_group_lid(0)
); );
} }
mc::util::profiler_leave(2); PL(2);
} }
// TODO : only stored here because init_communicator() and update_gids() are split // TODO : only stored here because init_communicator() and update_gids() are split
...@@ -296,9 +296,9 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) { ...@@ -296,9 +296,9 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) {
mc::threading::parallel_for::apply( mc::threading::parallel_for::apply(
0, ncell_local, 0, ncell_local,
[&](int i) { [&](int i) {
mc::util::profiler_enter("setup", "cells"); PE("setup", "cells");
m.cell_groups[i] = make_lowered_cell(i, basic_cell); m.cell_groups[i] = make_lowered_cell(i, basic_cell);
mc::util::profiler_leave(2); PL(2);
} }
); );
...@@ -307,7 +307,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) { ...@@ -307,7 +307,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) {
// //
m.init_communicator(); m.init_communicator();
mc::util::profiler_enter("setup", "connections"); PE("setup", "connections");
// RNG distributions for connection delays and source cell ids // RNG distributions for connection delays and source cell ids
auto weight_distribution = std::exponential_distribution<float>(0.75); auto weight_distribution = std::exponential_distribution<float>(0.75);
...@@ -351,8 +351,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) { ...@@ -351,8 +351,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) {
// setup probes // setup probes
// //
mc::util::profiler_leave(); PL(); PE("probes");
mc::util::profiler_enter("probes");
// monitor soma and dendrite on a few cells // monitor soma and dendrite on a few cells
float sample_dt = 0.1; float sample_dt = 0.1;
...@@ -378,7 +377,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) { ...@@ -378,7 +377,7 @@ void all_to_all_model(nest::mc::io::cl_options& options, model& m) {
); );
} }
mc::util::profiler_leave(2); PL(2);
} }
/////////////////////////////////////// ///////////////////////////////////////
......
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
// take any pending samples // take any pending samples
float cell_time = cell_.time(); float cell_time = cell_.time();
nest::mc::util::profiler_enter("sampling"); PE("sampling");
while (auto m = sample_events_.pop_if_before(cell_time)) { while (auto m = sample_events_.pop_if_before(cell_time)) {
auto& sampler = samplers_[m->sampler_index]; auto& sampler = samplers_[m->sampler_index];
EXPECTS((bool)sampler.sample); EXPECTS((bool)sampler.sample);
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
sample_events_.push(*m); sample_events_.push(*m);
} }
} }
nest::mc::util::profiler_leave(); PL();
// look for events in the next time step // look for events in the next time step
auto tstep = std::min(tfinal, cell_.time()+dt); auto tstep = std::min(tfinal, cell_.time()+dt);
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
std::cerr << "warning: solution out of bounds\n"; std::cerr << "warning: solution out of bounds\n";
} }
nest::mc::util::profiler_enter("events"); PE("events");
// check for new spikes // check for new spikes
for (auto& s : spike_sources_) { for (auto& s : spike_sources_) {
if (auto spike = s.source.test(cell_, cell_.time())) { if (auto spike = s.source.test(cell_, cell_.time())) {
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
cell_.apply_event(e.get()); cell_.apply_event(e.get());
} }
} }
nest::mc::util::profiler_leave(); PL();
} }
} }
......
...@@ -513,15 +513,15 @@ void fvm_cell<T, I>::advance(T dt) ...@@ -513,15 +513,15 @@ void fvm_cell<T, I>::advance(T dt)
{ {
using memory::all; using memory::all;
mc::util::profiler_enter("current"); PE("current");
current_(all) = 0.; current_(all) = 0.;
// update currents from ion channels // update currents from ion channels
for(auto& m : mechanisms_) { for(auto& m : mechanisms_) {
mc::util::profiler_enter(m->name().c_str()); PE(m->name().c_str());
m->set_params(t_, dt); m->set_params(t_, dt);
m->nrn_current(); m->nrn_current();
mc::util::profiler_leave(); PL();
} }
// add current contributions from stimulii // add current contributions from stimulii
...@@ -532,25 +532,25 @@ void fvm_cell<T, I>::advance(T dt) ...@@ -532,25 +532,25 @@ void fvm_cell<T, I>::advance(T dt)
// the factor of 100 scales the injected current to 10^2.nA // the factor of 100 scales the injected current to 10^2.nA
current_[loc] -= 100.*ie/cv_areas_[loc]; current_[loc] -= 100.*ie/cv_areas_[loc];
} }
mc::util::profiler_leave(); PL();
mc::util::profiler_enter("matrix", "setup"); PE("matrix", "setup");
// solve the linear system // solve the linear system
setup_matrix(dt); setup_matrix(dt);
mc::util::profiler_leave(); mc::util::profiler_enter("solve"); PL(); PE("solve");
matrix_.solve(); matrix_.solve();
mc::util::profiler_leave(); PL();
voltage_(all) = matrix_.rhs(); voltage_(all) = matrix_.rhs();
mc::util::profiler_leave(); PL();
mc::util::profiler_enter("state"); PE("state");
// integrate state of gating variables etc. // integrate state of gating variables etc.
for(auto& m : mechanisms_) { for(auto& m : mechanisms_) {
mc::util::profiler_enter(m->name().c_str()); PE(m->name().c_str());
m->nrn_state(); m->nrn_state();
mc::util::profiler_leave(); PL();
} }
mc::util::profiler_leave(); PL();
t_ += dt; t_ += dt;
} }
......
...@@ -226,6 +226,7 @@ void profiler_enter(const char* n, Args... args) { ...@@ -226,6 +226,7 @@ void profiler_enter(const char* n, Args... args) {
/// move up one level in the profiler /// move up one level in the profiler
void profiler_leave(); void profiler_leave();
/// move up multiple profiler levels in one call /// move up multiple profiler levels in one call
void profiler_leave(int nlevels); void profiler_leave(int nlevels);
...@@ -238,3 +239,8 @@ void profiler_output(double threshold); ...@@ -238,3 +239,8 @@ void profiler_output(double threshold);
} // namespace util } // namespace util
} // namespace mc } // namespace mc
} // namespace nest } // namespace nest
// define some helper macros to make instrumentation of the source code with calls
// to the profiler a little less visually distracting
#define PE nest::mc::util::profiler_enter
#define PL nest::mc::util::profiler_leave
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment