PAPI  5.7.0.0
The High Level API

Functions

int PAPI_accum_counters (long long *values, int array_len)
 
int PAPI_num_counters (void)
 
int PAPI_num_components (void)
 
int PAPI_read_counters (long long *values, int array_len)
 
int PAPI_start_counters (int *events, int array_len)
 
int PAPI_stop_counters (long long *values, int array_len)
 
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)
 

Detailed Description

The simple interface implemented by the following eight routines allows the user to access and count specific hardware events from both C and Fortran. It should be noted that this API can be used in conjunction with the low level API.

Function Documentation

◆ PAPI_accum_counters()

int PAPI_accum_counters ( long long *  values,
int  array_len 
)

add current counts to array and reset counters

Definition at line 760 of file papi_hl.c.

761 {
762  if ( values == NULL || array_len <= 0 )
763  return PAPI_EINVAL;
764 
765  return ( _internal_hl_read_cnts( values, array_len, HL_ACCUM ) );
766 }
int _internal_hl_read_cnts(long long *values, int array_len, int flag)
Definition: papi_hl.c:643
#define PAPI_EINVAL
Definition: fpapi.h:106
#define HL_ACCUM
Definition: papi_hl.c:33
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

◆ PAPI_epc()

int PAPI_epc ( int  event,
float *  rtime,
float *  ptime,
long long *  ref,
long long *  core,
long long *  evt,
float *  epc 
)

gets (named) events per cycle, real and processor time, reference and core cycles

Definition at line 387 of file papi_hl.c.

388 {
389  long long values[3] = { 0, 0, 0 };
391  int retval = 0;
392 
393  if ( rtime == NULL || ptime == NULL || ref == NULL ||core == NULL || evt == NULL || epc == NULL )
394  return PAPI_EINVAL;
395 
396  // if an event is provided, use it; otherwise use TOT_INS
397  if (event != 0 ) events[0] = event;
398 
399  if ( PAPI_query_event( ( int ) PAPI_REF_CYC ) != PAPI_OK )
400  events[2] = 0;
401 
402  retval = _hl_rate_calls( rtime, ptime, events, values, evt, epc, HL_EPC );
403  *core = values[1];
404  *ref = values[2];
405  return ( retval );
406 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
int retval
Definition: zero_fork.c:53
#define PAPI_REF_CYC
Definition: fpapi.h:243
#define HL_EPC
Definition: papi_hl.c:31
char events[MAX_EVENTS][BUFSIZ]
#define PAPI_TOT_INS
Definition: fpapi.h:186
int _hl_rate_calls(float *real_time, float *proc_time, int *events, long long *values, long long *ins, float *rate, int mode)
Definition: papi_hl.c:409
int PAPI_query_event(int EventCode)
Definition: papi.c:684
#define PAPI_TOT_CYC
Definition: fpapi.h:195
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

◆ PAPI_flips()

int PAPI_flips ( float *  rtime,
float *  ptime,
long long *  flpins,
float *  mflips 
)

simplified call to get Mflips/s (floating point instruction rate), real and processor time

Definition at line 204 of file papi_hl.c.

205 {
206  int retval;
207  int events[1] = {PAPI_FP_INS};
208  long long values = 0;
209 
210  if ( rtime == NULL || ptime == NULL ||
211  flpins == NULL || mflips == NULL ) {
212  return PAPI_EINVAL;
213  }
214 
215  retval = _hl_rate_calls( rtime, ptime, events,
216  &values, flpins, mflips, HL_FLIP );
217 
218  return ( retval );
219 }
#define PAPI_EINVAL
Definition: fpapi.h:106
int retval
Definition: zero_fork.c:53
char events[MAX_EVENTS][BUFSIZ]
int _hl_rate_calls(float *real_time, float *proc_time, int *events, long long *values, long long *ins, float *rate, int mode)
Definition: papi_hl.c:409
#define HL_FLIP
Definition: papi_hl.c:28
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
#define PAPI_FP_INS
Definition: fpapi.h:188

◆ PAPI_flops()

int PAPI_flops ( float *  rtime,
float *  ptime,
long long *  flpops,
float *  mflops 
)

simplified call to get Mflops/s (floating point operation rate), real and processor time

Definition at line 263 of file papi_hl.c.

264 {
265  int retval;
266  int events[1] = {PAPI_FP_OPS};
267  long long values = 0;
268 
269  if ( rtime == NULL || ptime == NULL || flpops == NULL || mflops == NULL )
270  return PAPI_EINVAL;
271 
272  retval = _hl_rate_calls( rtime, ptime, events, &values, flpops, mflops, HL_FLOP );
273  return ( retval );
274 }
#define PAPI_EINVAL
Definition: fpapi.h:106
#define HL_FLOP
Definition: papi_hl.c:29
#define PAPI_FP_OPS
Definition: fpapi.h:238
int retval
Definition: zero_fork.c:53
char events[MAX_EVENTS][BUFSIZ]
int _hl_rate_calls(float *real_time, float *proc_time, int *events, long long *values, long long *ins, float *rate, int mode)
Definition: papi_hl.c:409
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

◆ PAPI_ipc()

int PAPI_ipc ( float *  rtime,
float *  ptime,
long long *  ins,
float *  ipc 
)

gets instructions per cycle, real and processor time

Definition at line 320 of file papi_hl.c.

321 {
322  long long values[2] = { 0, 0 };
323  int events[2] = {PAPI_TOT_INS, PAPI_TOT_CYC};
324  int retval = 0;
325 
326  if ( rtime == NULL || ptime == NULL || ins == NULL || ipc == NULL )
327  return PAPI_EINVAL;
328 
329  retval = _hl_rate_calls( rtime, ptime, events, values, ins, ipc, HL_IPC );
330  return ( retval );
331 }
#define PAPI_EINVAL
Definition: fpapi.h:106
int retval
Definition: zero_fork.c:53
char events[MAX_EVENTS][BUFSIZ]
#define HL_IPC
Definition: papi_hl.c:30
#define PAPI_TOT_INS
Definition: fpapi.h:186
int _hl_rate_calls(float *real_time, float *proc_time, int *events, long long *values, long long *ins, float *rate, int mode)
Definition: papi_hl.c:409
#define PAPI_TOT_CYC
Definition: fpapi.h:195
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

◆ PAPI_num_components()

int PAPI_num_components ( void  )

get the number of components available on the system

Definition at line 4387 of file papi.c.

4388 {
4389  APIDBG( "Entry:\n");
4390  return ( papi_num_components );
4391 }
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int papi_num_components

◆ PAPI_num_counters()

int PAPI_num_counters ( void  )

get the number of hardware counters available on the system

Definition at line 541 of file papi_hl.c.

542 {
543  int retval;
544  HighLevelInfo *tmp = NULL;
545 
546  /* Make sure the Library is initialized, etc... */
547  if ( ( retval = _internal_check_state( &tmp ) ) != PAPI_OK )
548  return ( retval );
549 
550  return ( PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) );
551 }
#define PAPI_OK
Definition: fpapi.h:105
int _internal_check_state(HighLevelInfo **state)
Definition: papi_hl.c:100
int retval
Definition: zero_fork.c:53
double tmp
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
#define PAPI_MAX_HWCTRS
Definition: fpapi.h:58

