Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Tpetra::Details::ProfilingRegion Class Reference

Profile the given scope. More...

#include <Tpetra_Details_Profiling.hpp>

Public Member Functions

 ProfilingRegion ()
 Default constructor does not construct a region. More...
 
 ProfilingRegion (const char name[])
 Open region to profile; name the region name. More...
 
 ProfilingRegion (const char name[], const char group[])
 
 ~ProfilingRegion ()
 Close region to profile. More...
 

Detailed Description

Profile the given scope.

This class implements a "scope guard" for profiling a region of code, using Kokkos Profiling.

If you disable Kokkos Profiling by setting some configuration option such that KOKKOS_ENABLE_PROFILING is not defined, then this class is harmless, but will do NOTHING.

Tpetra currently uses Kokkos::Profiling::pushRegion(name) to start the region to profile, and Kokkos::Profiling::popRegion() to close the region to profile. The "scope guard" idiom means that the destructor automatically closes the region, no matter how the scope exits, even if an exception is thrown.

Here is an example of how to use this class:

void someFunctionYouWrote () {
ProfilingRegion wholeFuncRegion ("someFunctionYouWrote");
doStuff ();
{
ProfilingRegion innerRegion1 ("inner-region-1");
doOtherStuff ();
}
doSomeMoreStuff ();
{
ProfilingRegion innerRegion2 ("yet-another-inner-region");
doYetMoreStuff ();
}
finallyDoEvenStillMoreStuff ();
}

It's critical that you not forget to name the ProfilingRegion variable. If you forget, you will create a temporary ProfilingRegion object that will first open, then immediately close the "region" before anything else happens. This is not what you want.

You may name regions whatever you like. They don't have to have the same name as the region variable. Kokkos Profiling has a length limit of 512 characters for region names.

For details about Kokkos Profiling, see the kokkos-tools wiki:

https://github.com/kokkos/kokkos-tools/wiki

Definition at line 103 of file Tpetra_Details_Profiling.hpp.

Constructor & Destructor Documentation

Tpetra::Details::ProfilingRegion::ProfilingRegion ( )

Default constructor does not construct a region.

Definition at line 53 of file Tpetra_Details_Profiling.cpp.

Tpetra::Details::ProfilingRegion::ProfilingRegion ( const char  name[])

Open region to profile; name the region name.

Definition at line 59 of file Tpetra_Details_Profiling.cpp.

Tpetra::Details::ProfilingRegion::ProfilingRegion ( const char  name[],
const char  group[] 
)

Open region to profile, if the group name group is enabled by the TPETRA_TIMING variable; name the region name.

Definition at line 70 of file Tpetra_Details_Profiling.cpp.

Tpetra::Details::ProfilingRegion::~ProfilingRegion ( )

Close region to profile.

Definition at line 84 of file Tpetra_Details_Profiling.cpp.


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