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

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
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

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

Definition at line 96 of file perfmon.h.

References libmesh_nullptr.

Referenced by ~PerfMon().

97 {
98  gettimeofday (&the_time_stop, libmesh_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
const class libmesh_nullptr_t libmesh_nullptr
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
void libMesh::PerfMon::reset ( )
inline

Definition at line 83 of file perfmon.h.

References libmesh_nullptr.

Referenced by PerfMon().

84 {
85  gettimeofday (&the_time_start, libmesh_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
const class libmesh_nullptr_t libmesh_nullptr
float mflops
Definition: perfmon.h:74
long long int flpins
Definition: perfmon.h:75

Member Data Documentation

long long int libMesh::PerfMon::flpins
private

Definition at line 75 of file perfmon.h.

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

Definition at line 65 of file perfmon.h.

float libMesh::PerfMon::mflops
private

Definition at line 74 of file perfmon.h.

const unsigned int libMesh::PerfMon::proc_id
private

Definition at line 71 of file perfmon.h.

float libMesh::PerfMon::ptime
private

Definition at line 74 of file perfmon.h.

float libMesh::PerfMon::rtime
private

Definition at line 74 of file perfmon.h.

struct timeval libMesh::PerfMon::the_time_start
private

Definition at line 67 of file perfmon.h.

struct timeval libMesh::PerfMon::the_time_stop
private

Definition at line 68 of file perfmon.h.

const unsigned int libMesh::PerfMon::verbose
private

Definition at line 70 of file perfmon.h.


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