PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_hl.c File Reference

This file contains the 'high level' interface to PAPI. BASIC is a high level language. ;-) More...

Include dependency graph for papi_hl.c:

Go to the source code of this file.

Data Structures

struct  HighLevelInfo
 

Macros

#define HL_STOP   0
 
#define HL_START   1
 
#define HL_FLIP   2
 
#define HL_FLOP   3
 
#define HL_IPC   4
 
#define HL_EPC   5
 
#define HL_READ   6
 
#define HL_ACCUM   7
 

Functions

int _hl_rate_calls (float *real_time, float *proc_time, int *events, long long *values, long long *ins, float *rate, int mode)
 
void _internal_cleanup_hl_info (HighLevelInfo *state)
 
int _internal_check_state (HighLevelInfo **state)
 
int _internal_start_hl_counters (HighLevelInfo *state)
 
int _internal_hl_read_cnts (long long *values, int array_len, int flag)
 
int PAPI_flips (float *rtime, float *ptime, long long *flpins, float *mflips)
 
int PAPI_flops (float *rtime, float *ptime, long long *flpops, float *mflops)
 
int PAPI_ipc (float *rtime, float *ptime, long long *ins, float *ipc)
 
int PAPI_epc (int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc)
 
int PAPI_num_counters (void)
 
int PAPI_start_counters (int *events, int array_len)
 
int PAPI_read_counters (long long *values, int array_len)
 
int PAPI_accum_counters (long long *values, int array_len)
 
int PAPI_stop_counters (long long *values, int array_len)
 
void _papi_hwi_shutdown_highlevel ()
 

Detailed Description

Macro Definition Documentation

#define HL_ACCUM   7

Definition at line 33 of file papi_hl.c.

#define HL_EPC   5

Definition at line 31 of file papi_hl.c.

#define HL_FLIP   2

Definition at line 28 of file papi_hl.c.

#define HL_FLOP   3

Definition at line 29 of file papi_hl.c.

#define HL_IPC   4

Definition at line 30 of file papi_hl.c.

#define HL_READ   6

Definition at line 32 of file papi_hl.c.

#define HL_START   1

Definition at line 27 of file papi_hl.c.

#define HL_STOP   0

Definition at line 26 of file papi_hl.c.

Function Documentation

int _hl_rate_calls ( float *  real_time,
float *  proc_time,
int events,
long long values,
long long ins,
float *  rate,
int  mode 
)

Definition at line 405 of file papi_hl.c.

