From 5e65a939d6fc9bb929c3faab99cd0022efeec878 Mon Sep 17 00:00:00 2001 From: Ben Cumming <bcumming@cscs.ch> Date: Thu, 7 Jun 2018 12:56:59 +0200 Subject: [PATCH] profile multicore mechanism state and current calls individually (#492) The built in profiler generates timings for state and current for individual multicore mechanisms. Modcc generates and PE(advance_integrate_{state,current}_X) profiler calls (along with corresponding PL() for calls to multicore mechanism nrn_state and nrn_current API calls. No timings are made for the gpu back end, which is not properly supported by the current profiling tools. --- modcc/printer/cprinter.cpp | 14 ++++++++++++++ src/fvm_lowered_cell_impl.hpp | 6 ++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/modcc/printer/cprinter.cpp b/modcc/printer/cprinter.cpp index c856f4b6..e7b478b6 100644 --- a/modcc/printer/cprinter.cpp +++ b/modcc/printer/cprinter.cpp @@ -14,6 +14,13 @@ using io::indent; using io::popindent; using io::quote; +constexpr bool with_profiling() { +#ifdef ARB_HAVE_PROFILING + return true; +#else + return false; +#endif +} void emit_procedure_proto(std::ostream&, ProcedureExpression*, const std::string& qualified = ""); void emit_simd_procedure_proto(std::ostream&, ProcedureExpression*, const std::string& qualified = ""); @@ -106,6 +113,9 @@ std::string emit_cpp_source(const Module& module_, const std::string& ns, simd_s "#include <" << arb_header_prefix() << "backends/multicore/mechanism.hpp>\n" "#include <" << arb_header_prefix() << "math.hpp>\n"; + with_profiling() && + out << "#include <" << arb_header_prefix() << "profiling/profiler.hpp>\n"; + if (with_simd) { out << "#include <" << arb_header_prefix() << "simd/simd.hpp>\n"; } @@ -306,11 +316,15 @@ std::string emit_cpp_source(const Module& module_, const std::string& ns, simd_s out << popindent << "}\n\n"; out << "void " << class_name << "::nrn_state() {\n" << indent; + with_profiling() && out << "PE(advance_integrate_state_" << name << ");\n"; emit_body(state_api); + with_profiling() && out << "PL();\n"; out << popindent << "}\n\n"; out << "void " << class_name << "::nrn_current() {\n" << indent; + with_profiling() && out << "PE(advance_integrate_current_" << name << ");\n"; emit_body(current_api); + with_profiling() && out << "PL();\n"; out << popindent << "}\n\n"; out << "void " << class_name << "::write_ions() {\n" << indent; diff --git a/src/fvm_lowered_cell_impl.hpp b/src/fvm_lowered_cell_impl.hpp index 765dfb2a..c793659b 100644 --- a/src/fvm_lowered_cell_impl.hpp +++ b/src/fvm_lowered_cell_impl.hpp @@ -170,13 +170,13 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate( state_->deliverable_events.mark_until_after(state_->time); PL(); - PE(advance_integrate_current); + PE(advance_integrate_current_zero); state_->zero_currents(); + PL(); for (auto& m: mechanisms_) { m->deliver_events(); m->nrn_current(); } - PL(); PE(advance_integrate_events); state_->deliverable_events.drop_marked_events(); @@ -208,11 +208,9 @@ fvm_integration_result fvm_lowered_cell_impl<Backend>::integrate( // Integrate mechanism state. - PE(advance_integrate_state); for (auto& m: mechanisms_) { m->nrn_state(); } - PL(); // Update ion concentrations. -- GitLab