Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 846b3a6

Browse files
authored
Improve instrumentation phases (#645)
* Added instrumentation phases in multiple places for `gap-v-transfer`, `nrn_spike_exchange` and `handle-forward-skip` * Moved `timestep` phase to different places to cover all possible code execution flows * Created different phases for `net_receive` and `net_buf_receive` functions of different mod files * Created distinct phases for cpu2gpu and gpu2cpu transfers related to net receive and net send structs
1 parent d39e8d9 commit 846b3a6

File tree

7 files changed

+28
-9
lines changed

7 files changed

+28
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ if(CORENRN_ENABLE_CALIPER_PROFILING)
390390
include_directories(${caliper_INCLUDE_DIR})
391391
add_definitions("-DCORENEURON_CALIPER")
392392
set(CALIPER_LIB "caliper")
393+
set_property(GLOBAL APPEND_STRING PROPERTY CORENEURON_LIB_LINK_FLAGS
394+
" -L${caliper_LIB_DIR} -l${CALIPER_LIB}")
393395
endif()
394396

395397
if(CORENRN_ENABLE_LIKWID_PROFILING)

coreneuron/apps/main1.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
598598

599599
// handle forwardskip
600600
if (corenrn_param.forwardskip > 0.0) {
601+
Instrumentor::phase p("handle-forward-skip");
601602
handle_forward_skip(corenrn_param.forwardskip, corenrn_param.prcellgid);
602603
}
603604

coreneuron/gpu/nrn_acc_manager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ struct comp {
554554
};
555555

556556
static void net_receive_buffer_order(NetReceiveBuffer_t* nrb) {
557+
Instrumentor::phase p_net_receive_buffer_order("net-receive-buf-order");
557558
if (nrb->_cnt == 0) {
558559
nrb->_displ_cnt = 0;
559560
return;
@@ -593,6 +594,7 @@ static void net_receive_buffer_order(NetReceiveBuffer_t* nrb) {
593594
* functional version.
594595
*/
595596
void update_net_receive_buffer(NrnThread* nt) {
597+
Instrumentor::phase p_update_net_receive_buffer("update-net-receive-buf");
596598
for (auto tml = nt->tml; tml; tml = tml->next) {
597599
// net_receive buffer to copy
598600
NetReceiveBuffer_t* nrb = tml->ml->_net_receive_buffer;
@@ -604,6 +606,7 @@ void update_net_receive_buffer(NrnThread* nt) {
604606

605607
#ifdef _OPENACC
606608
if (nt->compute_gpu) {
609+
Instrumentor::phase p_net_receive_buffer_order("net-receive-buf-cpu2gpu");
607610
// note that dont update nrb otherwise we lose pointers
608611

609612
/* update scalar elements */
@@ -636,6 +639,7 @@ void update_net_send_buffer_on_host(NrnThread* nt, NetSendBuffer_t* nsb) {
636639
}
637640

638641
if (nsb->_cnt) {
642+
Instrumentor::phase p_net_receive_buffer_order("net-send-buf-gpu2cpu");
639643
acc_update_self(nsb->_sendtype, sizeof(int) * nsb->_cnt);
640644
acc_update_self(nsb->_vdata_index, sizeof(int) * nsb->_cnt);
641645
acc_update_self(nsb->_pnt_index, sizeof(int) * nsb->_cnt);

coreneuron/network/netcvode.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "coreneuron/network/netcvode.hpp"
1717
#include "coreneuron/network/netpar.hpp"
1818
#include "coreneuron/utils/ivocvect.hpp"
19+
#include "coreneuron/utils/profile/profiler_interface.h"
1920
#include "coreneuron/nrniv/nrniv_decl.h"
2021
#include "coreneuron/io/output_spikes.hpp"
2122
#include "coreneuron/utils/nrn_assert.h"
@@ -385,6 +386,9 @@ void NetCon::deliver(double tt, NetCvode* /* ns */, NrnThread* nt) {
385386
nt->_t = tt;
386387

387388
// printf("NetCon::deliver t=%g tt=%g %s\n", t, tt, pnt_name(target_));
389+
std::string ss("net-receive-");
390+
ss += nrn_get_mechname(typ);
391+
Instrumentor::phase p_get_pnt_receive(ss.c_str());
388392
(*corenrn.get_pnt_receive()[typ])(target_, u.weight_index_, 0);
389393
#ifdef DEBUG
390394
if (errno && nrn_errno_check(typ))
@@ -518,6 +522,7 @@ double PreSyn::value(NrnThread* nt) {
518522
}
519523

520524
void NetCvode::check_thresh(NrnThread* nt) { // for default method
525+
Instrumentor::phase p("check-threshold");
521526
double teps = 1e-10;
522527

523528
nt->_net_send_buffer_cnt = 0;
@@ -697,6 +702,9 @@ void NetCvode::deliver_net_events(NrnThread* nt) { // for default method
697702
update_net_receive_buffer(nt);
698703

699704
for (auto& net_buf_receive: corenrn.get_net_buf_receive()) {
705+
std::string ss("net-buf-receive-");
706+
ss += nrn_get_mechname(net_buf_receive.second);
707+
Instrumentor::phase p_net_buf_receive(ss.c_str());
700708
(*net_buf_receive.first)(nt);
701709
}
702710
}

coreneuron/network/netpar.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "coreneuron/network/multisend.hpp"
2525
#include "coreneuron/utils/nrn_assert.h"
2626
#include "coreneuron/utils/nrnoc_aux.hpp"
27+
#include "coreneuron/utils/profile/profiler_interface.h"
2728
#include "coreneuron/utils/utils.hpp"
2829

2930
#if NRNMPI
@@ -301,6 +302,7 @@ void nrn_spike_exchange_init() {
301302

302303
#if NRNMPI
303304
void nrn_spike_exchange(NrnThread* nt) {
305+
Instrumentor::phase p_spike_exchange("spike-exchange");
304306
if (!active_) {
305307
return;
306308
}

coreneuron/sim/fadvance_core.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void dt2thread(double adt) { /* copied from nrnoc/fadvance.c */
8888
}
8989

9090
void nrn_fixed_step_minimal() { /* not so minimal anymore with gap junctions */
91+
Instrumentor::phase p_timestep("timestep");
9192
if (t != nrn_threads->_t) {
9293
dt2thread(-1.);
9394
} else {
@@ -96,7 +97,10 @@ void nrn_fixed_step_minimal() { /* not so minimal anymore with gap junctions */
9697
nrn_thread_table_check();
9798
nrn_multithread_job(nrn_fixed_step_thread);
9899
if (nrn_have_gaps) {
99-
nrnmpi_v_transfer();
100+
{
101+
Instrumentor::phase p_gap("gap-v-transfer");
102+
nrnmpi_v_transfer();
103+
}
100104
nrn_multithread_job(nrn_fixed_step_lastpart);
101105
}
102106
#if NRNMPI
@@ -148,7 +152,6 @@ void nrn_fixed_step_group_minimal(int total_sim_steps) {
148152
int step_group_end = 0;
149153

150154
ProgressBar progress_bar(step_group_n);
151-
152155
while (step_group_end < step_group_n) {
153156
nrn_multithread_job(nrn_fixed_step_group_thread,
154157
step_group_n,
@@ -179,6 +182,7 @@ static void nrn_fixed_step_group_thread(NrnThread* nth,
179182
int& step_group_end) {
180183
nth->_stop_stepping = 0;
181184
for (int i = step_group_begin; i < step_group_max; ++i) {
185+
Instrumentor::phase p_timestep("timestep");
182186
nrn_fixed_step_thread(nth);
183187
if (nth->_stop_stepping) {
184188
if (nth->id == 0) {
@@ -339,10 +343,8 @@ void nrncore2nrn_send_values(NrnThread* nth) {
339343
static void* nrn_fixed_step_thread(NrnThread* nth) {
340344
/* check thresholds and deliver all (including binqueue)
341345
events up to t+dt/2 */
342-
Instrumentor::phase_begin("timestep");
343-
344346
{
345-
Instrumentor::phase p("deliver_events");
347+
Instrumentor::phase p("deliver-events");
346348
deliver_net_events(nth);
347349
}
348350

@@ -361,7 +363,7 @@ static void* nrn_fixed_step_thread(NrnThread* nth) {
361363
fixed_play_continuous(nth);
362364

363365
{
364-
Instrumentor::phase p("setup_tree_matrix");
366+
Instrumentor::phase p("setup-tree-matrix");
365367
setup_tree_matrix_minimal(nth);
366368
}
367369

@@ -371,7 +373,7 @@ static void* nrn_fixed_step_thread(NrnThread* nth) {
371373
}
372374

373375
{
374-
Instrumentor::phase p("second_order_cur");
376+
Instrumentor::phase p("second-order-cur");
375377
second_order_cur(nth, secondorder);
376378
}
377379

@@ -383,7 +385,6 @@ static void* nrn_fixed_step_thread(NrnThread* nth) {
383385
if (!nrn_have_gaps) {
384386
nrn_fixed_step_lastpart(nth);
385387
}
386-
Instrumentor::phase_end("timestep");
387388
return nullptr;
388389
}
389390

@@ -408,7 +409,7 @@ void* nrn_fixed_step_lastpart(NrnThread* nth) {
408409
}
409410

410411
{
411-
Instrumentor::phase p("deliver_events");
412+
Instrumentor::phase p("deliver-events");
412413
nrn_deliver_events(nth); /* up to but not past texit */
413414
}
414415

coreneuron/sim/finitialize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void nrn_finitialize(int setv, double v) {
6666
}
6767

6868
if (nrn_have_gaps) {
69+
Instrumentor::phase p("gap-v-transfer");
6970
nrnmpi_v_transfer();
7071
for (int i = 0; i < nrn_nthread; ++i) {
7172
nrnthread_v_transfer(nrn_threads + i);

0 commit comments

Comments
 (0)