profiler  0.0
molpro::profiler Namespace Reference

Namespaces

 detail
 
 dotgraph
 

Classes

class  Node
 A node in a parameter tree storing a Counter object aliased by a name. More...
 
class  Profiler
 Instrumental profiler for timing sections of code. More...
 
class  Timer
 Measures cpu or wall time. Can be constructed as a dummy that is always stopped. More...
 
class  Counter
 Resource counter used for storing operation count, call count, timing information. More...
 
struct  NodePathError
 
struct  WeakSingleton
 Implements the mechanism for the weak singleton pattern. More...
 

Enumerations

enum class  SortBy {
  wall ,
  cpu ,
  calls ,
  operations ,
  none
}
 

Functions

void report (const std::shared_ptr< Node< Counter >> &root, const std::string &description, std::ostream &out, bool cumulative=true, SortBy sort_by=SortBy::wall)
 Reports the content of a Profiler call subtree. More...
 
void report (const Profiler &prof, std::ostream &out, bool cumulative=true, SortBy sort_by=SortBy::wall)
 Reports content of Profiler. More...
 
std::string get_dotgraph (const Profiler &prof, int hot[3], int cool[3], double threshold, bool get_percentage_time)
 
std::ostream & operator<< (std::ostream &os, const Profiler &obj)
 
MPI_Comm comm_self ()
 Return MPI_COMM_SELF in an MPI program, or an appropriate dummy if not. More...
 
MPI_Comm comm_global ()
 Return the MPI communicator containing all processes available for participation in computation. If MPI support has been compiled (either mpi.h has already been included, or HAVE_MPI_H has been defined) but not yet initialised, MPI will be initialised, and then MPI_COMM_WORLD is selected. Otherwise, in the case of a program compiled with PPIDD, and for which PPIDD has already been initialised, this will be the PPIDD worker communicator. Otherwise, in the case of a program compiled with GA, and for which GA has already been initialised, this will be the GA worker communicator. Otherwise, if MPI support has is active, MPI_COMM_WORLD is selected. Otherwise (completely serial code), a place-holder is chosen. More...
 
int size_global ()
 
int rank_global ()
 
int init ()
 In MPI environment initialize; otherwise do nothing. Intended to support MPI-agnostic programs. More...
 
int finalize ()
 In MPI environment finalize; otherwise do nothing. More...
 

Variables

std::shared_ptr< Profilers_saver
 

Enumeration Type Documentation

◆ SortBy

Enumerator
wall 
cpu 
calls 
operations 
none 

Function Documentation

◆ comm_global()

MPI_Comm molpro::profiler::comm_global ( )
inline

Return the MPI communicator containing all processes available for participation in computation. If MPI support has been compiled (either mpi.h has already been included, or HAVE_MPI_H has been defined) but not yet initialised, MPI will be initialised, and then MPI_COMM_WORLD is selected. Otherwise, in the case of a program compiled with PPIDD, and for which PPIDD has already been initialised, this will be the PPIDD worker communicator. Otherwise, in the case of a program compiled with GA, and for which GA has already been initialised, this will be the GA worker communicator. Otherwise, if MPI support has is active, MPI_COMM_WORLD is selected. Otherwise (completely serial code), a place-holder is chosen.

Returns
The global communicator

◆ comm_self()

MPI_Comm molpro::profiler::comm_self ( )
inline

Return MPI_COMM_SELF in an MPI program, or an appropriate dummy if not.

Returns
MPI_COMM_SELF if MPI initialised, MPI_COMM_NULL otherwise, or 0 if MP I support not compiled

◆ finalize()

int molpro::profiler::finalize ( )

In MPI environment finalize; otherwise do nothing.

◆ get_dotgraph()

std::string molpro::profiler::get_dotgraph ( const Profiler prof,
int  hot[3],
int  cool[3],
double  threshold,
bool  get_percentage_time 
)

◆ init()

int molpro::profiler::init ( )

In MPI environment initialize; otherwise do nothing. Intended to support MPI-agnostic programs.

◆ operator<<()

std::ostream& molpro::profiler::operator<< ( std::ostream &  os,
const Profiler obj 
)

◆ rank_global()

int molpro::profiler::rank_global ( )
inline

◆ report() [1/2]

void molpro::profiler::report ( const Profiler prof,
std::ostream &  out,
bool  cumulative = true,
SortBy  sort_by = SortBy::wall 
)

Reports content of Profiler.

Parameters
profprofiler to analyse and write
outoutput stream to write to
sort_bywhat parameter to use for sorting. Sorting is done on the same level only.
cumulativewhether cumulative timings should be used or only time spend by the node and not its children

◆ report() [2/2]

void molpro::profiler::report ( const std::shared_ptr< Node< Counter >> &  root,
const std::string &  description,
std::ostream &  out,
bool  cumulative = true,
SortBy  sort_by = SortBy::wall 
)

Reports the content of a Profiler call subtree.

In case only part of the call tree needs to be reported. You can use Node<Counter>::find_parent, Node<Counter::walk, Node<Counter::child and Node<Counter::walk_up to navigate to the desired node.

Example usage

Profiler p("Example of report");
p.start("A").start("B").start("C");
// do some work that uses profiler p
report(p.active_node, std::cout);
void report(const std::shared_ptr< Node< Counter >> &root, const std::string &description, std::ostream &out, bool cumulative=true, SortBy sort_by=SortBy::wall)
Reports the content of a Profiler call subtree.
Definition: report.cpp:209
profiler::Profiler Profiler
Definition: Profiler.h:6
Parameters
rootroot node of the tree, can be different from Profiler::root
descriptiondescription to use for profiler
outoutput stream to write to
cumulativewhether cumulative timings should be used or only time spend by the node and not its children
sort_bywhat parameter to use for sorting. Sorting is done on the same level only.

◆ size_global()

int molpro::profiler::size_global ( )
inline

Variable Documentation

◆ s_saver

std::shared_ptr<Profiler> molpro::profiler::s_saver