407 {
408  long long rt, pt; // current elapsed real and process times in usec
409  int num_events = 2;
410  int retval = 0;
411  HighLevelInfo *state = NULL;
412 
413  if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK ) {
414  return ( retval );
415  }
416 
417  if ( state->running != HL_STOP && state->running != mode ) {
418  return PAPI_EINVAL;
419  }
420 
421  if ( state->running == HL_STOP ) {
422 
423  switch (mode) {
424  case HL_FLOP:
425  case HL_FLIP:
426  num_events = 1;
427  break;
428  case HL_IPC:
429  break;
430  case HL_EPC:
431  if ( events[2] != 0 ) num_events = 3;
432  break;
433  default:
434  return PAPI_EINVAL;
435  }
436  if (( retval = PAPI_add_events( state->EventSet, events, num_events )) != PAPI_OK ) {
437  _internal_cleanup_hl_info( state );
439  return retval;
440  }
441 
442  state->total_ins = 0;
445 
446  if ( ( retval = PAPI_start( state->EventSet ) ) != PAPI_OK ) {
447  return retval;
448  }
449 
450  /* Initialize the interface */
451  state->running = mode;
452  *real_time = 0.0;
453  *proc_time = 0.0;
454  *rate = 0.0;
455 
456  } else {
457  if ( ( retval = PAPI_stop( state->EventSet, values ) ) != PAPI_OK ) {
458  state->running = HL_STOP;
459  return retval;
460  }
461 
462  /* Read elapsed real and process times */
463  rt = PAPI_get_real_usec();
464  pt = PAPI_get_virt_usec();
465 
466  /* Convert to seconds with multiplication because it is much faster */
467  *real_time = ((float)( rt - state->initial_real_time )) * .000001;
468  *proc_time = ((float)( pt - state->initial_proc_time )) * .000001;
469 
470  state->total_ins += values[0];
471 
472  switch (mode) {
473  case HL_FLOP:
474  case HL_FLIP:
475  /* Calculate MFLOP and MFLIP rates */
476  if ( pt > 0 ) {
477  *rate = (float)values[0] / (pt - state->last_proc_time);
478  } else *rate = 0;
479  break;
480  case HL_IPC:
481  case HL_EPC:
482  /* Calculate IPC */
483  if (values[1]!=0) {
484  *rate = (float) ((float)values[0] / (float) ( values[1]));
485  }
486  break;
487  default:
488  return PAPI_EINVAL;
489  }
490  state->last_real_time = rt;
491  state->last_proc_time = pt;
492 
493  if ( ( retval = PAPI_start( state->EventSet ) ) != PAPI_OK ) {
494  state->running = HL_STOP;
495  return retval;
496  }
497  }
498  *ins = state->total_ins;
499  return PAPI_OK;
500 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
long long initial_proc_time
Definition: papi_hl.c:44
long long PAPI_get_virt_usec(void)
Definition: papi.c:6298
long long initial_real_time
Definition: papi_hl.c:43
#define HL_FLOP
Definition: papi_hl.c:29
int num_events
int _internal_check_state(HighLevelInfo **state)
Definition: papi_hl.c:100
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define HL_EPC
Definition: papi_hl.c:31
int PAPI_add_events(int EventSet, int *Events, int number)
Definition: papi.c:5769
char events[MAX_EVENTS][BUFSIZ]
#define HL_STOP
Definition: papi_hl.c:26
#define HL_IPC
Definition: papi_hl.c:30
long long last_proc_time
Definition: papi_hl.c:46
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
void _internal_cleanup_hl_info(HighLevelInfo *state)
Definition: papi_hl.c:152
short int running
Definition: papi_hl.c:42
#define HL_FLIP
Definition: papi_hl.c:28
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
child_idents[x-1] state
Definition: iozone.c:21341
long long total_ins
Definition: papi_hl.c:47
long long last_real_time
Definition: papi_hl.c:45
int EventSet
Definition: papi_hl.c:40
int PAPI_start(int EventSet)
Definition: papi.c:2053
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int _internal_check_state ( HighLevelInfo **  outgoing)

This function is called to determine the state of the system. We may as well set the HighLevelInfo so you don't have to look it up again.

Definition at line 100 of file papi_hl.c.

101 {
102  int retval;
103  HighLevelInfo *state = NULL;
104 
105  /* Only allow one thread at a time in here */
106  if ( init_level == PAPI_NOT_INITED ) {
108  if ( retval != PAPI_VER_CURRENT ) {
109  return ( retval );
110  } else {
114  }
115  }
116 
117  /*
118  * Do we have the thread specific data setup yet?
119  */
120  if ( ( retval =
121  PAPI_get_thr_specific( PAPI_HIGH_LEVEL_TLS, ( void * ) &state ) )
122  != PAPI_OK || state == NULL ) {
123  state = ( HighLevelInfo * ) papi_malloc( sizeof ( HighLevelInfo ) );
124  if ( state == NULL )
125  return ( PAPI_ENOMEM );
126 
127  memset( state, 0, sizeof ( HighLevelInfo ) );
128  state->EventSet = -1;
129 
130  if ( ( retval = PAPI_create_eventset( &state->EventSet ) ) != PAPI_OK )
131  return ( retval );
132 
133  if ( ( retval =
135  state ) ) != PAPI_OK )
136  return ( retval );
137  }
138  *outgoing = state;
139  return ( PAPI_OK );
140 }
memset(eventId, 0, size)
#define papi_malloc(a)
Definition: papi_memory.h:34
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_NOT_INITED
Definition: papi.h:278
int PAPI_get_thr_specific(int tag, void **ptr)
Definition: papi.c:359
int PAPI_library_init(int version)
Definition: papi.c:497
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
#define PAPI_HIGH_LEVEL_INITED
Definition: papi.h:280
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
#define PAPI_ENOMEM
Definition: papi.h:252
#define HIGHLEVEL_LOCK
Definition: papi_internal.h:88
int PAPI_set_thr_specific(int tag, void *ptr)
Definition: papi.c:435
child_idents[x-1] state
Definition: iozone.c:21341
int EventSet
Definition: papi_hl.c:40
int init_level
Definition: papi_internal.c:54
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
#define PAPI_HIGH_LEVEL_TLS
Definition: papi.h:319

