NEURON
coreneuron::detail::Instrumentor< TProfilerImpl > Class Template Reference

Instrumentation infrastructure for benchmarking and profiling. More...

#include <profiler_interface.h>

Static Public Member Functions

static void phase_begin (const char *name)
 Activate the collection of profiling data within a code region. More...
 
static void phase_end (const char *name)
 Deactivate the collection of profiling data within a code region. More...
 
static void start_profile ()
 Globally activate the collection of profiling data. More...
 
static void stop_profile ()
 Globally deactivate the collection of profiling data. More...
 
static void init_profile ()
 Initialize the profiler. More...
 
static void finalize_profile ()
 Finalize the profiler. More...
 

Static Private Member Functions

static void initialize_regions_from_env ()
 Initialize regions to track from the NRN_PROFILE_REGIONS environment variable. More...
 
static bool is_region_to_track (const char *name)
 Check if a given region name should be tracked. More...
 

Static Private Attributes

static std::unordered_set< std::string > regions_to_measure
 Caliper regions that we want to measure. More...
 

Detailed Description

template<class... TProfilerImpl>
class coreneuron::detail::Instrumentor< TProfilerImpl >

Instrumentation infrastructure for benchmarking and profiling.

The Instrumentor class exposes static methods that can be used to toggle with fine-grained resolution the profiling of specific areas within the code.

Definition at line 50 of file profiler_interface.h.

Member Function Documentation

◆ finalize_profile()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::finalize_profile ( )
inlinestatic

Finalize the profiler.

Finalize a profiler's internal structure, without activating yet any data collection, similar in concept to MPI_Finalize. Loops through all enabled profilers and calls the relevant finalize_profile function. This function should have a non-empty implementation only for profilers that require special finalization.

Definition at line 149 of file profiler_interface.h.

◆ init_profile()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::init_profile ( )
inlinestatic

Initialize the profiler.

Initialize a profiler's internal structure, without activating yet any data collection, similar in concept to MPI_Init. Loops through all enabled profilers and calls the relevant init_profile function. This function should have a non-empty implementation only for profilers that require special initialization, typically before any memory allocation is done.

Definition at line 134 of file profiler_interface.h.

◆ initialize_regions_from_env()

template<class... TProfilerImpl>
static void coreneuron::detail::Instrumentor< TProfilerImpl >::initialize_regions_from_env ( )
inlinestaticprivate

Initialize regions to track from the NRN_PROFILE_REGIONS environment variable.

Checks if the NRN_PROFILE_REGIONS environment variable is set. If it is set, splits the value by "," and inserts each split string into the regions that should be measured during profiling.

Definition at line 164 of file profiler_interface.h.

◆ is_region_to_track()

template<class... TProfilerImpl>
static bool coreneuron::detail::Instrumentor< TProfilerImpl >::is_region_to_track ( const char *  name)
inlinestaticprivate

Check if a given region name should be tracked.

By default the regions_to_measure set is empty and we measure all functions instrumented via Caliper instrumentation. But one might want to profile only particular region or "phase" (e.g. due to profiling overhead) and in that case we check NRN_PROFILE_REGIONS environment variable.

Parameters
nameThe name of the region to check.
Returns
true if the regions set is empty or if the name exists in the regions set, false otherwise.

Definition at line 189 of file profiler_interface.h.

◆ phase_begin()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::phase_begin ( const char *  name)
inlinestatic

Activate the collection of profiling data within a code region.

This function semantically defines the beginning of a region of code that the user wishes to profile. Loops through all enabled profilers and calls the relevant phase_begin function. This function should have a non-empty implementation only for profilers that allow multiple code regions with different names to be profiled concurrently.

Parameters
namethe (unique) identifier of the code region to be profiled

Definition at line 68 of file profiler_interface.h.

◆ phase_end()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::phase_end ( const char *  name)
inlinestatic

Deactivate the collection of profiling data within a code region.

This function semantically defines the end of a region of code that the user wishes to profile. Loops through all enabled profilers and calls the relevant phase_end function. This function should have a non-empty implementation only for profilers that allow multiple code regions with different names to be profiled concurrently.

Parameters
namethe (unique) identifier of the code region to be profiled

Definition at line 87 of file profiler_interface.h.

◆ start_profile()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::start_profile ( )
inlinestatic

Globally activate the collection of profiling data.

Activate the collection of profiler data without defining a region of interest with a given name, as opposed to phase_begin. Loops through all enabled profilers and calls the relevant start_profile function. This function should have a non-empty implementation only for profilers that expose simply a global begin/end interface, without named regions.

Definition at line 104 of file profiler_interface.h.

◆ stop_profile()

template<class... TProfilerImpl>
coreneuron::detail::Instrumentor< TProfilerImpl >::stop_profile ( )
inlinestatic

Globally deactivate the collection of profiling data.

Deactivate the collection of profiler data without defining a region of interest with a given name, as opposed to phase_end. Loops through all enabled profilers and calls the relevant stop_profile function. This function should have a non-empty implementation only for profilers that expose simply a global begin/end interface, without named regions.

Definition at line 119 of file profiler_interface.h.

Member Data Documentation

◆ regions_to_measure

template<class... TProfilerImpl>
std::unordered_set< std::string > coreneuron::detail::Instrumentor< TProfilerImpl >::regions_to_measure
inlinestaticprivate

Caliper regions that we want to measure.

Each string in the set represents the name of a region of interest that we have already defined via Instrumentor::phase API.

Definition at line 202 of file profiler_interface.h.


The documentation for this class was generated from the following file: