The Gaudi Framework  v33r0 (d5ea422b)
PerfMonAuditor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include "GaudiKernel/Auditor.h"
12 #include "GaudiKernel/HashMap.h"
15 #include "GaudiKernel/IToolSvc.h"
16 #include "GaudiKernel/MsgStream.h"
17 #include "GaudiKernel/VectorMap.h"
18 
19 /*BEGIN: perfmon*/
20 #include <cstring>
21 #include <fstream>
22 #include <iostream>
23 #include <map>
24 #include <perfmon/pfmlib.h>
25 #include <perfmon/pfmlib_core.h>
27 #include <sstream>
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 #include <perfmon/perfmon.h>
34 
36 
38 
39 #include <errno.h>
40 #include <fcntl.h>
41 #include <getopt.h>
42 #include <signal.h>
43 #include <stdarg.h>
44 #include <stdint.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <sys/mman.h>
49 #include <sys/ptrace.h>
50 #include <sys/resource.h>
51 #include <sys/time.h>
52 #include <sys/types.h>
53 #include <sys/wait.h>
54 #include <time.h>
55 #include <unistd.h>
56 #include <zlib.h>
57 
58 #include "IgHook_IgHookTrace.h"
59 #include <algorithm>
60 #include <cmath>
61 #include <list>
62 #include <stack>
63 #include <sys/stat.h>
64 
65 // dlopen (link with -ldl)
66 #include <dlfcn.h>
67 
68 #define MAX_EVT_NAME_LEN 256
69 #define NUM_PMCS PFMLIB_MAX_PMCS
70 #define NUM_PMDS PFMLIB_MAX_PMDS
71 #define FMT_NAME PFM_DFL_SMPL_NAME
72 #define BPL ( sizeof( uint64_t ) << 3 )
73 #define LBPL 6
74 
75 #define SYM_NAME_MAX_LENGTH 10000
76 #define MAX_OUTPUT_FILENAME_LENGTH 1024
77 #define MAX_EVENT_NAME_LENGTH 500
78 #define MAX_PREFIX_NAME_LENGTH 1024
79 #define FILENAME_MAX_LENGTH 1024
80 
81 #define MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS 4
82 
83 #define cpuid( func, ax, bx, cx, dx ) \
84  __asm__ __volatile__( "cpuid" : "=a"( ax ), "=b"( bx ), "=c"( cx ), "=d"( dx ) : "a"( func ) );
85 
86 static pfarg_pmd_t pd_smpl[NUM_PMDS];
87 static uint64_t collected_samples, collected_partial;
88 static int ctx_fd;
89 static pfm_dfl_smpl_hdr_t* hdr;
90 static uint64_t ovfl_count;
91 static size_t entry_size;
92 static unsigned int num_smpl_pmds;
94  samples( MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS ); // a map of modules each containing numbers of samples of their
95  // addresses
97  results( MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS ); // a map of modules and their result values across multiple events
98 static uint64_t last_overflow;
99 static uint64_t last_count;
101 
103 /*END: perfmon*/
104 
105 namespace {
107  template <typename T>
108  inline T function_cast( void* p ) {
109  union {
110  void* object;
111  T function;
112  } caster;
113  caster.object = p;
114  return caster.function;
115  }
116  class PFMon {
117  public:
118  bool loaded;
119  typedef void ( *pfm_stop_t )( int );
120  pfm_stop_t pfm_stop{nullptr};
121  typedef void ( *pfm_self_stop_t )( int );
122  pfm_self_stop_t pfm_self_stop{nullptr};
123  typedef os_err_t ( *pfm_restart_t )( int );
124  pfm_restart_t pfm_restart{nullptr};
125  typedef int ( *pfm_read_pmds_t )( int, pfarg_pmd_t*, int );
126  pfm_read_pmds_t pfm_read_pmds{nullptr};
127  typedef pfm_err_t ( *pfm_initialize_t )();
128  pfm_initialize_t pfm_initialize{nullptr};
129  typedef pfm_err_t ( *pfm_find_full_event_t )( const char*, pfmlib_event_t* );
130  pfm_find_full_event_t pfm_find_full_event{nullptr};
131  typedef pfm_err_t ( *pfm_dispatch_events_t )( pfmlib_input_param_t*, void*, pfmlib_output_param_t*, void* );
132  pfm_dispatch_events_t pfm_dispatch_events{nullptr};
133  typedef os_err_t ( *pfm_create_context_t )( pfarg_ctx_t*, char*, void*, size_t );
134  pfm_create_context_t pfm_create_context{nullptr};
135  typedef os_err_t ( *pfm_write_pmcs_t )( int, pfarg_pmc_t*, int );
136  pfm_write_pmcs_t pfm_write_pmcs{nullptr};
137  typedef os_err_t ( *pfm_write_pmds_t )( int, pfarg_pmd_t*, int );
138  pfm_write_pmds_t pfm_write_pmds{nullptr};
139  typedef os_err_t ( *pfm_load_context_t )( int, pfarg_load_t* );
140  pfm_load_context_t pfm_load_context{nullptr};
141  typedef os_err_t ( *pfm_start_t )( int fd, pfarg_start_t* );
142  pfm_start_t pfm_start{nullptr};
143  typedef char* ( *pfm_strerror_t )( int );
144  pfm_strerror_t pfm_strerror{nullptr};
145  typedef pfm_err_t ( *pfm_set_options_t )( pfmlib_options_t* );
146  pfm_set_options_t pfm_set_options{nullptr};
147  typedef pfm_err_t ( *pfm_get_num_counters_t )( unsigned int* );
148  pfm_get_num_counters_t pfm_get_num_counters{nullptr};
149  static PFMon& instance() { return s_instance; }
150 
151  private:
152  // static void failure() { throw 1; }
153 
154  void* handle;
155 
156  PFMon() {
157  handle = dlopen( "libpfm.so", RTLD_NOW );
158  if ( handle ) {
159  loaded = true;
160  } else {
161  loaded = false;
162  }
163  if ( loaded ) {
164  pfm_start = function_cast<pfm_start_t>( dlsym( handle, "pfm_start" ) );
165  pfm_stop = function_cast<pfm_stop_t>( dlsym( handle, "pfm_stop" ) );
166  pfm_self_stop = function_cast<pfm_self_stop_t>( dlsym( handle, "pfm_stop" ) ); // it's the same
167  pfm_restart = function_cast<pfm_restart_t>( dlsym( handle, "pfm_restart" ) );
168  pfm_read_pmds = function_cast<pfm_read_pmds_t>( dlsym( handle, "pfm_read_pmds" ) );
169  pfm_initialize = function_cast<pfm_initialize_t>( dlsym( handle, "pfm_initialize" ) );
170  pfm_find_full_event = function_cast<pfm_find_full_event_t>( dlsym( handle, "pfm_find_full_event" ) );
171  pfm_dispatch_events = function_cast<pfm_dispatch_events_t>( dlsym( handle, "pfm_dispatch_events" ) );
172  pfm_create_context = function_cast<pfm_create_context_t>( dlsym( handle, "pfm_create_context" ) );
173  pfm_write_pmcs = function_cast<pfm_write_pmcs_t>( dlsym( handle, "pfm_write_pmcs" ) );
174  pfm_write_pmds = function_cast<pfm_write_pmds_t>( dlsym( handle, "pfm_write_pmds" ) );
175  pfm_load_context = function_cast<pfm_load_context_t>( dlsym( handle, "pfm_load_context" ) );
176  pfm_strerror = function_cast<pfm_strerror_t>( dlsym( handle, "pfm_strerror" ) );
177  pfm_set_options = function_cast<pfm_set_options_t>( dlsym( handle, "pfm_set_options" ) );
178  pfm_get_num_counters = function_cast<pfm_get_num_counters_t>( dlsym( handle, "pfm_get_num_counters" ) );
179  } else {
180  // pfm_start = pfm_stop = pfm_self_stop = pfm_restart = pfm_read_pmds = pfm_initialize = pfm_find_full_event =
181  // pfm_dispatch_events = pfm_create_context = pfm_write_pmcs = pfm_write_pmds = pfm_load_context = pfm_strerror
182  // = pfm_set_options = pfm_get_num_counters = failure;
183  }
184  }
185  ~PFMon() {
186  if ( handle ) dlclose( handle );
187  }
188 
189  static PFMon s_instance;
190  };
191 
192  PFMon PFMon::s_instance;
193 } // namespace
194 
195 // ============================================================================
196 // GaudiAlg
197 // ============================================================================
198 // ============================================================================
208 class PerfMonAuditor : virtual public Auditor {
209 public:
210  void before( StandardEventType evt, INamedInterface* alg ) override;
211  void after( StandardEventType evt, INamedInterface* alg, const StatusCode& sc ) override;
212  using Auditor::after;
213  using Auditor::before;
214 
215 private:
220 
221 public:
222  StatusCode initialize() override;
223  StatusCode finalize() override;
224  int is_nehalem() {
225 #ifdef __ICC
226 // Disable ICC remark #593: variable "x" was set but never used
227 # pragma warning( push )
228 # pragma warning( disable : 593 )
229 #endif
230  int a, b, c, d;
231  cpuid( 1, a, b, c, d );
232  int sse4_2_mask = 1 << 20;
233  if ( c & sse4_2_mask )
234  return 1;
235  else
236  return 0;
237 #ifdef __ICC
238 # pragma warning( pop )
239 #endif
240  }
241 
242 private:
243  PFMon& m_pfm;
244  /*
245  typedef void (*pfm_stop_t)(int);
246  pfm_stop_t pfm_stop;
247  typedef void (*pfm_self_stop_t)(int);
248  pfm_self_stop_t pfm_self_stop;
249 
250  typedef os_err_t (*pfm_restart_t)(int);
251  pfm_restart_t pfm_restart;
252 
253  //typedef int (*pfm_read_pmds_t)(int, pfarg_pmd_t*, int);
254  //pfm_read_pmds_t pfm_read_pmds;
255 
256  typedef pfm_err_t (*pfm_initialize_t)();
257  pfm_initialize_t pfm_initialize;
258  typedef pfm_err_t (*pfm_find_full_event_t)(const char *, pfmlib_event_t *);
259  pfm_find_full_event_t pfm_find_full_event;
260  typedef pfm_err_t (*pfm_dispatch_events_t)(pfmlib_input_param_t *, void *, pfmlib_output_param_t *, void *);
261  pfm_dispatch_events_t pfm_dispatch_events;
262  typedef os_err_t (*pfm_create_context_t)(pfarg_ctx_t *, char *, void *, size_t);
263  pfm_create_context_t pfm_create_context;
264  typedef os_err_t (*pfm_write_pmcs_t)(int, pfarg_pmc_t *, int);
265  pfm_write_pmcs_t pfm_write_pmcs;
266  typedef os_err_t (*pfm_write_pmds_t)(int, pfarg_pmd_t *, int);
267  pfm_write_pmds_t pfm_write_pmds;
268  typedef os_err_t (*pfm_load_context_t)(int, pfarg_load_t *);
269  pfm_load_context_t pfm_load_context;
270  typedef os_err_t (*pfm_start_t)(int fd, pfarg_start_t *);
271  pfm_start_t pfm_start;
272  typedef char* (*pfm_strerror_t)(int);
273  pfm_strerror_t pfm_strerror;
274  typedef pfm_err_t (*pfm_set_options_t)(pfmlib_options_t *);
275  pfm_set_options_t pfm_set_options;
276  typedef pfm_err_t (*pfm_get_num_counters_t)(unsigned int *);
277  pfm_get_num_counters_t pfm_get_num_counters;
278  */
279 
280 public:
282  : // standard constructor
283  Auditor( name, pSvc )
284  , m_pfm( PFMon::instance() )
285  , m_map()
286  , m_indent( 0 )
287  , m_inEvent( false ) {
289  declareProperty( "EVENT0", event_str[0] );
290  declareProperty( "EVENT1", event_str[1] );
291  declareProperty( "EVENT2", event_str[2] );
292  declareProperty( "EVENT3", event_str[3] );
293  declareProperty( "FAMILY", family );
294  declareProperty( "PREFIX", prefix );
295  declareProperty( "INV0", inv[0] );
296  declareProperty( "INV1", inv[1] );
297  declareProperty( "INV2", inv[2] );
298  declareProperty( "INV3", inv[3] );
299  declareProperty( "CMASK0", cmask[0] );
300  declareProperty( "CMASK1", cmask[1] );
301  declareProperty( "CMASK2", cmask[2] );
302  declareProperty( "CMASK3", cmask[3] );
303  declareProperty( "SP0", sp[0] );
304  declareProperty( "SP1", sp[1] );
305  declareProperty( "SP2", sp[2] );
306  declareProperty( "SP3", sp[3] );
307  declareProperty( "SAMPLE", sampling );
308  declareProperty( "START_AT_EVENT", start_at_event );
309  declareProperty( "IS_NEHALEM", is_nehalem_ret );
310 
312  /*
313  // loading functions from PFM library
314  void* handle = dlopen("libpfm.so", RTLD_NOW);
315  if (!handle) {
316  // error() << "Cannot open library: " << dlerror() << endmsg;
317  }
318  typedef void (*hello_t)();
319  hello_t hello = (hello_t) dlsym(handle, "hello");
320  if (!hello) {
321  // error() << "Cannot load symbol 'hello': " << dlerror() << endmsg;
322  dlclose(handle);
323  }
324 
325  pfm_start = (pfm_start_t) dlsym(handle, "pfm_start");
326  pfm_stop = (pfm_stop_t) dlsym(handle, "pfm_stop");
327  pfm_self_stop = (pfm_self_stop_t) dlsym(handle, "pfm_stop"); //it's the same
328  pfm_restart = (pfm_restart_t) dlsym(handle, "pfm_restart");
329  //pfm_read_pmds = (pfm_read_pmds_t) dlsym(handle, "pfm_read_pmds");
330  pfm_initialize = (pfm_initialize_t) dlsym(handle, "pfm_initialize");
331  pfm_find_full_event = (pfm_find_full_event_t) dlsym(handle, "pfm_find_full_event");
332  pfm_dispatch_events = (pfm_dispatch_events_t) dlsym(handle, "pfm_dispatch_events");
333  pfm_create_context = (pfm_create_context_t) dlsym(handle, "pfm_create_context");
334  pfm_write_pmcs = (pfm_write_pmcs_t) dlsym(handle, "pfm_write_pmcs");
335  pfm_write_pmds = (pfm_write_pmds_t) dlsym(handle, "pfm_write_pmds");
336  pfm_load_context = (pfm_load_context_t) dlsym(handle, "pfm_load_context");
337  pfm_strerror = (pfm_strerror_t) dlsym(handle, "pfm_strerror");
338  pfm_set_options = (pfm_set_options_t) dlsym(handle, "pfm_set_options");
339  pfm_get_num_counters = (pfm_get_num_counters_t) dlsym(handle, "pfm_get_num_counters");
340  // use it to do the calculation
341  // info() << "Calling hello..." << endmsg;
342  // hello();
343 
344  // close the library
345  // info() << "Closing library..." << endmsg;
346  dlclose(handle);
347  */
348 
350  }
351 
352  virtual ~PerfMonAuditor() {} // virtual destructor
353 
354 private:
355  PerfMonAuditor(); // the default constructor is disabled
356  PerfMonAuditor( const PerfMonAuditor& ); // copy constructor is disabled
357  PerfMonAuditor& operator=( const PerfMonAuditor& ); // assignement operator is disabled
358 
359 private:
362  int m_indent; // indentation level
363  bool m_inEvent; // "In event" flag
364 
365 private:
367 
374  int fd;
375  unsigned int i;
376  int ret{0};
377  void startpm();
378  void pausepm();
379  void stoppm();
380  void finalizepm();
386  unsigned int ph_ev_count{0};
389  unsigned int start_at_event;
393  bool nehalem;
394  bool westmere;
395  bool core;
396 
397  bool sampling;
398  int detect_unavail_pmu_regs( int fd, pfmlib_regmask_t* r_pmcs, pfmlib_regmask_t* r_pmds );
399  int detect_unavail_pmcs( int fd, pfmlib_regmask_t* r_pmcs ) { return detect_unavail_pmu_regs( fd, r_pmcs, NULL ); }
400  void pfm_bv_set( uint64_t* bv, uint16_t rnum ) { bv[rnum >> LBPL] |= 1UL << ( rnum & ( BPL - 1 ) ); }
401  int pfm_bv_isset( uint64_t* bv, uint16_t rnum ) {
402  return bv[rnum >> LBPL] & ( 1UL << ( rnum & ( BPL - 1 ) ) ) ? 1 : 0;
403  }
405  if ( n <= BPL )
406  *d = *j;
407  else {
408  memcpy( d, j, ( n >> LBPL ) * sizeof( uint64_t ) );
409  }
410  }
411  static void process_smpl_buf( pfm_dfl_smpl_hdr_t* hdr, size_t entry_size );
412  static void sigio_handler( int, siginfo_t*, void* ); // dlopen ==>
413  // void sigio_handler(int, struct siginfo *, struct sigcontext *);
414  void start_smpl();
415  void stop_smpl();
416  void finalize_smpl();
419  void* buf_addr;
420  unsigned num_counters;
421  unsigned int max_pmd;
423 
424  int level;
425 
426  bool first_alg;
429 };
430 
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 ) { error() << "ERROR: Context not created. Aborting..." << endmsg; }
477  if ( m_pfm.pfm_write_pmcs( fd, pc, outp.pfp_pmc_count ) == -1 ) {
478  error() << "ERROR: Could not write pmcs. Aborting..." << endmsg;
479  }
480  if ( m_pfm.pfm_write_pmds( fd, pd, outp.pfp_pmd_count ) == -1 ) {
481  error() << "ERROR: Could not write pmds. Aborting..." << endmsg;
482  }
483  load_arg.load_pid = getpid();
484  if ( m_pfm.pfm_load_context( fd, &load_arg ) == -1 ) {
485  error() << "ERROR: Could not load context. Aborting..." << endmsg;
486  // error() << "Could not read pmds" << endmsg;
487  }
488 
489  m_pfm.pfm_start( fd, NULL );
490 }
491 
492 // stoppm()
493 // const ModuleDescription& desc : description of the module that just finished its execution (we are only interested in
494 // its name)
495 // stops the counting calling pfm_stop() and stores the counting results into the "results" map
497  m_pfm.pfm_stop( fd );
498  if ( m_pfm.pfm_read_pmds( fd, pd, inp.pfp_event_count ) == -1 ) { error() << "Could not read pmds" << endmsg; }
499  for ( int i = 0; i < used_counters_number; i++ ) {
500  results[i][( alg_stack.top().first )->name()].push_back( alg_stack.top().second[i] + pd[i].reg_value );
501  }
502 
503  close( fd );
504 }
505 
507  m_pfm.pfm_stop( fd );
508  if ( m_pfm.pfm_read_pmds( fd, pd, inp.pfp_event_count ) == -1 ) { error() << "Could not read pmds" << endmsg; }
509 
510  for ( int i = 0; i < used_counters_number; i++ ) { alg_stack.top().second[i] += pd[i].reg_value; }
511 
512  close( fd );
513 }
514 
515 // finalizepm()
516 // called when all the countings of the current event are finished, it dumps the results
517 // into the output file corresponding to the event being counted
519  info() << "start of finalizepm ucn:" << used_counters_number << endmsg;
520  for ( int i = 0; i < used_counters_number; i++ ) {
522  filename += '_';
523  filename += event_cstr[i];
524 
525  for ( auto& c : filename )
526  if ( c == ':' ) c = '-';
527 
528  if ( inv[i] ) filename += "_INV_1";
529  if ( cmask[i] > 0 ) filename += "_CMASK_" + std::to_string( cmask[i] );
530  filename += ".txt";
531 
532  info() << "Filename:" << filename << endmsg;
533  FILE* outfile = fopen( filename.c_str(), "w" );
534  if ( nehalem ) {
535  fprintf( outfile, "NHM " );
536  } else if ( westmere ) {
537  fprintf( outfile, "WSM " );
538  } else if ( core ) {
539  fprintf( outfile, "CORE " );
540  }
541  fprintf( outfile, "%s %d %d %d\n", event_cstr[i], cmask[i], inv[i], sp[i] );
542  for ( std::map<std::string, std::vector<unsigned long int>>::iterator it = ( results[i] ).begin();
543  it != ( results[i] ).end(); it++ ) {
544  fprintf( outfile, "%s\n", ( it->first ).c_str() );
545  for ( std::vector<unsigned long int>::iterator j = ( it->second ).begin(); j != ( it->second ).end(); j++ ) {
546  fprintf( outfile, "%lu\n", *j );
547  }
548  }
549  fclose( outfile );
550  }
551 }
552 
554  if ( !m_pfm.loaded ) {
555  error() << "pfm library could not be loaded" << endmsg;
556  return StatusCode::FAILURE;
557  }
558 
559  info() << "Initializing..." << endmsg;
561  if ( sc.isFailure() ) { return sc; }
563  for ( int i = 0; i < MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS; i++ ) {
564  if ( event_str[i].length() > 0 ) used_counters_number++;
565  }
566  for ( int i = 0; i < MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS; i++ ) { strcpy( event_cstr[i], event_str[i].c_str() ); }
567  strcpy( prefix_cstr, prefix.c_str() );
568 
569  if ( m_pfm.pfm_initialize() != PFMLIB_SUCCESS ) { error() << "Cannot initialize perfmon!!" << endmsg; }
570  ph_ev_count = 0;
571  first_alg = true;
572  event_count_reached = false;
573  nehalem = false;
574  core = false;
575  westmere = false;
576  if ( family.compare( "CORE" ) == 0 )
577  core = true;
578  else if ( family.compare( "NEHALEM" ) == 0 )
579  nehalem = true;
580  else if ( family.compare( "WESTMERE" ) == 0 )
581  westmere = true;
582  else {
583  error() << "ERROR: Unsupported processor family " << family << ". aborting..." << endmsg;
584  }
585 
586  info() << "Initialized!" << endmsg;
587  return StatusCode::SUCCESS;
588 }
589 
590 // process_smpl_buf()
591 // pfm_dfl_smpl_hdr_t *hdr : pointer to header of the buffer containing addresses sampled during the sampling process
592 // size_t entry_size : size of each entry, used to navigate through the various entries
593 // called when the sampling buffer is full, saves the samples into memory ("samples" map)
594 void PerfMonAuditor::process_smpl_buf( pfm_dfl_smpl_hdr_t* hdr, size_t entry_size ) {
597  size_t pos, count;
598  uint64_t entry;
599  if ( hdr->hdr_overflows == last_overflow && hdr->hdr_count == last_count ) {
600  printf( "skipping identical set of samples...\n" );
601  return;
602  }
603  count = hdr->hdr_count;
604  ent = (pfm_dfl_smpl_entry_t*)( hdr + 1 );
605  pos = (unsigned long)ent;
606  entry = collected_samples;
607  while ( count-- ) {
608  // if(ent->ovfl_pmd>=0 && ent->ovfl_pmd<=3)
609  if ( ent->ovfl_pmd <= 3 ) {
610  ( ( samples[ent->ovfl_pmd] )[( alg_stack.top().first )->name()] )[(unsigned long)( ent->ip )]++;
611  }
612  pos += entry_size;
613  ent = (pfm_dfl_smpl_entry_t*)pos;
614  entry++;
615  }
616  collected_samples = entry;
617  last_overflow = hdr->hdr_overflows;
618  if ( last_count != hdr->hdr_count && ( last_count || last_overflow == 0 ) ) { collected_partial += hdr->hdr_count; }
619  last_count = hdr->hdr_count;
620  return;
621 }
622 
623 // sigio_handler()
624 // int n : signal number of the signal being delivered
625 // siginfo_t *info : pointer to a siginfo_t structure containing info about the signal
626 // signal handler used to catch sampling buffer overflows. When they occur it calls the process_smpl_buf() function
627 void PerfMonAuditor::sigio_handler( int /*n*/, siginfo_t* /*info*/, void* ) {
628  PFMon& pfm = PFMon::instance();
630  int fd = ctx_fd;
631  int r;
632  if ( fd != ctx_fd ) {
633  // error() << "ERROR: handler does not get valid file descriptor. Aborting..." << endmsg;
634  }
635  if ( pfm.pfm_read_pmds( fd, pd_smpl + 1, 1 ) == -1 ) {
636  // error() << "ERROR: pfm_read_pmds: " << strerror(errno) << ". Aborting..." << endmsg;
637  }
638  while ( true ) {
639  r = read( fd, &msg, sizeof( msg ) );
640  if ( r != sizeof( msg ) ) {
641  if ( r == -1 && errno == EINTR ) {
642  printf( "read interrupted, retrying\n" );
643  continue;
644  }
645  // error() << "ERROR: cannot read overflow message: " << strerror(errno) << ". Aborting..." << endmsg;
646  }
647  break;
648  }
649  switch ( msg.type ) {
650  case PFM_MSG_OVFL: // the sampling buffer is full
651  process_smpl_buf( hdr, entry_size );
652  ovfl_count++;
653  if ( pfm.pfm_restart( fd ) ) {
654  if ( errno != EBUSY ) {
655  // error() << "ERROR: pfm_restart error errno " << errno << ". Aborting..." << endmsg;
656  } else {
657  printf( "pfm_restart: task probably terminated \n" );
658  }
659  }
660  break;
661  default:
662  // error() << "ERROR: unknown message type " << msg.type << ". Aborting..." << endmsg;
663  break;
664  }
665 }
666 
667 // start_smpl()
668 // const ModuleDescription& desc : description of the module that is just starting its execution (we are only interested
669 // in its name)
670 // initializes all the necessary structures to start the sampling, calling pfm_self_start()
672  ovfl_count = 0;
673  num_smpl_pmds = 0;
674  last_overflow = ~0;
675  max_pmd = 0;
676  memset( &pfmlib_options, 0, sizeof( pfmlib_options ) );
679  m_pfm.pfm_set_options( &pfmlib_options );
680  ret = m_pfm.pfm_initialize();
681  if ( ret != PFMLIB_SUCCESS ) {
682  error() << "ERROR: Cannot initialize library: " << m_pfm.pfm_strerror( ret ) << ". Aborting..." << endmsg;
683  }
684  struct sigaction act;
685  memset( &act, 0, sizeof( act ) );
686  act.sa_sigaction = sigio_handler; // dlopen() ==>
687  // act.sa_handler = (sig_t)&sigio_handler;
688  sigaction( SIGIO, &act, 0 );
689  memset( &ctx, 0, sizeof( ctx ) );
690  memset( &buf_arg, 0, sizeof( buf_arg ) );
691  memset( &inp, 0, sizeof( inp ) );
692  memset( &outp, 0, sizeof( outp ) );
693  memset( pd_smpl, 0, sizeof( pd_smpl ) );
694  memset( pc, 0, sizeof( pc ) );
695  memset( &load_args, 0, sizeof( load_args ) );
696  m_pfm.pfm_get_num_counters( &num_counters );
697  memset( &params, 0, sizeof( params ) );
698  memset( &nhm_params, 0, sizeof( nhm_params ) );
699 
700  for ( int i = 0; i < used_counters_number; i++ ) {
701  ret = m_pfm.pfm_find_full_event( event_cstr[i], &inp.pfp_events[i] );
702  if ( ret != PFMLIB_SUCCESS ) {
703  error() << "ERROR: cannot find event: " << event_cstr[i] << ". Aborting..." << endmsg;
704  }
705  }
707  inp.pfp_event_count = 4;
708  for ( int i = 0; i < used_counters_number; i++ ) {
709  if ( inv[i] ) {
712  }
713  if ( cmask[i] > 0 ) {
714  ( params.pfp_core_counters[i] ).cnt_mask = cmask[i];
715  ( nhm_params.pfp_nhm_counters[i] ).cnt_mask = cmask[i];
716  }
717  }
718  if ( nehalem || westmere ) {
719  ret = m_pfm.pfm_dispatch_events( &inp, &nhm_params, &outp, NULL );
720  } else {
721  ret = m_pfm.pfm_dispatch_events( &inp, &params, &outp, NULL );
722  }
723  if ( ret != PFMLIB_SUCCESS ) {
724  error() << "ERROR: cannot configure events: " << m_pfm.pfm_strerror( ret ) << ". Aborting..." << endmsg;
725  }
726  for ( unsigned int i = 0; i < outp.pfp_pmc_count; i++ ) {
729  }
730  for ( unsigned int i = 0; i < outp.pfp_pmd_count; i++ ) {
731  pd_smpl[i].reg_num = outp.pfp_pmds[i].reg_num;
732  if ( i ) {
733  pfm_bv_set( pd_smpl[0].reg_smpl_pmds, pd_smpl[i].reg_num );
734  if ( pd_smpl[i].reg_num > max_pmd ) { max_pmd = pd_smpl[i].reg_num; }
735  num_smpl_pmds++;
736  }
737  }
738  for ( int i = 0; i < used_counters_number; i++ ) {
740  pfm_bv_copy( pd_smpl[i].reg_reset_pmds, pd_smpl[i].reg_smpl_pmds, max_pmd );
741  pd_smpl[i].reg_value = ( uint64_t )( sp[i] * -1 );
742  pd_smpl[i].reg_short_reset = ( uint64_t )( sp[i] * -1 );
743  pd_smpl[i].reg_long_reset = ( uint64_t )( sp[i] * -1 );
744  pd_smpl[i].reg_random_seed = 5; // tocheck
745  pd_smpl[i].reg_random_mask = 0xff; // tocheck
746  }
747  entry_size = sizeof( pfm_dfl_smpl_entry_t ) + ( num_smpl_pmds << 3 );
748  ctx.ctx_flags = 0;
749  buf_arg.buf_size = 3 * getpagesize() + 512;
750  ctx_fd = m_pfm.pfm_create_context( &ctx, (char*)FMT_NAME, &buf_arg, sizeof( buf_arg ) );
751  if ( ctx_fd == -1 ) {
752  if ( errno == ENOSYS ) {
753  error() << "ERROR: Your kernel does not have performance monitoring support! Aborting..." << endmsg;
754  }
755  error() << "ERROR: Can't create PFM context " << strerror( errno ) << ". Aborting..." << endmsg;
756  }
757  buf_addr = mmap( NULL, buf_arg.buf_size, PROT_READ, MAP_PRIVATE, ctx_fd, 0 );
758  if ( buf_addr == MAP_FAILED ) {
759  error() << "ERROR: cannot mmap sampling buffer: " << strerror( errno ) << ". Aborting..." << endmsg;
760  }
762  if ( PFM_VERSION_MAJOR( hdr->hdr_version ) < 1 ) {
763  error() << "ERROR: invalid buffer format version. Aborting..." << endmsg;
764  }
765  if ( m_pfm.pfm_write_pmcs( ctx_fd, pc, outp.pfp_pmc_count ) ) {
766  error() << "ERROR: pfm_write_pmcs error errno " << strerror( errno ) << ". Aborting..." << endmsg;
767  }
768  if ( m_pfm.pfm_write_pmds( ctx_fd, pd_smpl, outp.pfp_pmd_count ) ) {
769  error() << "ERROR: pfm_write_pmds error errno " << strerror( errno ) << ". Aborting..." << endmsg;
770  }
771  load_args.load_pid = getpid();
772  if ( m_pfm.pfm_load_context( ctx_fd, &load_args ) ) {
773  error() << "ERROR: pfm_load_context error errno " << strerror( errno ) << ". Aborting..." << endmsg;
774  }
775  ret = fcntl( ctx_fd, F_SETFL, fcntl( ctx_fd, F_GETFL, 0 ) | O_ASYNC );
776  if ( ret == -1 ) { error() << "ERROR: cannot set ASYNC: " << strerror( errno ) << ". Aborting..." << endmsg; }
777  ret = fcntl( ctx_fd, F_SETOWN, getpid() );
778  if ( ret == -1 ) { error() << "ERROR: cannot setown: " << strerror( errno ) << ". Aborting..." << endmsg; }
779  // pfm_self_start(ctx_fd); ==>
780  m_pfm.pfm_start( ctx_fd, NULL );
781 }
782 
783 // stop_smpl()
784 // const ModuleDescription& desc : description of the module that just finished its execution (we are only interested in
785 // its name)
786 // stops the sampling and calls process_smpl_buf() one last time to process all the remaining samples
788  m_pfm.pfm_self_stop( ctx_fd );
789  process_smpl_buf( hdr, entry_size );
790  close( ctx_fd );
791  ret = munmap( hdr, buf_arg.buf_size );
792  if ( ret ) { error() << "Cannot unmap buffer: %s" << strerror( errno ) << endmsg; }
793  return;
794 }
795 
796 // finalize_smpl()
797 // processes the sampling results in order to find library and offset of each sampled address, using the symbol() and
798 // tosymbol() functions,
799 // and then dumps the new found information into gzipped output files, to be processed later
801  int err;
802  for ( int i = 0; i < used_counters_number; i++ ) {
804  filename += '_';
805  filename += event_cstr[i];
806 
807  for ( auto& c : filename )
808  if ( c == ':' ) c = '-';
809 
810  if ( inv[i] ) filename += "_INV_1";
811  if ( cmask[i] > 0 ) filename += "_CMASK_" + std::to_string( cmask[i] );
812  filename += ".txt.gz";
813 
814  gzFile outfile = gzopen( filename.c_str(), "wb" );
815  if ( outfile != NULL ) {
816  if ( nehalem ) {
817  gzprintf( outfile, "NHM " );
818  } else if ( westmere ) {
819  gzprintf( outfile, "WSM " );
820  } else if ( core ) {
821  gzprintf( outfile, "CORE " );
822  }
823  if ( gzprintf( outfile, "%s %d %d %d\n", event_cstr[i], cmask[i], inv[i], sp[i] ) <
824  (int)strlen( event_cstr[i] ) ) {
825  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << ". Aborting..." << endmsg;
826  }
827  for ( std::map<std::string, std::map<unsigned long, unsigned int>>::iterator it = samples[i].begin();
828  it != samples[i].end(); it++ ) {
829  unsigned long long sum = 0;
830  for ( std::map<unsigned long, unsigned int>::iterator jt = ( it->second ).begin(); jt != ( it->second ).end();
831  jt++ ) {
832  sum += jt->second;
833  }
834  if ( gzprintf( outfile, "%s%%%llu\n", ( it->first ).c_str(), sum ) < (int)( ( it->first ).length() ) ) {
835  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << ". Aborting..." << endmsg;
836  }
837  for ( std::map<unsigned long, unsigned int>::iterator jt = ( it->second ).begin(); jt != ( it->second ).end();
838  jt++ ) {
839  char sym_name[SYM_NAME_MAX_LENGTH];
840  bzero( sym_name, SYM_NAME_MAX_LENGTH );
841  const char* libName;
842  const char* symbolName;
843  int libOffset = 0;
844  int offset = 0;
845  void* sym_addr = IgHookTrace::tosymbol( (void*)( jt->first ) );
846  if ( sym_addr != NULL ) {
847  bool success = IgHookTrace::symbol( sym_addr, symbolName, libName, offset, libOffset );
848  if ( success ) {
849  if ( symbolName != NULL && strlen( symbolName ) > 0 ) {
850  strcpy( sym_name, symbolName );
851  strcat( sym_name, " " );
852  } else {
853  strcpy( sym_name, "??? " );
854  }
855  if ( libName != NULL && strlen( libName ) > 0 ) {
856  strcat( sym_name, libName );
857  strcat( sym_name, " " );
858  } else {
859  strcat( sym_name, "??? " );
860  }
861  sprintf( sym_name + strlen( sym_name ), "%d ", libOffset );
862  if ( strlen( sym_name ) <= 0 ) { error() << "ERROR: Symbol name length is zero. Aborting..." << endmsg; }
863  } else {
864  strcpy( sym_name, "??? ??? 0 " );
865  }
866  } else {
867  strcpy( sym_name, "??? ??? 0 " );
868  }
869  if ( gzprintf( outfile, "%s %d\n", sym_name, jt->second ) < (int)strlen( sym_name ) ) {
870  error() << "ERROR: gzputs err: " << gzerror( outfile, &err ) << endmsg;
871  }
872  }
873  }
874  } else {
875  error() << "ERROR: Could not open file: " << filename << ". Aborting..." << endmsg;
876  }
877  gzclose( outfile );
878  }
879 }
880 
882  if ( sampling == 0 )
883  finalizepm();
884  else
885  finalize_smpl();
886  return Auditor::finalize();
887 }
888 
889 void PerfMonAuditor::before( StandardEventType evt, INamedInterface* alg ) {
890  switch ( evt ) {
893  break;
894  case IAuditor::Execute:
895  i_beforeExecute( alg );
896  break;
897  default:
898  break;
899  }
900  return;
901 }
902 
903 void PerfMonAuditor::after( StandardEventType evt, INamedInterface* alg, const StatusCode& ) {
904  switch ( evt ) {
907  break;
908  case IAuditor::Execute:
909  i_afterExecute( alg );
910  break;
911  default:
912  break;
913  }
914  return;
915 }
916 
918 
920 
922  if ( !alg ) return;
923  // info() << "before:inside! " << alg->name() << endmsg;
924  if ( first_alg ) {
925  first_alg = false;
926  first_alg_name = alg->name();
927  // info() << "first_alg_name= " << alg->name() << endmsg;
928  }
929  if ( !event_count_reached ) {
930  if ( !first_alg_name.compare( alg->name() ) ) {
931  ph_ev_count++;
932  // info() << "EVENT COUNT: " << ph_ev_count << endmsg;
933  if ( ph_ev_count == start_at_event ) {
934  event_count_reached = true;
935  // info() << "!!! EVENT COUNT REACHED: " << ph_ev_count << endmsg;
936  }
937  }
938  }
939  if ( event_count_reached ) {
940  // info() << "before:inside! " << alg->name() << endmsg;
941 
942  if ( !alg_stack.empty() ) {
943  if ( sampling == 0 )
944  pausepm(); // pausing father algorithm counting
945  else
946  stop_smpl();
947  }
948  ++m_indent;
949  std::vector<unsigned long int> zeroes( 4, 0 );
950  alg_stack.push( std::make_pair( alg, zeroes ) );
951  if ( sampling == 0 )
952  startpm();
953  else
954  start_smpl();
955  }
956 }
957 
959  if ( !alg ) { return; } // info() << "after:inside! " << alg->name() << endmsg;
960 
961  if ( event_count_reached ) {
962  // info() << "after:inside! " << alg->name() << endmsg;
963 
964  if ( sampling == 0 )
965  stoppm();
966  else
967  stop_smpl();
968  alg_stack.pop();
969  --m_indent;
970  if ( !alg_stack.empty() ) {
971  if ( sampling == 0 )
972  startpm();
973  else
974  start_smpl(); // resuming father algorithm counting
975  }
976  }
977 }
978 
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
Definition: pfmlib.h:129
pfarg_load_t load_args
int pfm_err_t
Definition: pfmlib.h:150
uint64_t reg_short_reset
Definition: perfmon_v2.h:44
pfmlib_core_input_param_t params
os_err_t pfm_write_pmds(int fd, pfarg_pmd_t *pmds, int count)
virtual StatusCode finalize()
Definition: Auditor.cpp:185
#define PFM_REGFL_OVFL_NOTIFY
Definition: perfmon.h:112
#define MAX_PREFIX_NAME_LENGTH
#define PFM_NHM_SEL_INV
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
os_err_t pfm_create_context(pfarg_ctx_t *ctx, char *smpl_name, void *smpl_arg, size_t smpl_size)
#define PFM_PLM3
Definition: pfmlib.h:53
PerfMonAuditor(const std::string &name, ISvcLocator *pSvc)
std::string family
char * pfm_strerror(int code)
pfmlib_event_t pfp_events[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:112
#define PFM_CORE_SEL_INV
Definition: pfmlib_core.h:68
static void * tosymbol(void *address)
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 pfm_verbose
Definition: pfmlib.h:138
T to_string(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
unsigned int pfp_dfl_plm
Definition: pfmlib.h:109
pfm_err_t pfm_get_num_counters(unsigned int *num)
#define SYM_NAME_MAX_LENGTH
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
int os_err_t
Definition: perfmon.h:69
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:33
uint16_t reg_num
Definition: perfmon_v2.h:39
unsigned long long uint64_t
Definition: instrset.h:143
void i_afterExecute(INamedInterface *alg)
pfmlib_input_param_t inp
unsigned short int uint16_t
Definition: instrset.h:139
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
os_err_t pfm_write_pmcs(int fd, pfarg_pmc_t *pmcs, int count)
Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.
pfm_err_t pfm_dispatch_events(pfmlib_input_param_t *p, void *model_in, pfmlib_output_param_t *q, void *model_out)
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
STL class.
uint32_t reg_random_seed
Definition: perfmon_v2.h:51
std::string first_alg_name
pfm_err_t pfm_find_full_event(const char *str, pfmlib_event_t *e)
uint64_t reg_long_reset
Definition: perfmon_v2.h:43
StatusCode finalize() override
#define MAX_EVENT_NAME_LENGTH
pfmlib_nhm_input_param_t nhm_params
int detect_unavail_pmu_regs(int fd, pfmlib_regmask_t *r_pmcs, pfmlib_regmask_t *r_pmds)
#define NUM_PMCS
STL class.
#define DECLARE_COMPONENT(type)
#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)
GaudiUtils::VectorMap< const INamedInterface *, int > Map
int detect_unavail_pmcs(int fd, pfmlib_regmask_t *r_pmcs)
uint16_t ovfl_pmd
uint64_t ip
void pfm_bv_set(uint64_t *bv, uint16_t rnum)
uint32_t reg_flags
Definition: perfmon_v2.h:41
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
os_err_t pfm_restart(int fd)
STL class.
std::string event_str[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
#define NUM_PMDS
std::string prefix
unsigned int pfm_debug
Definition: pfmlib.h:137
unsigned int reg_num
Definition: pfmlib.h:99
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
pfmlib_output_param_t outp
void after(StandardEventType, INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:107
uint16_t reg_num
Definition: perfmon_v2.h:28
static bool symbol(void *address, const char *&sym, const char *&lib, int &offset, int &liboffset)
T make_pair(T... args)
char event_cstr[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVENT_NAME_LENGTH]
def end
Definition: IOTest.py:123
#define LBPL
void after(StandardEventType evt, INamedInterface *alg, const StatusCode &sc) override
pfarg_pmd_t pd[NUM_PMDS]
os_err_t pfm_start(int fd, pfarg_start_t *start)
pfm_err_t pfm_initialize(void)
PerfMonAuditor & operator=(const PerfMonAuditor &)
char prefix_cstr[MAX_PREFIX_NAME_LENGTH]
#define BPL
uint32_t load_pid
Definition: perfmon_v2.h:69
unsigned int i
pfarg_pmc_t pc[NUM_PMCS]
IInterface compliant class extending IInterface with the name() method.
unsigned int ph_ev_count
STL class.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
int pfm_bv_isset(uint64_t *bv, uint16_t rnum)
T begin(T... args)
#define FMT_NAME
unsigned int start_at_event
static void process_smpl_buf(pfm_dfl_smpl_hdr_t *hdr, size_t entry_size)
T c_str(T... args)
os_err_t pfm_load_context(int fd, pfarg_load_t *load)
#define cpuid(func, ax, bx, cx, dx)
const std::string & name() const override
Definition: Auditor.cpp:187
#define PFM_REGFL_RANDOM
Definition: perfmon.h:113
constexpr static const auto FAILURE
Definition: StatusCode.h:97
pfm_dfl_smpl_arg_t buf_arg
static void sigio_handler(int, siginfo_t *, void *)
os_err_t pfm_read_pmds(int fd, pfarg_pmd_t *pmds, int count)
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
StatusCode initialize() override
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
void i_beforeExecute(INamedInterface *alg)
virtual StatusCode initialize()
Definition: Auditor.cpp:74
bool isFailure() const
Definition: StatusCode.h:141
AttribStringParser::Iterator begin(const AttribStringParser &parser)
#define MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS
void i_afterInitialize(INamedInterface *alg)
void i_beforeInitialize(INamedInterface *alg)
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
#define PFM_MSG_OVFL
Definition: perfmon.h:210
os_err_t pfm_stop(int fd)
virtual ~PerfMonAuditor()
void before(StandardEventType, INamedInterface *) override
The following methods are meant to be implemented by the child class...
Definition: Auditor.cpp:77
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:202
void before(StandardEventType evt, INamedInterface *alg) override
T compare(T... args)
unsigned int pfp_event_count
Definition: pfmlib.h:108
pfm_err_t pfm_set_options(pfmlib_options_t *opt)
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:44