Here is the call graph for this function:

Here is the caller graph for this function:

void _internal_cleanup_hl_info ( HighLevelInfo state)

Definition at line 152 of file papi_hl.c.

153 {
154  state->num_evts = 0;
155  state->running = HL_STOP;
156  state->initial_real_time = -1;
157  state->initial_proc_time = -1;
158  state->total_ins = 0;
159  return;
160 }
long long initial_proc_time
Definition: papi_hl.c:44
long long initial_real_time
Definition: papi_hl.c:43
short int num_evts
Definition: papi_hl.c:41
#define HL_STOP
Definition: papi_hl.c:26
short int running
Definition: papi_hl.c:42
long long total_ins
Definition: papi_hl.c:47

Here is the caller graph for this function:

int _internal_hl_read_cnts ( long long values,
int  array_len,
int  flag 
)

Definition at line 639 of file papi_hl.c.

640 {
641  int retval;
642  HighLevelInfo *state = NULL;
643 
644  if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK )
645  return ( retval );
646 
647  if ( state->running != HL_START || array_len < state->num_evts )
648  return ( PAPI_EINVAL );
649 
650  if ( flag == HL_ACCUM )
651  return ( PAPI_accum( state->EventSet, values ) );
652  else if ( flag == HL_READ ) {
653  if ( ( retval = PAPI_read( state->EventSet, values ) ) != PAPI_OK )
654  return ( retval );
655  return ( PAPI_reset( state->EventSet ) );
656  }
657 
658  /* Invalid flag passed in */
659  return ( PAPI_EINVAL );
660 }
int PAPI_reset(int EventSet)
Definition: papi.c:2403
int _internal_check_state(HighLevelInfo **state)
Definition: papi_hl.c:100
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define HL_READ
Definition: papi_hl.c:32
int PAPI_accum(int EventSet, long long *values)
Definition: papi.c:2689
#define HL_ACCUM
Definition: papi_hl.c:33
#define HL_START
Definition: papi_hl.c:27
child_stat flag
Definition: iozone.c:12951
short int running
Definition: papi_hl.c:42
child_idents[x-1] state
Definition: iozone.c:21341
int EventSet
Definition: papi_hl.c:40
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2503
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int _internal_start_hl_counters ( HighLevelInfo state)

Make sure to allocate space for values

Definition at line 146 of file papi_hl.c.

147 {
148  return ( PAPI_start( state->EventSet ) );
149 }
int EventSet
Definition: papi_hl.c:40
int PAPI_start(int EventSet)
Definition: papi.c:2053

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_hwi_shutdown_highlevel ( )

Definition at line 836 of file papi_hl.c.

837 {
838  HighLevelInfo *state = NULL;
839 
840  if ( PAPI_get_thr_specific( PAPI_HIGH_LEVEL_TLS, ( void * ) &state ) ==
841  PAPI_OK ) {
842  if ( state )
843  papi_free( state );
844  }
845 }
#define papi_free(a)
Definition: papi_memory.h:35
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_get_thr_specific(int tag, void **ptr)
Definition: papi.c:359
child_idents[x-1] state
Definition: iozone.c:21341
#define PAPI_HIGH_LEVEL_TLS
Definition: papi.h:319

Here is the call graph for this function:

Here is the caller graph for this function: