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

Go to the source code of this file.
Data Structures | |
| struct | HighLevelInfo |
Defines | |
| #define | HL_START_COUNTERS 1 |
| #define | HL_FLIPS 2 |
| #define | HL_IPC 3 |
| #define | HL_FLOPS 4 |
| #define | PAPI_HL_READ 1 |
| #define | PAPI_HL_ACCUM 2 |
Functions | |
| int | _hl_rate_calls (float *real_time, float *proc_time, long long *ins, float *rate, unsigned int EVENT, HighLevelInfo *state) |
| 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_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 () |
Definition in file papi_hl.c.
| #define HL_START_COUNTERS 1 |
| #define PAPI_HL_ACCUM 2 |
| #define PAPI_HL_READ 1 |
| int _hl_rate_calls | ( | float * | real_time, |
| float * | proc_time, | ||
| long long * | ins, | ||
| float * | rate, | ||
| unsigned int | EVENT, | ||
| HighLevelInfo * | state | ||
| ) |
< Invalid argument
< No error
< Event does not exist
< No error
< No error
< Event does not exist
< No error
< No error
< No error
< No error
< No error
Definition at line 342 of file papi_hl.c.
{
long long values[2] = { 0, 0 };
int retval = 0;
int level = 0;
if ( EVENT == ( unsigned int ) PAPI_FP_INS )
level = HL_FLIPS;
else if ( EVENT == ( unsigned int ) PAPI_TOT_INS )
level = HL_IPC;
else if ( EVENT == ( unsigned int ) PAPI_FP_OPS )
level = HL_FLOPS;
if ( state->running != 0 && state->running != level ) {
return PAPI_EINVAL;
}
if ( state->running == 0 ) {
if ( PAPI_query_event( ( int ) EVENT ) != PAPI_OK ) {
return PAPI_ENOEVNT;
}
if ((retval=PAPI_add_event(state->EventSet,(int)EVENT))!=PAPI_OK ) {
_internal_cleanup_hl_info( state );
PAPI_cleanup_eventset( state->EventSet );
return retval;
}
if ( PAPI_query_event( ( int ) PAPI_TOT_CYC ) != PAPI_OK ) {
return PAPI_ENOEVNT;
}
if ((retval=PAPI_add_event(state->EventSet,(int)PAPI_TOT_CYC))!=PAPI_OK) {
_internal_cleanup_hl_info( state );
PAPI_cleanup_eventset( state->EventSet );
return retval;
}
state->initial_time = PAPI_get_real_usec( );
if ( ( retval = PAPI_start( state->EventSet ) ) != PAPI_OK ) {
return retval;
}
state->running = ( short ) level;
} else {
if ( ( retval = PAPI_stop( state->EventSet, values ) ) != PAPI_OK ) {
return retval;
}
/* Use Multiplication because it is much faster */
*real_time = (float) ((double) (PAPI_get_real_usec() -
state->initial_time ) * .000001 );
*proc_time = (float) ((double) values[1] * .000001 /
(( _papi_hwi_system_info.hw_info.cpu_max_mhz == 0 ) ?
1 : _papi_hwi_system_info.hw_info.cpu_max_mhz ) );
if ( *proc_time > 0 ) {
*rate = (float) ((float)values[0] *
( EVENT == ( unsigned int ) PAPI_TOT_INS ? 1 :
_papi_hwi_system_info.hw_info.cpu_max_mhz ) /
(float) ( values[1] == 0 ? 1 : values[1] ) );
}
state->total_proc_time += *proc_time;
state->total_ins += ( float ) values[0];
*proc_time = state->total_proc_time;
*ins = ( long long ) state->total_ins;
if ( ( retval = PAPI_start( state->EventSet ) ) != PAPI_OK ) {
state->running = 0;
return retval;
}
}
return PAPI_OK;
}


| 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.
< Used with setting up array
< Used with setting up array
< No error
< Insufficient memory
< No error
< No error
< No error
Definition at line 98 of file papi_hl.c.
{
int retval;
HighLevelInfo *state = NULL;
/* Only allow one thread at a time in here */
if ( init_level == PAPI_NOT_INITED ) {
retval = PAPI_library_init( PAPI_VER_CURRENT );
if ( retval != PAPI_VER_CURRENT ) {
return ( retval );
} else {
_papi_hwi_lock( HIGHLEVEL_LOCK );
init_level = PAPI_HIGH_LEVEL_INITED;
_papi_hwi_unlock( HIGHLEVEL_LOCK );
}
}
/*
* Do we have the thread specific data setup yet?
*/
if ( ( retval =
PAPI_get_thr_specific( PAPI_HIGH_LEVEL_TLS, ( void * ) &state ) )
!= PAPI_OK || state == NULL ) {
state = ( HighLevelInfo * ) papi_malloc( sizeof ( HighLevelInfo ) );
if ( state == NULL )
return ( PAPI_ENOMEM );
memset( state, 0, sizeof ( HighLevelInfo ) );
state->EventSet = -1;
if ( ( retval = PAPI_create_eventset( &state->EventSet ) ) != PAPI_OK )
return ( retval );
if ( ( retval =
PAPI_set_thr_specific( PAPI_HIGH_LEVEL_TLS,
state ) ) != PAPI_OK )
return ( retval );
}
*outgoing = state;
return ( PAPI_OK );
}


| void _internal_cleanup_hl_info | ( | HighLevelInfo * | state | ) |
Definition at line 150 of file papi_hl.c.
{
state->num_evts = 0;
state->running = 0;
state->initial_time = -1;
state->total_proc_time = 0;
state->total_ins = 0;
return;
}

| int _internal_hl_read_cnts | ( | long long * | values, |
| int | array_len, | ||
| int | flag | ||
| ) |
< No error
< Invalid argument
< No error
< Invalid argument
Definition at line 557 of file papi_hl.c.
{
int retval;
HighLevelInfo *state = NULL;
if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK )
return ( retval );
if ( state->running != HL_START_COUNTERS || array_len < state->num_evts )
return ( PAPI_EINVAL );
if ( flag == PAPI_HL_ACCUM )
return ( PAPI_accum( state->EventSet, values ) );
else if ( flag == PAPI_HL_READ ) {
if ( ( retval = PAPI_read( state->EventSet, values ) ) != PAPI_OK )
return ( retval );
return ( PAPI_reset( state->EventSet ) );
}
/* Invalid flag passed in */
return ( PAPI_EINVAL );
}


| int _internal_start_hl_counters | ( | HighLevelInfo * | state | ) |
Make sure to allocate space for values
Definition at line 144 of file papi_hl.c.
{
return ( PAPI_start( state->EventSet ) );
}


| void _papi_hwi_shutdown_highlevel | ( | ) |
< No error
Definition at line 754 of file papi_hl.c.
{
HighLevelInfo *state = NULL;
if ( PAPI_get_thr_specific( PAPI_HIGH_LEVEL_TLS, ( void * ) &state ) ==
PAPI_OK ) {
if ( state )
papi_free( state );
}
}

