diff --git a/doc/profiler.rst b/doc/profiler.rst index afe9248f8e45203d6e44f5eed746b227df56147b..6f0d0787ebdb14d11a6c188c85971b9b304e646b 100644 --- a/doc/profiler.rst +++ b/doc/profiler.rst @@ -156,6 +156,8 @@ Running the Profiler -------------------- The profiler does not need to be started or stopped by the user. +It needs to be initialized before entering any profiling region. +It is initialized using the information provided by the simulation's thread pool. At any point a summary of profiler region counts and times can be obtained, and the profiler regions can be reset. @@ -168,6 +170,11 @@ and the profiler regions can be reset. using namespace arb; void main() { + execution_context context; + + // Initialize the profiler with thread information from the execution context + profile::profiler_initialize(context.thread_pool); + PE(init); // ... PL(); @@ -177,11 +184,11 @@ and the profiler regions can be reset. PL(); // Print a summary of the profiler to stdout - std::cout << util::profiler_summary() << "\n"; + std::cout << profile::profiler_summary() << "\n"; // Clear the profiler state, which can then be used to record // profile information for a different part of the code. - util::profiler_clear(); + profile::profiler_clear(); } After a call to ``util::profiler_clear``, all counters and timers are set to zero. diff --git a/example/bench/bench.cpp b/example/bench/bench.cpp index 2c566e7b84be853c8973b5b9658f2db43280f57b..f8934b734f5b674b07e04b024664d8ebecde3412 100644 --- a/example/bench/bench.cpp +++ b/example/bench/bench.cpp @@ -17,6 +17,7 @@ #include <arbor/recipe.hpp> #include <arbor/simulation.hpp> #include <arbor/threadinfo.hpp> +#include <arbor/version.hpp> #include <aux/ioutil.hpp> @@ -33,11 +34,11 @@ namespace profile = arb::profile; int main(int argc, char** argv) { try { arb::execution_context context; -#ifdef ARB_HAVE_MPI +#ifdef ARB_MPI_ENABLED aux::with_mpi guard(&argc, &argv); context.distributed = mpi_context(MPI_COMM_WORLD); #endif -#ifdef ARB_HAVE_PROFILING +#ifdef ARB_PROFILE_ENABLED profile::profiler_initialize(context.thread_pool); #endif const bool is_root = context.distributed.id()==0; diff --git a/example/brunel/brunel_miniapp.cpp b/example/brunel/brunel_miniapp.cpp index 45d82cb71a5210f2ccb4bf56fb55d5c5861117e4..9de099c02bee0867a2a5ae175ead9081ecbf9afb 100644 --- a/example/brunel/brunel_miniapp.cpp +++ b/example/brunel/brunel_miniapp.cpp @@ -194,7 +194,7 @@ int main(int argc, char** argv) { with_mpi guard(argc, argv, false); context.distributed = mpi_context(MPI_COMM_WORLD); #endif -#ifdef ARB_HAVE_PROFILING +#ifdef ARB_PROFILE_ENABLED profile::profiler_initialize(context.thread_pool); #endif arb::profile::meter_manager meters(&context.distributed); diff --git a/example/miniapp/miniapp.cpp b/example/miniapp/miniapp.cpp index a809a3f371395433c2477e8640d99568b073d24e..590cdcfb16a35428c2537cd94d4ca7c96ac80f3e 100644 --- a/example/miniapp/miniapp.cpp +++ b/example/miniapp/miniapp.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) { with_mpi guard(argc, argv, false); context.distributed = mpi_context(MPI_COMM_WORLD); #endif -#ifdef ARB_HAVE_PROFILING +#ifdef ARB_PROFILE_ENABLED profile::profiler_initialize(context.thread_pool); #endif profile::meter_manager meters(&context.distributed);