diff --git a/modcc/printer/cprinter.cpp b/modcc/printer/cprinter.cpp index c856f4b6f27250dd83a753b661301b8caea29a6c..e7b478b6dba5cbc18848551bba97047b9d48d8b7 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 765dfb2ae17790da286b643ae6e159d153d6e22a..c793659b3382497092819292ce69f0ab2c7e527d 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.