The Gaudi Framework  v30r4 (9b837755)
PerfMonAuditor Class Reference

Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms. More...

Inheritance diagram for PerfMonAuditor:
Collaboration diagram for PerfMonAuditor:

Public Member Functions

void before (StandardEventType evt, INamedInterface *alg) override
 
void after (StandardEventType evt, INamedInterface *alg, const StatusCode &sc) override
 
StatusCode initialize () override
 
StatusCode finalize () override
 
int is_nehalem ()
 
 PerfMonAuditor (const std::string &name, ISvcLocator *pSvc)
 
virtual ~PerfMonAuditor ()
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
const std::stringname () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Private Types

typedef GaudiUtils::VectorMap< const INamedInterface *, int > Map
 

Private Member Functions

void i_beforeInitialize (INamedInterface *alg)
 
void i_afterInitialize (INamedInterface *alg)
 
void i_beforeExecute (INamedInterface *alg)
 
void i_afterExecute (INamedInterface *alg)
 
 PerfMonAuditor ()
 
 PerfMonAuditor (const PerfMonAuditor &)
 
PerfMonAuditoroperator= (const PerfMonAuditor &)
 
void startpm ()
 
void pausepm ()
 
void stoppm ()
 
void finalizepm ()
 
int detect_unavail_pmu_regs (int fd, pfmlib_regmask_t *r_pmcs, pfmlib_regmask_t *r_pmds)
 
int detect_unavail_pmcs (int fd, pfmlib_regmask_t *r_pmcs)
 
void pfm_bv_set (uint64_t *bv, uint16_t rnum)
 
int pfm_bv_isset (uint64_t *bv, uint16_t rnum)
 
void pfm_bv_copy (uint64_t *d, uint64_t *j, uint16_t n)
 
void start_smpl ()
 
void stop_smpl ()
 
void finalize_smpl ()
 

Static Private Member Functions

static void process_smpl_buf (pfm_dfl_smpl_hdr_t *hdr, size_t entry_size)
 
static void sigio_handler (int, siginfo_t *, void *)
 

Private Attributes

PFMon & m_pfm
 
Map m_map
 
int m_indent
 
bool m_inEvent
 
int is_nehalem_ret
 
pfmlib_input_param_t inp
 
pfmlib_output_param_t outp
 
pfarg_ctx_t ctx
 
pfarg_pmd_t pd [NUM_PMDS]
 
pfarg_pmc_t pc [NUM_PMCS]
 
pfarg_load_t load_arg
 
int fd
 
unsigned int i
 
int ret
 
