libMesh::PerfMon Class Reference

A class for interfacing with hardware timers. More...

#include <perfmon.h>

Public Member Functions

 PerfMon (std::string id, const unsigned int v=1, const unsigned int pid=0)
 
 ~PerfMon ()
 
void reset ()
 
double print (std::string msg="NULL", std::ostream &out=libMesh::out)
 

Private Attributes

const std::string id_string
 
struct timeval the_time_start
 
struct timeval the_time_stop
 
const unsigned int verbose
 
const unsigned int proc_id
 
float rtime
 
float ptime
 
float mflops
 
long long int flpins
 

Detailed Description

A class for interfacing with hardware timers.

PAPI stands for Performance Application Programming Interface. This class was supposed to provide an interface to the hardware timers that PAPI exposes, but it never really got developed.

Author
Benjamin S. Kirk
Date
2002

Definition at line 52 of file perfmon.h.

Constructor & Destructor Documentation

◆ PerfMon()

libMesh::PerfMon::PerfMon ( std::string  id,
const unsigned int  v = 1,
const unsigned int  pid = 0 
)
inline

Definition at line 144 of file perfmon.h.

References reset().

146  :
147  id_string(id),
148  verbose(v),
149  proc_id(pid)
150 {
151  reset ();
152 }
const std::string id_string
Definition: perfmon.h:65
void reset()
Definition: perfmon.h:83
const unsigned int proc_id
Definition: perfmon.h:71
const unsigned int verbose
Definition: perfmon.h:70

◆ ~PerfMon()

libMesh::PerfMon::~PerfMon ( )
inline

Definition at line 157 of file perfmon.h.

References print().

158 {
159  print ();
160 }
double print(std::string msg="NULL", std::ostream &out=libMesh::out)
Definition: perfmon.h:96

Member Function Documentation

◆ print()

double libMesh::PerfMon::print ( std::string  msg = "NULL",
std::ostream &  out = libMesh::out 
)
inline

Definition at line 96 of file perfmon.h.

References flpins, id_string, mflops, proc_id, ptime, rtime, the_time_start, the_time_stop, and verbose.

Referenced by ~PerfMon().

97 {
98  gettimeofday (&the_time_stop, nullptr);
99 
100 #ifdef HAVE_PAPI_H
101  Papi::PAPI_flops (&rtime, & ptime, &flpins, &mflops);
102 #endif
103 
104  const double elapsed_time = ((double) (the_time_stop.tv_sec - the_time_start.tv_sec)) +
105  ((double) (the_time_stop.tv_usec - the_time_start.tv_usec))/1000000.;
106 
107  if (verbose)
108  {
109 
110  if (proc_id == 0)
111  {
112  if (msg == "NULL")
113  my_out << " " << id_string
114  << ": elapsed time: "
115  << elapsed_time << " (sec)"
116  << std::endl;
117  else
118  my_out << " " << msg
119  << ": elapsed time: "
120  << elapsed_time << " (sec)"
121  << std::endl;
122 
123 #ifdef HAVE_PAPI_H
124  if (msg == "NULL")
125  my_out << " " << id_string
126  << ": mflops: "
127  << mflops
128  << std::endl;
129  else
130  my_out << " " << msg
131  << ": mflops: "
132  << mflops
133  << std::endl;
134 #endif
135 
136  }
137  }
138 
139  return elapsed_time;
140 }
const std::string id_string
Definition: perfmon.h:65
struct timeval the_time_start
Definition: perfmon.h:67
struct timeval the_time_stop
Definition: perfmon.h:68
float mflops
Definition: perfmon.h:74
long long int flpins
Definition: perfmon.h:75
const unsigned int proc_id
Definition: perfmon.h:71
const unsigned int verbose
Definition: perfmon.h:70

◆ reset()

void libMesh::PerfMon::reset ( )
inline

Definition at line 83 of file perfmon.h.

References flpins, mflops, ptime, rtime, and the_time_start.

Referenced by PerfMon().

84 {
85  gettimeofday (&the_time_start, nullptr);
86 
87 #ifdef HAVE_PAPI_H
88  Papi::PAPI_flops (&rtime, & ptime, &flpins, &mflops);
89 #endif
90 }
struct timeval the_time_start
Definition: perfmon.h:67
float mflops
Definition: perfmon.h:74
long long int flpins
Definition: perfmon.h:75

Member Data Documentation

◆ flpins

long long int libMesh::PerfMon::flpins
private

Definition at line 75 of file perfmon.h.

Referenced by print(), and reset().

◆ id_string

const std::string libMesh::PerfMon::id_string
private

Definition at line 65 of file perfmon.h.

Referenced by print().

◆ mflops

float libMesh::PerfMon::mflops
private

Definition at line 74 of file perfmon.h.

Referenced by print(), and reset().

◆ proc_id

const unsigned int libMesh::PerfMon::proc_id
private

Definition at line 71 of file perfmon.h.

Referenced by print().

◆ ptime

float libMesh::PerfMon::ptime
private

Definition at line 74 of file perfmon.h.

Referenced by print(), and reset().

◆ rtime

float libMesh::PerfMon::rtime
private

Definition at line 74 of file perfmon.h.

Referenced by print(), and reset().

◆ the_time_start

struct timeval libMesh::PerfMon::the_time_start
private

Definition at line 67 of file perfmon.h.

Referenced by print(), and reset().

◆ the_time_stop

struct timeval libMesh::PerfMon::the_time_stop
private

Definition at line 68 of file perfmon.h.

Referenced by print().

◆ verbose

const unsigned int libMesh::PerfMon::verbose
private

Definition at line 70 of file perfmon.h.

Referenced by print().


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