Skip to content

Commit

Permalink
replace '_' with ':' for profiler subsections
Browse files Browse the repository at this point in the history
  • Loading branch information
noraabiakar committed Oct 11, 2021
1 parent 10af578 commit 5a49cca
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion arbor/benchmark_cell_group.cpp
Expand Up @@ -61,7 +61,7 @@ void benchmark_cell_group::advance(epoch ep,
using std::chrono::high_resolution_clock;
using duration_type = std::chrono::duration<double, std::micro>;

PE(advance_bench_cell);
PE(advance:bench:cell);
// Micro-seconds to advance in this epoch.
auto us = 1e3*(ep.duration());
for (auto i: util::make_span(0, gids_.size())) {
Expand Down
4 changes: 2 additions & 2 deletions arbor/communication/communicator.cpp
Expand Up @@ -139,12 +139,12 @@ time_type communicator::min_delay() {
}

gathered_vector<spike> communicator::exchange(std::vector<spike> local_spikes) {
PE(communication_exchange_sort);
PE(communication:exchange:sort);
// sort the spikes in ascending order of source gid
util::sort_by(local_spikes, [](spike s){return s.source;});
PL();

PE(communication_exchange_gather);
PE(communication:exchange:gather);
// global all-to-all to gather a local copy of the global spike list on each node.
auto global_spikes = distributed_->gather_spikes(local_spikes);
num_spikes_ += global_spikes.size();
Expand Down
26 changes: 13 additions & 13 deletions arbor/fvm_lowered_cell_impl.hpp
Expand Up @@ -205,7 +205,7 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(
set_gpu();

// Integration setup
PE(advance_integrate_setup);
PE(advance:integrate:setup);
threshold_watcher_.clear_crossings();

auto n_samples = staged_samples.size();
Expand Down Expand Up @@ -234,11 +234,11 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(

// Deliver events and accumulate mechanism current contributions.

PE(advance_integrate_events);
PE(advance:integrate:events);
state_->deliverable_events.mark_until_after(state_->time);
PL();

PE(advance_integrate_current_zero);
PE(advance:integrate:current:zero);
state_->zero_currents();
PL();
for (auto& m: mechanisms_) {
Expand All @@ -255,7 +255,7 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(
// Add current contribution from gap_junctions
state_->add_gj_current();

PE(advance_integrate_events);
PE(advance:integrate:events);
state_->deliverable_events.drop_marked_events();

// Update event list and integration step times.
Expand All @@ -270,24 +270,24 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(
// want to use mean current contributions as opposed to point
// sample.)

PE(advance_integrate_stimuli)
PE(advance:integrate:stimuli)
state_->add_stimulus_current();
PL();

// Take samples at cell time if sample time in this step interval.

PE(advance_integrate_samples);
PE(advance:integrate:samples);
sample_events_.mark_until(state_->time_to);
state_->take_samples(sample_events_.marked_events(), sample_time_, sample_value_);
sample_events_.drop_marked_events();
PL();

// Integrate voltage by matrix solve.

PE(advance_integrate_matrix_build);
PE(advance:integrate:matrix:build);
matrix_.assemble(state_->dt_intdom, state_->voltage, state_->current_density, state_->conductivity);
PL();
PE(advance_integrate_matrix_solve);
PE(advance:integrate:matrix:solve);
matrix_.solve(state_->voltage);
PL();

Expand All @@ -299,17 +299,17 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(

// Update ion concentrations.

PE(advance_integrate_ionupdate);
PE(advance:integrate:ionupdate);
update_ion_state();
PL();

// Update time and test for spike threshold crossings.

PE(advance_integrate_threshold);
PE(advance:integrate:threshold);
threshold_watcher_.test(&state_->time_since_spike);
PL();

PE(advance_integrate_post)
PE(advance:integrate:post)
if (post_events_) {
for (auto& m: mechanisms_) {
m->post_event();
Expand All @@ -323,14 +323,14 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate(
// Check for non-physical solutions:

if (check_voltage_mV_>0) {
PE(advance_integrate_physicalcheck);
PE(advance:integrate:physicalcheck);
assert_voltage_bounded(check_voltage_mV_);
PL();
}

// Check for end of integration.

PE(advance_integrate_stepsupdate);
PE(advance:integrate:stepsupdate);
if (!--remaining_steps) {
tmin_ = state_->time_bounds().first;
remaining_steps = dt_steps(tmin_, tfinal, dt_max);
Expand Down
4 changes: 2 additions & 2 deletions arbor/include/arbor/mechanism.hpp
Expand Up @@ -34,8 +34,8 @@ class mechanism {
mechanism(const arb_mechanism_type m,
const arb_mechanism_interface& i): mech_{m}, iface_{i}, ppack_{} {
if (mech_.abi_version != ARB_MECH_ABI_VERSION) throw unsupported_abi_error{mech_.abi_version};
state_prof_id = profile::profiler_region_id("advance_integrate_state_"+internal_name());
current_prof_id = profile::profiler_region_id("advance_integrate_current_"+internal_name());
state_prof_id = profile::profiler_region_id("advance:integrate:state:"+internal_name());
current_prof_id = profile::profiler_region_id("advance:integrate:current:"+internal_name());
}
mechanism() = default;
mechanism(const mechanism&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion arbor/lif_cell_group.cpp
Expand Up @@ -40,7 +40,7 @@ cell_kind lif_cell_group::get_cell_kind() const {
}

void lif_cell_group::advance(epoch ep, time_type dt, const event_lane_subrange& event_lanes) {
PE(advance_lif);
PE(advance:lif);
if (event_lanes.size() > 0) {
for (auto lid: util::make_span(gids_.size())) {
// Advance each cell independently.
Expand Down
6 changes: 3 additions & 3 deletions arbor/mc_cell_group.cpp
Expand Up @@ -388,7 +388,7 @@ void mc_cell_group::advance(epoch ep, time_type dt, const event_lane_subrange& e

// Bin and collate deliverable events from event lanes.

PE(advance_eventsetup);
PE(advance:eventsetup);
staged_events_.clear();

// Skip event handling if nothing to deliver.
Expand Down Expand Up @@ -446,7 +446,7 @@ void mc_cell_group::advance(epoch ep, time_type dt, const event_lane_subrange& e
// value as defined below, grouping together all the samples of the
// same probe for this callback in this association.

PE(advance_samplesetup);
PE(advance:samplesetup);
std::vector<sampler_call_info> call_info;

std::vector<sample_event> sample_events;
Expand Down Expand Up @@ -527,7 +527,7 @@ void mc_cell_group::advance(epoch ep, time_type dt, const event_lane_subrange& e
// vector of sample entries from the lowered cell sample times and values
// and then call the callback.

PE(advance_sampledeliver);
PE(advance:sampledeliver);
std::vector<sample_record> sample_records;
sample_records.reserve(max_samples_per_call);

Expand Down
8 changes: 4 additions & 4 deletions arbor/profile/profiler.cpp
Expand Up @@ -20,24 +20,24 @@ using util::make_span;
namespace {
// Check whether a string describes a valid profiler region name.
bool is_valid_region_string(const std::string& s) {
if (s.size()==0u || s.front()=='_' || s.back()=='_') return false;
if (s.size()==0u || s.front()==':' || s.back()==':') return false;
return s.find("__") == s.npos;
}

//
// Return a list of the words in the string, using '_' as the delimiter
// Return a list of the words in the string, using ':' as the delimiter
// string, e.g.:
// "communicator" -> {"communicator"}
// "communicator_events" -> {"communicator", "events"}
// "communicator_events_sort" -> {"communicator", "events", "sort"}
std::vector<std::string> split(const std::string& str) {
std::vector<std::string> cont;
std::size_t first = 0;
std::size_t last = str.find('_');
std::size_t last = str.find(':');
while (last != std::string::npos) {
cont.push_back(str.substr(first, last - first));
first = last + 1;
last = str.find('_', first);
last = str.find(':', first);
}
cont.push_back(str.substr(first, last - first));
return cont;
Expand Down
18 changes: 9 additions & 9 deletions arbor/simulation.cpp
Expand Up @@ -44,13 +44,13 @@ void merge_cell_events(
std::vector<event_generator>& generators,
pse_vector& new_events)
{
PE(communication_enqueue_setup);
PE(communication:enqueue:setup);
new_events.clear();
old_events = split_sorted_range(old_events, t_from, event_time_less()).second;
PL();

if (!generators.empty()) {
PE(communication_enqueue_setup);
PE(communication:enqueue:setup);
// Tree-merge events in [t_from, t_to) from old, pending and generator events.

std::vector<event_span> spanbuf;
Expand All @@ -70,7 +70,7 @@ void merge_cell_events(
}
PL();

PE(communication_enqueue_tree);
PE(communication:enqueue:tree);
tree_merge_events(spanbuf, new_events);
PL();

Expand All @@ -79,7 +79,7 @@ void merge_cell_events(
}

// Merge (remaining) old and pending events.
PE(communication_enqueue_merge);
PE(communication:enqueue:merge);
auto n = new_events.size();
new_events.resize(n+pending.size()+old_events.size());
std::merge(pending.begin(), pending.end(), old_events.begin(), old_events.end(), new_events.begin()+n);
Expand Down Expand Up @@ -350,7 +350,7 @@ time_type simulation_state::run(time_type tfinal, time_type dt) {
auto queues = util::subrange_view(event_lanes(current.id), communicator_.group_queue_range(i));
group->advance(current, dt, queues);

PE(advance_spikes);
PE(advance:spikes);
local_spikes(current.id).insert(group->spikes());
group->clear_spikes();
PL();
Expand All @@ -361,14 +361,14 @@ time_type simulation_state::run(time_type tfinal, time_type dt) {
// post-synaptic spike events to per-cell pending event vectors.
auto exchange = [this](epoch prev) {
// Collate locally generated spikes.
PE(communication_exchange_gatherlocal);
PE(communication:exchange:gatherlocal);
auto all_local_spikes = local_spikes(prev.id).gather();
PL();
// Gather generated spikes across all ranks.
auto global_spikes = communicator_.exchange(all_local_spikes);

// Present spikes to user-supplied callbacks.
PE(communication_spikeio);
PE(communication:spikeio);
if (local_export_callback_) {
local_export_callback_(all_local_spikes);
}
Expand All @@ -378,7 +378,7 @@ time_type simulation_state::run(time_type tfinal, time_type dt) {
PL();

// Append events formed from global spikes to per-cell pending event queues.
PE(communication_walkspikes);
PE(communication:walkspikes);
communicator_.make_event_queues(global_spikes, pending_events_);
PL();
};
Expand All @@ -388,7 +388,7 @@ time_type simulation_state::run(time_type tfinal, time_type dt) {
auto enqueue = [this](epoch next) {
foreach_cell(
[&](cell_size_type i) {
PE(communication_enqueue_sort);
PE(communication:enqueue:sort);
util::sort(pending_events_[i]);
PL();

Expand Down
2 changes: 1 addition & 1 deletion arbor/spike_source_cell_group.cpp
Expand Up @@ -46,7 +46,7 @@ cell_kind spike_source_cell_group::get_cell_kind() const {
}

void spike_source_cell_group::advance(epoch ep, time_type dt, const event_lane_subrange& event_lanes) {
PE(advance_sscell);
PE(advance:sscell);

for (auto i: util::count_along(gids_)) {
const auto gid = gids_[i];
Expand Down
12 changes: 6 additions & 6 deletions doc/cpp/profiler.rst
Expand Up @@ -79,7 +79,7 @@ For example, network simulations have two main regions of code to profile: those
We would like to break these regions down further, e.g. break the `communication` time into time spent performing `spike exchange` and `event binning`.

The subdivision of profiling regions is encoded in the region names.
For example, ``PE(communication_exchange)`` indicates that we are profiling the ``exchange`` sub-region of the top level ``communication`` region.
For example, ``PE(communication:exchange)`` indicates that we are profiling the ``exchange`` sub-region of the top level ``communication`` region.

Below is an example of using sub-regions:

Expand All @@ -95,26 +95,26 @@ Below is an example of using sub-regions:
int num_cells = 100;
void communicate() {
PE(communication_sortspikes);
PE(communication:sortspikes);
auto local_spikes = get_local_spikes();
sort(local_spikes);
PL();
PE(communication_exchange);
PE(communication:exchange);
global_spikes = exchange_spikes(local_spikes);
PL();
}
void update_cell(int i) {
PE(update_setup);
PE(update:setup);
setup_events(i);
PL();
PE(update_advance_state);
PE(update:advance:state);
update_cell_states(i);
PL();
PE(update_advance_current);
PE(update:advance:current);
update_cell_current(i);
PL();
}
Expand Down

0 comments on commit 5a49cca

Please sign in to comment.