libMesh::PerfMon Class Reference

#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

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

References reset().

137  :
138  id_string(id),
139  verbose(v),
140  proc_id(pid)
141 {
142  reset ();
143 }
libMesh::PerfMon::~PerfMon ( )
inline

Definition at line 148 of file perfmon.h.

References print().

149 {
150  print ();
151 }

Member Function Documentation

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

Definition at line 87 of file perfmon.h.

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

Referenced by ~PerfMon().

88 {
89  gettimeofday (&the_time_stop, NULL);
90 
91 #ifdef HAVE_PAPI_H
92  Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
93 #endif
94 
95  const double elapsed_time = ((double) (the_time_stop.tv_sec - the_time_start.tv_sec)) +
96  ((double) (the_time_stop.tv_usec - the_time_start.tv_usec))/1000000.;
97 
98  if (verbose)
99  {
100 
101  if (proc_id == 0)
102  {
103  if (msg == "NULL")
104  my_out << " " << id_string
105  << ": elapsed time: "
106  << elapsed_time << " (sec)"
107  << std::endl;
108  else
109  my_out << " " << msg
110  << ": elapsed time: "
111  << elapsed_time << " (sec)"
112  << std::endl;
113 
114 #ifdef HAVE_PAPI_H
115  if (msg == "NULL")
116  my_out << " " << id_string
117  << ": mflops: "
118  << mflops
119  << std::endl;
120  else
121  my_out << " " << msg
122  << ": mflops: "
123  << mflops
124  << std::endl;
125 #endif
126 
127  }
128  }
129 
130  return elapsed_time;
131 }
void libMesh::PerfMon::reset ( )
inline

Definition at line 74 of file perfmon.h.

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

Referenced by PerfMon().

75 {
76  gettimeofday (&the_time_start, NULL);
77 
78 #ifdef HAVE_PAPI_H
79  Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
80 #endif
81 }

Member Data Documentation

long long int libMesh::PerfMon::flpins
private

Definition at line 66 of file perfmon.h.

Referenced by print(), and reset().

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

Definition at line 56 of file perfmon.h.

Referenced by print().

float libMesh::PerfMon::mflops
private

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

const unsigned int libMesh::PerfMon::proc_id
private

Definition at line 62 of file perfmon.h.

Referenced by print().

float libMesh::PerfMon::ptime
private

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

float libMesh::PerfMon::rtime
private

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

struct timeval libMesh::PerfMon::the_time_start
private

Definition at line 58 of file perfmon.h.

Referenced by print(), and reset().

struct timeval libMesh::PerfMon::the_time_stop
private

Definition at line 59 of file perfmon.h.

Referenced by print().

const unsigned int libMesh::PerfMon::verbose
private

Definition at line 61 of file perfmon.h.

Referenced by print().


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:29 UTC

Hosted By:
SourceForge.net Logo