◆ PAPI_read_counters()

int PAPI_read_counters ( long long *  values,
int  array_len 
)

copy current counts to array and reset counters

Definition at line 710 of file papi_hl.c.

711 {
712  return ( _internal_hl_read_cnts( values, array_len, HL_READ ) );
713 }
int _internal_hl_read_cnts(long long *values, int array_len, int flag)
Definition: papi_hl.c:643
#define HL_READ
Definition: papi_hl.c:32
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

◆ PAPI_start_counters()

int PAPI_start_counters ( int *  events,
int  array_len 
)

start counting hardware events

Definition at line 597 of file papi_hl.c.

598 {
599  int i, retval;
600  HighLevelInfo *state = NULL;
601 
602  if ( events == NULL || array_len <= 0 )
603  return PAPI_EINVAL;
604 
605  if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK )
606  return ( retval );
607 
608  if ( state->running != 0 )
609  return ( PAPI_EINVAL );
610 
611  /* load events to the new EventSet */
612  for ( i = 0; i < array_len; i++ ) {
613  retval = PAPI_add_event( state->EventSet, events[i] );
614  if ( retval == PAPI_EISRUN )
615  return ( retval );
616 
617  if ( retval ) {
618  /* remove any prior events that may have been added
619  * and cleanup the high level information
620  */
621  _internal_cleanup_hl_info( state );
623  return ( retval );
624  }
625  }
626  /* start the EventSet */
627  if ( ( retval = _internal_start_hl_counters( state ) ) == PAPI_OK ) {
628  state->running = HL_START;
629  state->num_evts = ( short ) array_len;
630  }
631  return ( retval );
632 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
short int num_evts
Definition: papi_hl.c:41
int _internal_check_state(HighLevelInfo **state)
Definition: papi_hl.c:100
int retval
Definition: zero_fork.c:53
char events[MAX_EVENTS][BUFSIZ]
int _internal_start_hl_counters(HighLevelInfo *state)
Definition: papi_hl.c:146
#define HL_START
Definition: papi_hl.c:27
#define PAPI_EISRUN
Definition: fpapi.h:115
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
void _internal_cleanup_hl_info(HighLevelInfo *state)
Definition: papi_hl.c:152
short int running
Definition: papi_hl.c:42
int EventSet
Definition: papi_hl.c:40
int i
Definition: fileop.c:140

◆ PAPI_stop_counters()

int PAPI_stop_counters ( long long *  values,
int  array_len 
)

stop counters and return current counts

Definition at line 807 of file papi_hl.c.

808 {
809  int retval;
810  HighLevelInfo *state = NULL;
811 
812  if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK )
813  return ( retval );
814 
815  if ( state->running == 0 )
816  return ( PAPI_ENOTRUN );
817 
818  if ( state->running == HL_START ) {
819  if ( array_len < state->num_evts || values == NULL) {
820  return ( PAPI_EINVAL );
821  } else {
822  retval = PAPI_stop( state->EventSet, values );
823  }
824  }
825 
826  if ( state->running > HL_START ) {
827  long long tmp_values[3];
828  retval = PAPI_stop( state->EventSet, tmp_values );
829  }
830 
831  if ( retval == PAPI_OK ) {
832  _internal_cleanup_hl_info( state );
834  }
835  APIDBG( "PAPI_stop_counters returns %d\n", retval );
836  return retval;
837 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
#define PAPI_EINVAL
Definition: fpapi.h:106
int _internal_check_state(HighLevelInfo **state)
Definition: papi_hl.c:100
int retval
Definition: zero_fork.c:53
#define APIDBG(format, args...)
Definition: papi_debug.h:64
#define HL_START
Definition: papi_hl.c:27
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
void _internal_cleanup_hl_info(HighLevelInfo *state)
Definition: papi_hl.c:152
short int running
Definition: papi_hl.c:42
#define PAPI_ENOTRUN
Definition: fpapi.h:114
int EventSet
Definition: papi_hl.c:40
static long long values[NUM_EVENTS]
Definition: init_fini.c:10