libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::PerfMon Class Reference

PAPI stands for Performance Application Programming Interface. 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 &my_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

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 A class for interfacing with hardware timers.

Definition at line 57 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 150 of file perfmon.h.

References reset().

152  :
153  id_string(id),
154  verbose(v),
155  proc_id(pid)
156 {
157  reset ();
158 }
const std::string id_string
Definition: perfmon.h:71
void reset()
Definition: perfmon.h:89
const unsigned int proc_id
Definition: perfmon.h:77
const unsigned int verbose
Definition: perfmon.h:76

◆ ~PerfMon()

libMesh::PerfMon::~PerfMon ( )
inline

Definition at line 163 of file perfmon.h.

References print().

164 {
165  print ();
166 }
double print(std::string msg="NULL", std::ostream &my_out=libMesh::out)
Definition: perfmon.h:102

Member Function Documentation

◆ print()

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

Definition at line 102 of file perfmon.h.

References flpins, gettimeofday(), id_string, mflops, proc_id, ptime, rtime, the_time_start, the_time_stop, timeval::tv_sec, timeval::tv_usec, and verbose.

Referenced by ~PerfMon().

103 {
104  gettimeofday (&the_time_stop, nullptr);
105 
106 #ifdef HAVE_PAPI_H
107  Papi::PAPI_flops (&rtime, & ptime, &flpins, &mflops);
108 #endif
109 
110  const double elapsed_time = ((double) (the_time_stop.tv_sec - the_time_start.tv_sec)) +
111  ((double) (the_time_stop.tv_usec - the_time_start.tv_usec))/1000000.;
112 
113  if (verbose)
114  {
115 
116  if (proc_id == 0)
117  {
118  if (msg == "NULL")
119  my_out << " " << id_string
120  << ": elapsed time: "
121  << elapsed_time << " (sec)"
122  << std::endl;
123  else
124  my_out << " " << msg
125  << ": elapsed time: "
126  << elapsed_time << " (sec)"
127  << std::endl;
128 
129 #ifdef HAVE_PAPI_H
130  if (msg == "NULL")
131  my_out << " " << id_string
132  << ": mflops: "
133  << mflops
134  << std::endl;
135  else
136  my_out << " " << msg
137  << ": mflops: "
138  << mflops
139  << std::endl;
140 #endif
141 
142  }
143  }
144 
145  return elapsed_time;
146 }
const std::string id_string
Definition: perfmon.h:71
struct timeval the_time_start
Definition: perfmon.h:73
int gettimeofday(struct timeval *tp, struct timezone *tzp)
struct timeval the_time_stop
Definition: perfmon.h:74
float mflops
Definition: perfmon.h:80
long long int flpins
Definition: perfmon.h:81
const unsigned int proc_id
Definition: perfmon.h:77
const unsigned int verbose
Definition: perfmon.h:76

◆ reset()

void libMesh::PerfMon::reset ( )
inline

Definition at line 89 of file perfmon.h.

References flpins, gettimeofday(), mflops, ptime, rtime, and the_time_start.

Referenced by PerfMon().

90 {
91  gettimeofday (&the_time_start, nullptr);
92 
93 #ifdef HAVE_PAPI_H
94  Papi::PAPI_flops (&rtime, & ptime, &flpins, &mflops);
95 #endif
96 }
struct timeval the_time_start
Definition: perfmon.h:73
int gettimeofday(struct timeval *tp, struct timezone *tzp)
float mflops
Definition: perfmon.h:80
long long int flpins
Definition: perfmon.h:81

Member Data Documentation

◆ flpins

long long int libMesh::PerfMon::flpins
private

Definition at line 81 of file perfmon.h.

Referenced by print(), and reset().

◆ id_string

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

Definition at line 71 of file perfmon.h.

Referenced by print().

◆ mflops

float libMesh::PerfMon::mflops
private

Definition at line 80 of file perfmon.h.

Referenced by print(), and reset().

◆ proc_id

const unsigned int libMesh::PerfMon::proc_id
private

Definition at line 77 of file perfmon.h.

Referenced by print().

◆ ptime

float libMesh::PerfMon::ptime
private

Definition at line 80 of file perfmon.h.

Referenced by print(), and reset().

◆ rtime

float libMesh::PerfMon::rtime
private

Definition at line 80 of file perfmon.h.

Referenced by print(), and reset().

◆ the_time_start

struct timeval libMesh::PerfMon::the_time_start
private

Definition at line 73 of file perfmon.h.

Referenced by print(), and reset().

◆ the_time_stop

struct timeval libMesh::PerfMon::the_time_stop
private

Definition at line 74 of file perfmon.h.

Referenced by print().

◆ verbose

const unsigned int libMesh::PerfMon::verbose
private

Definition at line 76 of file perfmon.h.

Referenced by print().


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