std::string event_str [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
std::string prefix
 
std::string family
 
char event_cstr [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
 
char prefix_cstr [MAX_PREFIX_NAME_LENGTH]
 
unsigned int ph_ev_count
 
bool inv [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
unsigned int cmask [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
unsigned int start_at_event
 
pfmlib_core_input_param_t params
 
pfmlib_nhm_input_param_t nhm_params
 
int used_counters_number
 
bool nehalem
 
bool westmere
 
bool core
 
bool sampling
 
pfm_dfl_smpl_arg_t buf_arg
 
pfarg_load_t load_args
 
void * buf_addr
 
unsigned num_counters
 
unsigned int max_pmd
 
pfmlib_options_t pfmlib_options
 
int level
 
bool first_alg
 
std::string first_alg_name
 
bool event_count_reached
 

Additional Inherited Members

- Public Types inherited from Auditor
using Factory = Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.

Author
Daniele Francesco KRUSE danie.nosp@m.le.f.nosp@m.rance.nosp@m.sco..nosp@m.kruse.nosp@m.@cer.nosp@m.n.ch
Date
2009-10-28

Definition at line 202 of file PerfMonAuditor.cpp.

Member Typedef Documentation

Definition at line 357 of file PerfMonAuditor.cpp.

Constructor & Destructor Documentation

PerfMonAuditor::PerfMonAuditor ( const std::string name,
ISvcLocator pSvc 
)
inline

Definition at line 277 of file PerfMonAuditor.cpp.

278  : // standard constructor
279  Auditor( name, pSvc )
280  , m_pfm( PFMon::instance() )
281  , m_map()
282  , m_indent( 0 )
283  , m_inEvent( false )
284  {
286  declareProperty( "EVENT0", event_str[0] );
287  declareProperty( "EVENT1", event_str[1] );
288  declareProperty( "EVENT2", event_str[2] );
289  declareProperty( "EVENT3", event_str[3] );
290  declareProperty( "FAMILY", family );
291  declareProperty( "PREFIX", prefix );
292  declareProperty( "INV0", inv[0] );
293  declareProperty( "INV1", inv[1] );
294  declareProperty( "INV2", inv[2] );
295  declareProperty( "INV3", inv[3] );
296  declareProperty( "CMASK0", cmask[0] );
297  declareProperty( "CMASK1", cmask[1] );
298  declareProperty( "CMASK2", cmask[2] );
299  declareProperty( "CMASK3", cmask[3] );
300  declareProperty( "SP0", sp[0] );
301  declareProperty( "SP1", sp[1] );
302  declareProperty( "SP2", sp[2] );
303  declareProperty( "SP3", sp[3] );
304  declareProperty( "SAMPLE", sampling );
305  declareProperty( "START_AT_EVENT", start_at_event );
306  declareProperty( "IS_NEHALEM", is_nehalem_ret );
307 
309  /*
310  // loading functions from PFM library
311  void* handle = dlopen("libpfm.so", RTLD_NOW);
312  if (!handle) {
313  // error() << "Cannot open library: " << dlerror() << endmsg;
314  }
315  typedef void (*hello_t)();
316  hello_t hello = (hello_t) dlsym(handle, "hello");
317  if (!hello) {
318  // error() << "Cannot load symbol 'hello': " << dlerror() << endmsg;
319  dlclose(handle);
320  }
321 
322  pfm_start = (pfm_start_t) dlsym(handle, "pfm_start");
323  pfm_stop = (pfm_stop_t) dlsym(handle, "pfm_stop");
324  pfm_self_stop = (pfm_self_stop_t) dlsym(handle, "pfm_stop"); //it's the same
325  pfm_restart = (pfm_restart_t) dlsym(handle, "pfm_restart");
326  //pfm_read_pmds = (pfm_read_pmds_t) dlsym(handle, "pfm_read_pmds");
327  pfm_initialize = (pfm_initialize_t) dlsym(handle, "pfm_initialize");
328  pfm_find_full_event = (pfm_find_full_event_t) dlsym(handle, "pfm_find_full_event");
329  pfm_dispatch_events = (pfm_dispatch_events_t) dlsym(handle, "pfm_dispatch_events");
330  pfm_create_context = (pfm_create_context_t) dlsym(handle, "pfm_create_context");
331  pfm_write_pmcs = (pfm_write_pmcs_t) dlsym(handle, "pfm_write_pmcs");
332  pfm_write_pmds = (pfm_write_pmds_t) dlsym(handle, "pfm_write_pmds");
333  pfm_load_context = (pfm_load_context_t) dlsym(handle, "pfm_load_context");
334  pfm_strerror = (pfm_strerror_t) dlsym(handle, "pfm_strerror");
335  pfm_set_options = (pfm_set_options_t) dlsym(handle, "pfm_set_options");
336  pfm_get_num_counters = (pfm_get_num_counters_t) dlsym(handle, "pfm_get_num_counters");
337  // use it to do the calculation
338  // info() << "Calling hello..." << endmsg;
339  // hello();
340 
341  // close the library
342  // info() << "Closing library..." << endmsg;
343  dlclose(handle);
344  */
345 
347  }
std::string family
bool inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
std::string event_str[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
std::string prefix
unsigned int start_at_event
unsigned int cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
virtual PerfMonAuditor::~PerfMonAuditor ( )
inlinevirtual

Definition at line 349 of file PerfMonAuditor.cpp.

349 {} // virtual destructor
PerfMonAuditor::PerfMonAuditor ( )
private
PerfMonAuditor::PerfMonAuditor ( const PerfMonAuditor )
private

Member Function Documentation

void PerfMonAuditor::after ( StandardEventType  evt,
INamedInterface alg,
const StatusCode sc 
)
override

Definition at line 940 of file PerfMonAuditor.cpp.

941 {
942  switch ( evt ) {
944  i_afterInitialize( alg );
945  break;
946  case IAuditor::Execute:
947  i_afterExecute( alg );
948  break;
949  default:
950  break;
951  }
952  return;
953 }
void i_afterExecute(INamedInterface *alg)
void i_afterInitialize(INamedInterface *alg)
evt
Definition: IOTest.py:96
void PerfMonAuditor::before ( StandardEventType  evt,
INamedInterface alg 
)
override

Definition at line 925 of file PerfMonAuditor.cpp.

926 {
927  switch ( evt ) {
929  i_beforeInitialize( alg );
930  break;
931  case IAuditor::Execute:
932  i_beforeExecute( alg );
933  break;
934  default:
935  break;
936  }
937  return;
938 }
void i_beforeExecute(INamedInterface *alg)
void i_beforeInitialize(INamedInterface *alg)
evt
Definition: IOTest.py:96
int PerfMonAuditor::detect_unavail_pmcs ( int  fd,
pfmlib_regmask_t r_pmcs 
)
inlineprivate

Definition at line 396 of file PerfMonAuditor.cpp.

396 { return detect_unavail_pmu_regs( fd, r_pmcs, NULL ); }
int detect_unavail_pmu_regs(int fd, pfmlib_regmask_t *r_pmcs, pfmlib_regmask_t *r_pmds)
int PerfMonAuditor::detect_unavail_pmu_regs ( int  fd,
pfmlib_regmask_t r_pmcs,
pfmlib_regmask_t r_pmds 
)
private
StatusCode PerfMonAuditor::finalize ( )
overridevirtual

Reimplemented from Auditor.

Definition at line 916 of file PerfMonAuditor.cpp.

917 {
918  if ( sampling == 0 )
919  finalizepm();
920  else
921  finalize_smpl();
922  return Auditor::finalize();
923 }
virtual StatusCode finalize()
Definition: Auditor.cpp:195
void PerfMonAuditor::finalize_smpl ( )
private

Definition at line 832 of file PerfMonAuditor.cpp.

833 {
834  int err;
835  for ( int i = 0; i < used_counters_number; i++ ) {
837  filename += '_';
838  filename += event_cstr[i];
839 
840  for ( auto& c : filename )
841  if ( c == ':' ) c = '-';
842 
843  if ( inv[i] ) filename += "_INV_1";
844  if ( cmask[i] > 0 ) filename += "_CMASK_" + std::to_string( cmask[i] );
845  filename += ".txt.gz";
846 
847  gzFile outfile = gzopen( filename.c_str(), "wb" );
848  if ( outfile != NULL ) {
849  if ( nehalem ) {
850  gzprintf( outfile, "NHM " );
851  } else if ( westmere ) {
852  gzprintf( outfile, "WSM " );
853  } else if ( core ) {
854  gzprintf( outfile, "CORE " );
855  }
856  if ( gzprintf( outfile, "%s %d %d %d\n", event_cstr[i], cmask[i], inv[i], sp[i] ) <
857  (int)strlen( event_cstr[i] ) ) {
858  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << ". Aborting..." << endmsg;
859  }
860  for ( std::map<std::string, std::map<unsigned long, unsigned int>>::iterator it = samples[i].begin();
861  it != samples[i].end(); it++ ) {
862  unsigned long long sum = 0;
863  for ( std::map<unsigned long, unsigned int>::iterator jt = ( it->second ).begin(); jt != ( it->second ).end();
864  jt++ ) {
865  sum += jt->second;
866  }
867  if ( gzprintf( outfile, "%s%%%llu\n", ( it->first ).c_str(), sum ) < (int)( ( it->first ).length() ) ) {
868  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << ". Aborting..." << endmsg;
869  }
870  for ( std::map<unsigned long, unsigned int>::iterator jt = ( it->second ).begin(); jt != ( it->second ).end();
871  jt++ ) {
872  char sym_name[SYM_NAME_MAX_LENGTH];
873  bzero( sym_name, SYM_NAME_MAX_LENGTH );
874  const char* libName;
875  const char* symbolName;
876  int libOffset = 0;
877  int offset = 0;
878  void* sym_addr = IgHookTrace::tosymbol( (void*)( jt->first ) );
879  if ( sym_addr != NULL ) {
880  bool success = IgHookTrace::symbol( sym_addr, symbolName, libName, offset, libOffset );
881  if ( success ) {
882  if ( symbolName != NULL && strlen( symbolName ) > 0 ) {
883  strcpy( sym_name, symbolName );
884  strcat( sym_name, " " );
885  } else {
886  strcpy( sym_name, "??? " );
887  }
888  if ( libName != NULL && strlen( libName ) > 0 ) {
889  strcat( sym_name, libName );
890  strcat( sym_name, " " );
891  } else {
892  strcat( sym_name, "??? " );
893  }
894  sprintf( sym_name + strlen( sym_name ), "%d ", libOffset );
895  if ( strlen( sym_name ) <= 0 ) {
896  error() << "ERROR: Symbol name length is zero. Aborting..." << endmsg;
897  }
898  } else {
899  strcpy( sym_name, "??? ??? 0 " );
900  }
901  } else {
902  strcpy( sym_name, "??? ??? 0 " );
903  }
904  if ( gzprintf( outfile, "%s %d\n", sym_name, jt->second ) < (int)strlen( sym_name ) ) {
905  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << endmsg;
906  }
907  }
908  }
909  } else {
910  error() << "ERROR: Could not open file: " << filename << ". Aborting..." << endmsg;
911  }
912  gzclose( outfile );
913  }
914 }
T strcat(T...args)
static void * tosymbol(void *address)
double sum(double x, double y, double z)
bool inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
T to_string(T...args)
#define SYM_NAME_MAX_LENGTH
STL class.
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T strlen(T...args)
static bool symbol(void *address, const char *&sym, const char *&lib, int &offset, int &liboffset)
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
char prefix_cstr[MAX_PREFIX_NAME_LENGTH]
T strcpy(T...args)
unsigned int i
T begin(T...args)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
unsigned int cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
T sprintf(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void PerfMonAuditor::finalizepm ( )
private

Definition at line 528 of file PerfMonAuditor.cpp.

529 {
530  info() << "start of finalizepm ucn:" << used_counters_number << endmsg;
531  for ( int i = 0; i < used_counters_number; i++ ) {
533  filename += '_';
534  filename += event_cstr[i];
535 
536  for ( auto& c : filename )
537  if ( c == ':' ) c = '-';
538 
539  if ( inv[i] ) filename += "_INV_1";
540  if ( cmask[i] > 0 ) filename += "_CMASK_" + std::to_string( cmask[i] );
541  filename += ".txt";
542 
543  info() << "Filename:" << filename << endmsg;
544  FILE* outfile = fopen( filename.c_str(), "w" );
545  if ( nehalem ) {
546  fprintf( outfile, "NHM " );
547  } else if ( westmere ) {
548  fprintf( outfile, "WSM " );
549  } else if ( core ) {
550  fprintf( outfile, "CORE " );
551  }
552  fprintf( outfile, "%s %d %d %d\n", event_cstr[i], cmask[i], inv[i], sp[i] );
553  for ( std::map<std::string, std::vector<unsigned long int>>::iterator it = ( results[i] ).begin();
554  it != ( results[i] ).end(); it++ ) {
555  fprintf( outfile, "%s\n", ( it->first ).c_str() );
556  for ( std::vector<unsigned long int>::iterator j = ( it->second ).begin(); j != ( it->second ).end(); j++ ) {
557  fprintf( outfile, "%lu\n", *j );
558  }
559  }
560  fclose( outfile );
561  }
562 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
T to_string(T...args)
STL class.
T fclose(T...args)
STL class.
T fopen(T...args)
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
char prefix_cstr[MAX_PREFIX_NAME_LENGTH]
unsigned int i
STL class.
T begin(T...args)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
unsigned int cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
T fprintf(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void PerfMonAuditor::i_afterExecute ( INamedInterface alg)
private

Definition at line 1005 of file PerfMonAuditor.cpp.

1006 {
1007  if ( !alg ) {
1008  return;
1009  } // info() << "after:inside! " << alg->name() << endmsg;
1010 
1011  if ( event_count_reached ) {
1012  // info() << "after:inside! " << alg->name() << endmsg;
1013 
1014  if ( sampling == 0 )
1015  stoppm();
1016  else
1017  stop_smpl();
1018  alg_stack.pop();
1019  --m_indent;
1020  if ( !alg_stack.empty() ) {
1021  if ( sampling == 0 )
1022  startpm();
1023  else
1024  start_smpl(); // resuming father algorithm counting
1025  }
1026  }
1027 }
void PerfMonAuditor::i_afterInitialize ( INamedInterface alg)
private

Definition at line 961 of file PerfMonAuditor.cpp.

962 {
963  if ( !alg ) return;
964  return;
965 }
void PerfMonAuditor::i_beforeExecute ( INamedInterface alg)
private

Definition at line 967 of file PerfMonAuditor.cpp.

968 {
969  if ( !alg ) return;
970  // info() << "before:inside! " << alg->name() << endmsg;
971  if ( first_alg ) {
972  first_alg = false;
973  first_alg_name = alg->name();
974  // info() << "first_alg_name= " << alg->name() << endmsg;
975  }
976  if ( !event_count_reached ) {
977  if ( !first_alg_name.compare( alg->name() ) ) {
978  ph_ev_count++;
979  // info() << "EVENT COUNT: " << ph_ev_count << endmsg;
980  if ( ph_ev_count == start_at_event ) {
981  event_count_reached = true;
982  // info() << "!!! EVENT COUNT REACHED: " << ph_ev_count << endmsg;
983  }
984  }
985  }
986  if ( event_count_reached ) {
987  // info() << "before:inside! " << alg->name() << endmsg;
988 
989  if ( !alg_stack.empty() ) {
990  if ( sampling == 0 )
991  pausepm(); // pausing father algorithm counting
992  else
993  stop_smpl();
994  }
995  ++m_indent;
996  std::vector<unsigned long int> zeroes( 4, 0 );
997  alg_stack.push( std::make_pair( alg, zeroes ) );
998  if ( sampling == 0 )
999  startpm();
1000  else
1001  start_smpl();
1002  }
1003 }
std::string first_alg_name
T make_pair(T...args)
unsigned int ph_ev_count
STL class.
unsigned int start_at_event
virtual const std::string & name() const =0
Retrieve the name of the instance.
T compare(T...args)
void PerfMonAuditor::i_beforeInitialize ( INamedInterface alg)
private

Definition at line 955 of file PerfMonAuditor.cpp.

956 {
957  if ( !alg ) return;
958  return;
959 }
StatusCode PerfMonAuditor::initialize ( )
overridevirtual

Reimplemented from Auditor.

Definition at line 564 of file PerfMonAuditor.cpp.

565 {
566  if ( !m_pfm.loaded ) {
567  error() << "pfm library could not be loaded" << endmsg;
568  return StatusCode::FAILURE;
569  }
570 
571  info() << "Initializing..." << endmsg;
573  if ( sc.isFailure() ) {
574  return sc;
575  }
577  for ( int i = 0; i < MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS; i++ ) {
578  if ( event_str[i].length() > 0 ) used_counters_number++;
579  }
580  for ( int i = 0; i < MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS; i++ ) {
581  strcpy( event_cstr[i], event_str[i].c_str() );
582  }
584 
585  if ( m_pfm.pfm_initialize() != PFMLIB_SUCCESS ) {
586  error() << "Cannot initialize perfmon!!" << endmsg;
587  }
588  ph_ev_count = 0;
589  first_alg = true;
590  event_count_reached = false;
591  nehalem = false;
592  core = false;
593  westmere = false;
594  if ( family.compare( "CORE" ) == 0 )
595  core = true;
596  else if ( family.compare( "NEHALEM" ) == 0 )
597  nehalem = true;
598  else if ( family.compare( "WESTMERE" ) == 0 )
599  westmere = true;
600  else {
601  error() << "ERROR: Unsupported processor family " << family << ". aborting..." << endmsg;
602  }
603 
604  info() << "Initialized!" << endmsg;
605  return StatusCode::SUCCESS;
606 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
std::string family
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
#define PFMLIB_SUCCESS
Definition: pfmlib.h:267
bool isFailure() const
Definition: StatusCode.h:139
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::string event_str[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
std::string prefix
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
char prefix_cstr[MAX_PREFIX_NAME_LENGTH]
T strcpy(T...args)
unsigned int i
unsigned int ph_ev_count
T c_str(T...args)
virtual StatusCode initialize()
Definition: Auditor.cpp:65
#define MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
T compare(T...args)
int PerfMonAuditor::is_nehalem ( )
inline

Definition at line 219 of file PerfMonAuditor.cpp.

220  {
221 #ifdef __ICC
222 // Disable ICC remark #593: variable "x" was set but never used
223 #pragma warning( push )
224 #pragma warning( disable : 593 )
225 #endif
226  int a, b, c, d;
227  cpuid( 1, a, b, c, d );
228  int sse4_2_mask = 1 << 20;
229  if ( c & sse4_2_mask )
230  return 1;
231  else
232  return 0;
233 #ifdef __ICC
234 #pragma warning( pop )
235 #endif
236  }
#define cpuid(func, ax, bx, cx, dx)
PerfMonAuditor& PerfMonAuditor::operator= ( const PerfMonAuditor )
private
void PerfMonAuditor::pausepm ( )
private

Definition at line 511 of file PerfMonAuditor.cpp.

512 {
513  m_pfm.pfm_stop( fd );
514  if ( m_pfm.pfm_read_pmds( fd, pd, inp.pfp_event_count ) == -1 ) {
515  error() << "Could not read pmds" << endmsg;
516  }
517 
518  for ( int i = 0; i < used_counters_number; i++ ) {
519  alg_stack.top().second[i] += pd[i].reg_value;
520  }
521 
522  close( fd );
523 }
pfmlib_input_param_t inp
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
pfarg_pmd_t pd[NUM_PMDS]
unsigned int i
uint64_t reg_value
Definition: perfmon_v2.h:42
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
unsigned int pfp_event_count
Definition: pfmlib.h:108
void PerfMonAuditor::pfm_bv_copy ( uint64_t d,
uint64_t j,
uint16_t  n 
)
inlineprivate

Definition at line 402 of file PerfMonAuditor.cpp.

403  {
404  if ( n <= BPL )
405  *d = *j;
406  else {
407  memcpy( d, j, ( n >> LBPL ) * sizeof( uint64_t ) );
408  }
409  }
unsigned long long uint64_t
Definition: instrset.h:143
T memcpy(T...args)
#define LBPL
#define BPL
int PerfMonAuditor::pfm_bv_isset ( uint64_t bv,
uint16_t  rnum 
)
inlineprivate

Definition at line 398 of file PerfMonAuditor.cpp.

399  {
400  return bv[rnum >> LBPL] & ( 1UL << ( rnum & ( BPL - 1 ) ) ) ? 1 : 0;
401  }
#define LBPL
#define BPL
void PerfMonAuditor::pfm_bv_set ( uint64_t bv,
uint16_t  rnum 
)
inlineprivate

Definition at line 397 of file PerfMonAuditor.cpp.

397 { bv[rnum >> LBPL] |= 1UL << ( rnum & ( BPL - 1 ) ); }
#define LBPL
#define BPL
void PerfMonAuditor::process_smpl_buf ( pfm_dfl_smpl_hdr_t hdr,
size_t  entry_size 
)
staticprivate

Definition at line 612 of file PerfMonAuditor.cpp.

613 {
616  size_t pos, count;
617  uint64_t entry;
618  if ( hdr->hdr_overflows == last_overflow && hdr->hdr_count == last_count ) {
619  printf( "skipping identical set of samples...\n" );
620  return;
621  }
622  count = hdr->hdr_count;
623  ent = (pfm_dfl_smpl_entry_t*)( hdr + 1 );
624  pos = (unsigned long)ent;
625  entry = collected_samples;
626  while ( count-- ) {
627  // if(ent->ovfl_pmd>=0 && ent->ovfl_pmd<=3)
628  if ( ent->ovfl_pmd <= 3 ) {
629  ( ( samples[ent->ovfl_pmd] )[( alg_stack.top().first )->name()] )[(unsigned long)( ent->ip )]++;
630  }
631  pos += entry_size;
632  ent = (pfm_dfl_smpl_entry_t*)pos;
633  entry++;
634  }
635  collected_samples = entry;
636  last_overflow = hdr->hdr_overflows;
637  if ( last_count != hdr->hdr_count && ( last_count || last_overflow == 0 ) ) {
638  collected_partial += hdr->hdr_count;
639  }
640  last_count = hdr->hdr_count;
641  return;
642 }
unsigned long long uint64_t
Definition: instrset.h:143
uint16_t ovfl_pmd
uint64_t ip
T count(T...args)
T printf(T...args)
const std::string & name() const override
Definition: Auditor.cpp:197
void PerfMonAuditor::sigio_handler ( int  ,
siginfo_t *  ,
void *   
)
staticprivate

Definition at line 648 of file PerfMonAuditor.cpp.

649 {
650  PFMon& pfm = PFMon::instance();
652  int fd = ctx_fd;
653  int r;
654  if ( fd != ctx_fd ) {
655  // error() << "ERROR: handler does not get valid file descriptor. Aborting..." << endmsg;
656  }
657  if ( pfm.pfm_read_pmds( fd, pd_smpl + 1, 1 ) == -1 ) {
658  // error() << "ERROR: pfm_read_pmds: " << strerror(errno) << ". Aborting..." << endmsg;
659  }
660  while ( true ) {
661  r = read( fd, &msg, sizeof( msg ) );
662  if ( r != sizeof( msg ) ) {
663  if ( r == -1 && errno == EINTR ) {
664  printf( "read interrupted, retrying\n" );
665  continue;
666  }
667  // error() << "ERROR: cannot read overflow message: " << strerror(errno) << ". Aborting..." << endmsg;
668  }
669  break;
670  }
671  switch ( msg.type ) {
672  case PFM_MSG_OVFL: // the sampling buffer is full
673  process_smpl_buf( hdr, entry_size );
674  ovfl_count++;
675  if ( pfm.pfm_restart( fd ) ) {
676  if ( errno != EBUSY ) {
677  // error() << "ERROR: pfm_restart error errno " << errno << ". Aborting..." << endmsg;
678  } else {
679  printf( "pfm_restart: task probably terminated \n" );
680  }
681  }
682  break;
683  default:
684  // error() << "ERROR: unknown message type " << msg.type << ". Aborting..." << endmsg;
685  break;
686  }
687 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
uint32_t type
Definition: perfmon.h:206
static void process_smpl_buf(pfm_dfl_smpl_hdr_t *hdr, size_t entry_size)
#define PFM_MSG_OVFL
Definition: perfmon.h:210
T printf(T...args)
void PerfMonAuditor::start_smpl ( )
private

Definition at line 693 of file PerfMonAuditor.cpp.

694 {
695  ovfl_count = 0;
696  num_smpl_pmds = 0;
697  last_overflow = ~0;
698  max_pmd = 0;
699  memset( &pfmlib_options, 0, sizeof( pfmlib_options ) );
702  m_pfm.pfm_set_options( &pfmlib_options );
703  ret = m_pfm.pfm_initialize();
704  if ( ret != PFMLIB_SUCCESS ) {
705  error() << "ERROR: Cannot initialize library: " << m_pfm.pfm_strerror( ret ) << ". Aborting..." << endmsg;
706  }
707  struct sigaction act;
708  memset( &act, 0, sizeof( act ) );
709  act.sa_sigaction = sigio_handler; // dlopen() ==>
710  // act.sa_handler = (sig_t)&sigio_handler;
711  sigaction( SIGIO, &act, 0 );
712  memset( &ctx, 0, sizeof( ctx ) );
713  memset( &buf_arg, 0, sizeof( buf_arg ) );
714  memset( &inp, 0, sizeof( inp ) );
715  memset( &outp, 0, sizeof( outp ) );
716  memset( pd_smpl, 0, sizeof( pd_smpl ) );
717  memset( pc, 0, sizeof( pc ) );
718  memset( &load_args, 0, sizeof( load_args ) );
719  m_pfm.pfm_get_num_counters( &num_counters );
720  memset( &params, 0, sizeof( params ) );
721  memset( &nhm_params, 0, sizeof( nhm_params ) );
722 
723  for ( int i = 0; i < used_counters_number; i++ ) {
724  ret = m_pfm.pfm_find_full_event( event_cstr[i], &inp.pfp_events[i] );
725  if ( ret != PFMLIB_SUCCESS ) {
726  error() << "ERROR: cannot find event: " << event_cstr[i] << ". Aborting..." << endmsg;
727  }
728  }
730  inp.pfp_event_count = 4;
731  for ( int i = 0; i < used_counters_number; i++ ) {
732  if ( inv[i] ) {
735  }
736  if ( cmask[i] > 0 ) {
737  ( params.pfp_core_counters[i] ).cnt_mask = cmask[i];
738  ( nhm_params.pfp_nhm_counters[i] ).cnt_mask = cmask[i];
739  }
740  }
741  if ( nehalem || westmere ) {
742  ret = m_pfm.pfm_dispatch_events( &inp, &nhm_params, &outp, NULL );
743  } else {
744  ret = m_pfm.pfm_dispatch_events( &inp, &params, &outp, NULL );
745  }
746  if ( ret != PFMLIB_SUCCESS ) {
747  error() << "ERROR: cannot configure events: " << m_pfm.pfm_strerror( ret ) << ". Aborting..." << endmsg;
748  }
749  for ( unsigned int i = 0; i < outp.pfp_pmc_count; i++ ) {
752  }
753  for ( unsigned int i = 0; i < outp.pfp_pmd_count; i++ ) {
754  pd_smpl[i].reg_num = outp.pfp_pmds[i].reg_num;
755  if ( i ) {
756  pfm_bv_set( pd_smpl[0].reg_smpl_pmds, pd_smpl[i].reg_num );
757  if ( pd_smpl[i].reg_num > max_pmd ) {
758  max_pmd = pd_smpl[i].reg_num;
759  }
760  num_smpl_pmds++;
761  }
762  }
763  for ( int i = 0; i < used_counters_number; i++ ) {
765  pfm_bv_copy( pd_smpl[i].reg_reset_pmds, pd_smpl[i].reg_smpl_pmds, max_pmd );
766  pd_smpl[i].reg_value = ( uint64_t )( sp[i] * -1 );
767  pd_smpl[i].reg_short_reset = ( uint64_t )( sp[i] * -1 );
768  pd_smpl[i].reg_long_reset = ( uint64_t )( sp[i] * -1 );
769  pd_smpl[i].reg_random_seed = 5; // tocheck
770  pd_smpl[i].reg_random_mask = 0xff; // tocheck
771  }
772  entry_size = sizeof( pfm_dfl_smpl_entry_t ) + ( num_smpl_pmds << 3 );
773  ctx.ctx_flags = 0;
774  buf_arg.buf_size = 3 * getpagesize() + 512;
775  ctx_fd = m_pfm.pfm_create_context( &ctx, (char*)FMT_NAME, &buf_arg, sizeof( buf_arg ) );
776  if ( ctx_fd == -1 ) {
777  if ( errno == ENOSYS ) {
778  error() << "ERROR: Your kernel does not have performance monitoring support! Aborting..." << endmsg;
779  }
780  error() << "ERROR: Can't create PFM context " << strerror( errno ) << ". Aborting..." << endmsg;
781  }
782  buf_addr = mmap( NULL, (size_t)buf_arg.buf_size, PROT_READ, MAP_PRIVATE, ctx_fd, 0 );
783  if ( buf_addr == MAP_FAILED ) {
784  error() << "ERROR: cannot mmap sampling buffer: " << strerror( errno ) << ". Aborting..." << endmsg;
785  }
787  if ( PFM_VERSION_MAJOR( hdr->hdr_version ) < 1 ) {
788  error() << "ERROR: invalid buffer format version. Aborting..." << endmsg;
789  }
790  if ( m_pfm.pfm_write_pmcs( ctx_fd, pc, outp.pfp_pmc_count ) ) {
791  error() << "ERROR: pfm_write_pmcs error errno " << strerror( errno ) << ". Aborting..." << endmsg;
792  }
793  if ( m_pfm.pfm_write_pmds( ctx_fd, pd_smpl, outp.pfp_pmd_count ) ) {
794  error() << "ERROR: pfm_write_pmds error errno " << strerror( errno ) << ". Aborting..." << endmsg;
795  }
796  load_args.load_pid = getpid();
797  if ( m_pfm.pfm_load_context( ctx_fd, &load_args ) ) {
798  error() << "ERROR: pfm_load_context error errno " << strerror( errno ) << ". Aborting..." << endmsg;
799  }
800  ret = fcntl( ctx_fd, F_SETFL, fcntl( ctx_fd, F_GETFL, 0 ) | O_ASYNC );
801  if ( ret == -1 ) {
802  error() << "ERROR: cannot set ASYNC: " << strerror( errno ) << ". Aborting..." << endmsg;
803  }
804  ret = fcntl( ctx_fd, F_SETOWN, getpid() );
805  if ( ret == -1 ) {
806  error() << "ERROR: cannot setown: " << strerror( errno ) << ". Aborting..." << endmsg;
807  }
808  // pfm_self_start(ctx_fd); ==>
809  m_pfm.pfm_start( ctx_fd, NULL );
810 }
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
Definition: pfmlib.h:129
pfarg_load_t load_args
uint64_t reg_short_reset
Definition: perfmon_v2.h:44
pfmlib_core_input_param_t params
#define PFM_REGFL_OVFL_NOTIFY
Definition: perfmon.h:112
#define PFM_NHM_SEL_INV
#define PFM_PLM3
Definition: pfmlib.h:53
pfmlib_event_t pfp_events[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:112
#define PFM_CORE_SEL_INV
Definition: pfmlib_core.h:68
pfmlib_nhm_counter_t pfp_nhm_counters[PMU_NHM_NUM_COUNTERS]
T strerror(T...args)
bool inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
#define PFMLIB_SUCCESS
Definition: pfmlib.h:267
unsigned int pfm_verbose
Definition: pfmlib.h:138
unsigned int pfp_dfl_plm
Definition: pfmlib.h:109
uint16_t reg_num
Definition: perfmon_v2.h:39
unsigned long long uint64_t
Definition: instrset.h:143
T memset(T...args)
pfmlib_input_param_t inp
unsigned int pfp_pmc_count
Definition: pfmlib.h:126
pfmlib_options_t pfmlib_options
unsigned long long reg_value
Definition: pfmlib.h:97
unsigned int pfp_pmd_count
Definition: pfmlib.h:127
uint32_t reg_random_seed
Definition: perfmon_v2.h:51
uint64_t reg_long_reset
Definition: perfmon_v2.h:43
pfmlib_nhm_input_param_t nhm_params
#define PFM_VERSION_MAJOR(x)
Definition: perfmon.h:213
uint32_t ctx_flags
Definition: perfmon_v2.h:19
void pfm_bv_copy(uint64_t *d, uint64_t *j, uint16_t n)
void pfm_bv_set(uint64_t *bv, uint16_t rnum)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
uint32_t reg_flags
Definition: perfmon_v2.h:41
unsigned int pfm_debug
Definition: pfmlib.h:137
unsigned int reg_num
Definition: pfmlib.h:99
pfmlib_output_param_t outp
uint16_t reg_num
Definition: perfmon_v2.h:28
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
uint32_t load_pid
Definition: perfmon_v2.h:69
unsigned int i
pfarg_pmc_t pc[NUM_PMCS]
#define FMT_NAME
#define PFM_REGFL_RANDOM
Definition: perfmon.h:113
pfm_dfl_smpl_arg_t buf_arg
static void sigio_handler(int, siginfo_t *, void *)
uint64_t reg_value
Definition: perfmon_v2.h:31
unsigned int max_pmd
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:128
uint64_t reg_random_mask
Definition: perfmon_v2.h:50
pfmlib_core_counter_t pfp_core_counters[PMU_CORE_NUM_COUNTERS]
Definition: pfmlib_core.h:79
unsigned int cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
uint64_t reg_value
Definition: perfmon_v2.h:42
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
unsigned int pfp_event_count
Definition: pfmlib.h:108
void PerfMonAuditor::startpm ( )
private

Definition at line 430 of file PerfMonAuditor.cpp.

431 {
432  memset( &ctx, 0, sizeof( ctx ) );
433  memset( &inp, 0, sizeof( inp ) );
434  memset( &outp, 0, sizeof( outp ) );
435  memset( pd, 0, sizeof( pd ) );
436  memset( pc, 0, sizeof( pc ) );
437  memset( &load_arg, 0, sizeof( load_arg ) );
438  memset( &params, 0, sizeof( params ) );
439  memset( &nhm_params, 0, sizeof( nhm_params ) );
440 
441  for ( int i = 0; i < used_counters_number; i++ ) {
442  ret = m_pfm.pfm_find_full_event( event_cstr[i], &inp.pfp_events[i] );
443  if ( ret != PFMLIB_SUCCESS ) {
444  error() << "ERROR: cannot find event: " << event_cstr[i] << ". Aborting..." << endmsg;
445  }
446  }
448  inp.pfp_event_count = 4;
449  for ( int i = 0; i < used_counters_number; i++ ) {
450  if ( inv[i] ) {
453  }
454  if ( cmask[i] > 0 ) {
455  ( params.pfp_core_counters[i] ).cnt_mask = cmask[i];
456  ( nhm_params.pfp_nhm_counters[i] ).cnt_mask = cmask[i];
457  }
458  }
459  if ( nehalem || westmere ) {
460  ret = m_pfm.pfm_dispatch_events( &inp, &nhm_params, &outp, NULL );
461  } else {
462  ret = m_pfm.pfm_dispatch_events( &inp, &params, &outp, NULL );
463  }
464  if ( ret != PFMLIB_SUCCESS ) {
465  error() << "ERROR: cannot dispatch events: " << m_pfm.pfm_strerror( ret ) << ". Aborting..." << endmsg;
466  }
467  for ( unsigned int i = 0; i < outp.pfp_pmc_count; i++ ) {
470  }
471  for ( unsigned int i = 0; i < outp.pfp_pmd_count; i++ ) {
473  pd[i].reg_value = 0;
474  }
475  fd = m_pfm.pfm_create_context( &ctx, NULL, 0, 0 );
476  if ( fd == -1 ) {
477  error() << "ERROR: Context not created. Aborting..." << endmsg;
478  }
479  if ( m_pfm.pfm_write_pmcs( fd, pc, outp.pfp_pmc_count ) == -1 ) {
480  error() << "ERROR: Could not write pmcs. Aborting..." << endmsg;
481  }
482  if ( m_pfm.pfm_write_pmds( fd, pd, outp.pfp_pmd_count ) == -1 ) {
483  error() << "ERROR: Could not write pmds. Aborting..." << endmsg;
484  }
485  load_arg.load_pid = getpid();
486  if ( m_pfm.pfm_load_context( fd, &load_arg ) == -1 ) {
487  error() << "ERROR: Could not load context. Aborting..." << endmsg;
488  // error() << "Could not read pmds" << endmsg;
489  }
490 
491  m_pfm.pfm_start( fd, NULL );
492 }
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
Definition: pfmlib.h:129
pfmlib_core_input_param_t params
#define PFM_NHM_SEL_INV
#define PFM_PLM3
Definition: pfmlib.h:53
pfmlib_event_t pfp_events[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:112
#define PFM_CORE_SEL_INV
Definition: pfmlib_core.h:68
pfmlib_nhm_counter_t pfp_nhm_counters[PMU_NHM_NUM_COUNTERS]
bool inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
#define PFMLIB_SUCCESS
Definition: pfmlib.h:267
unsigned int pfp_dfl_plm
Definition: pfmlib.h:109
uint16_t reg_num
Definition: perfmon_v2.h:39
T memset(T...args)
pfmlib_input_param_t inp
unsigned int pfp_pmc_count
Definition: pfmlib.h:126
unsigned long long reg_value
Definition: pfmlib.h:97
unsigned int pfp_pmd_count
Definition: pfmlib.h:127
pfmlib_nhm_input_param_t nhm_params
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
unsigned int reg_num
Definition: pfmlib.h:99
pfmlib_output_param_t outp
uint16_t reg_num
Definition: perfmon_v2.h:28
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
pfarg_pmd_t pd[NUM_PMDS]
uint32_t load_pid
Definition: perfmon_v2.h:69
unsigned int i
pfarg_pmc_t pc[NUM_PMCS]
uint64_t reg_value
Definition: perfmon_v2.h:31
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:128
pfmlib_core_counter_t pfp_core_counters[PMU_CORE_NUM_COUNTERS]
Definition: pfmlib_core.h:79
unsigned int cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
pfarg_load_t load_arg
uint64_t reg_value
Definition: perfmon_v2.h:42
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
unsigned int pfp_event_count
Definition: pfmlib.h:108
void PerfMonAuditor::stop_smpl ( )
private

Definition at line 816 of file PerfMonAuditor.cpp.

817 {
818  m_pfm.pfm_self_stop( ctx_fd );
819  process_smpl_buf( hdr, entry_size );
820  close( ctx_fd );
821  ret = munmap( hdr, (size_t)buf_arg.buf_size );
822  if ( ret ) {
823  error() << "Cannot unmap buffer: %s" << strerror( errno ) << endmsg;
824  }
825  return;
826 }
T strerror(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
static void process_smpl_buf(pfm_dfl_smpl_hdr_t *hdr, size_t entry_size)
pfm_dfl_smpl_arg_t buf_arg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void PerfMonAuditor::stoppm ( )
private

Definition at line 498 of file PerfMonAuditor.cpp.

499 {
500  m_pfm.pfm_stop( fd );
501  if ( m_pfm.pfm_read_pmds( fd, pd, inp.pfp_event_count ) == -1 ) {
502  error() << "Could not read pmds" << endmsg;
503  }
504  for ( int i = 0; i < used_counters_number; i++ ) {
505  results[i][( alg_stack.top().first )->name()].push_back( alg_stack.top().second[i] + pd[i].reg_value );
506  }
507 
508  close( fd );
509 }
pfmlib_input_param_t inp
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
pfarg_pmd_t pd[NUM_PMDS]
unsigned int i
const std::string & name() const override
Definition: Auditor.cpp:197
uint64_t reg_value
Definition: perfmon_v2.h:42
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
unsigned int pfp_event_count
Definition: pfmlib.h:108

Member Data Documentation

void* PerfMonAuditor::buf_addr
private

Definition at line 418 of file PerfMonAuditor.cpp.

pfm_dfl_smpl_arg_t PerfMonAuditor::buf_arg
private

Definition at line 416 of file PerfMonAuditor.cpp.

unsigned int PerfMonAuditor::cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 385 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::core
private

Definition at line 392 of file PerfMonAuditor.cpp.

pfarg_ctx_t PerfMonAuditor::ctx
private

Definition at line 367 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::event_count_reached
private

Definition at line 427 of file PerfMonAuditor.cpp.

char PerfMonAuditor::event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
private

Definition at line 381 of file PerfMonAuditor.cpp.

std::string PerfMonAuditor::event_str[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 378 of file PerfMonAuditor.cpp.

std::string PerfMonAuditor::family
private

Definition at line 380 of file PerfMonAuditor.cpp.

int PerfMonAuditor::fd
private

Definition at line 371 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::first_alg
private

Definition at line 425 of file PerfMonAuditor.cpp.

std::string PerfMonAuditor::first_alg_name
private

Definition at line 426 of file PerfMonAuditor.cpp.

unsigned int PerfMonAuditor::i
private

Definition at line 372 of file PerfMonAuditor.cpp.

pfmlib_input_param_t PerfMonAuditor::inp
private

Definition at line 365 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 384 of file PerfMonAuditor.cpp.

int PerfMonAuditor::is_nehalem_ret
private

Definition at line 363 of file PerfMonAuditor.cpp.

int PerfMonAuditor::level
private

Definition at line 423 of file PerfMonAuditor.cpp.

pfarg_load_t PerfMonAuditor::load_arg
private

Definition at line 370 of file PerfMonAuditor.cpp.

pfarg_load_t PerfMonAuditor::load_args
private

Definition at line 417 of file PerfMonAuditor.cpp.

int PerfMonAuditor::m_indent
private

Definition at line 359 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::m_inEvent
private

Definition at line 360 of file PerfMonAuditor.cpp.

Map PerfMonAuditor::m_map
private

Definition at line 358 of file PerfMonAuditor.cpp.

PFMon& PerfMonAuditor::m_pfm
private

Definition at line 239 of file PerfMonAuditor.cpp.

unsigned int PerfMonAuditor::max_pmd
private

Definition at line 420 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::nehalem
private

Definition at line 390 of file PerfMonAuditor.cpp.

pfmlib_nhm_input_param_t PerfMonAuditor::nhm_params
private

Definition at line 388 of file PerfMonAuditor.cpp.

unsigned PerfMonAuditor::num_counters
private

Definition at line 419 of file PerfMonAuditor.cpp.

pfmlib_output_param_t PerfMonAuditor::outp
private

Definition at line 366 of file PerfMonAuditor.cpp.

pfmlib_core_input_param_t PerfMonAuditor::params
private

Definition at line 387 of file PerfMonAuditor.cpp.

pfarg_pmc_t PerfMonAuditor::pc[NUM_PMCS]
private

Definition at line 369 of file PerfMonAuditor.cpp.

pfarg_pmd_t PerfMonAuditor::pd[NUM_PMDS]
private

Definition at line 368 of file PerfMonAuditor.cpp.

pfmlib_options_t PerfMonAuditor::pfmlib_options
private

Definition at line 421 of file PerfMonAuditor.cpp.

unsigned int PerfMonAuditor::ph_ev_count
private

Definition at line 383 of file PerfMonAuditor.cpp.

std::string PerfMonAuditor::prefix
private

Definition at line 379 of file PerfMonAuditor.cpp.

char PerfMonAuditor::prefix_cstr[MAX_PREFIX_NAME_LENGTH]
private

Definition at line 382 of file PerfMonAuditor.cpp.

int PerfMonAuditor::ret
private

Definition at line 373 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::sampling
private

Definition at line 394 of file PerfMonAuditor.cpp.

unsigned int PerfMonAuditor::start_at_event
private

Definition at line 386 of file PerfMonAuditor.cpp.

int PerfMonAuditor::used_counters_number
private

Definition at line 389 of file PerfMonAuditor.cpp.

bool PerfMonAuditor::westmere
private

Definition at line 391 of file PerfMonAuditor.cpp.


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