PAPI  5.3.0.0
linux-CNKunit.c File Reference

This file has the source code for a component that enables PAPI-C to access hardware monitoring counters for BG/Q through the bgpm library. More...

Include dependency graph for linux-CNKunit.c:

Go to the source code of this file.

Functions

int CNKUNIT_init_thread (hwd_context_t *ctx)
int CNKUNIT_init_component (int cidx)
int CNKUNIT_init_control_state (hwd_control_state_t *ptr)
int CNKUNIT_start (hwd_context_t *ctx, hwd_control_state_t *ptr)
int CNKUNIT_stop (hwd_context_t *ctx, hwd_control_state_t *ptr)
int CNKUNIT_read (hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **events, int flags)
int CNKUNIT_shutdown_thread (hwd_context_t *ctx)
int CNKUNIT_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
int CNKUNIT_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
int CNKUNIT_set_domain (hwd_control_state_t *cntrl, int domain)
int CNKUNIT_reset (hwd_context_t *ctx, hwd_control_state_t *ptr)
int CNKUNIT_cleanup_eventset (hwd_control_state_t *ctrl)
int CNKUNIT_ntv_enum_events (unsigned int *EventCode, int modifier)
int CNKUNIT_ntv_name_to_code (char *name, unsigned int *event_code)
int CNKUNIT_ntv_code_to_name (unsigned int EventCode, char *name, int len)
int CNKUNIT_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
int CNKUNIT_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)

Variables

papi_vector_t _CNKunit_vector

Detailed Description

Author:
Heike Jagode jagode@eecs.utk.edu Mods: < your name here > < your email address > BGPM / CNKunit component

Tested version of bgpm (early access)

Definition in file linux-CNKunit.c.


Function Documentation

Definition at line 307 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_cleanup_eventset\n" );
#endif
    int retval;

    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ctrl;
        
    // create a new empty bgpm eventset
    // reason: bgpm doesn't permit to remove events from an eventset; 
    // hence we delete the old eventset and create a new one
    retval = _common_deleteRecreate( &this_state->EventGroup ); // HJ try to use delete() only
    if ( retval < 0 ) return retval;

    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 185 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_ctl\n" );
#endif
    ( void ) ctx;
    ( void ) code;
    ( void ) option;
    return ( PAPI_OK );
}
int CNKUNIT_init_component ( int  cidx)

Definition at line 49 of file linux-CNKunit.c.

{  
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_init_component\n" );
#endif

    _CNKunit_vector.cmp_info.CmpIdx = cidx;
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_init_component cidx = %d\n", cidx );
#endif
    
    return ( PAPI_OK );
}

Definition at line 69 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_init_control_state\n" );
#endif
    int retval;

    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
    
    this_state->EventGroup = Bgpm_CreateEventSet();
    retval = _check_BGPM_error( this_state->EventGroup, "Bgpm_CreateEventSet" );
    if ( retval < 0 ) return retval;

    return PAPI_OK;
}

Here is the call graph for this function:

Definition at line 33 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_init_thread\n" );
#endif
    
    ( void ) ctx;
    return PAPI_OK;
}
int CNKUNIT_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 447 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_ntv_code_to_bits\n" );
#endif
    ( void ) EventCode;
    ( void ) bits;
    return ( PAPI_OK );
}
int CNKUNIT_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 426 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    //printf( "CNKUNIT_ntv_code_to_descr\n" );
#endif
    int retval, index;
    
    index = ( EventCode ) + OFFSET;
    
    retval = Bgpm_GetLongDesc( index, name, &len );
    retval = _check_BGPM_error( retval, "Bgpm_GetLongDesc" );                        
    if ( retval < 0 ) return retval;

    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 396 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    //printf( "CNKUNIT_ntv_code_to_name\n" );
#endif
    int index;
    
    index = ( EventCode ) + OFFSET;

    if ( index >= MAX_COUNTERS )
        return PAPI_ENOEVNT;

    strncpy( name, Bgpm_GetEventIdLabel( index ), len );
    //printf("----%s----\n", name);
    
    if ( name == NULL ) {
#ifdef DEBUG_BGPM
        printf ("Error: ret value is NULL for BGPM API function Bgpm_GetEventIdLabel.\n" );
#endif
        return PAPI_ENOEVNT;
    }
    
    return ( PAPI_OK );
}
int CNKUNIT_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

Definition at line 330 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
//  printf( "CNKUNIT_ntv_enum_events\n" );
#endif

    switch ( modifier ) {
    case PAPI_ENUM_FIRST:
        *EventCode = 0;

        return ( PAPI_OK );
        break;

    case PAPI_ENUM_EVENTS:
    {
        int index = ( *EventCode ) + OFFSET;

        if ( index < CNKUNIT_MAX_COUNTERS ) {
            *EventCode = *EventCode + 1;
            return ( PAPI_OK );
        } else
            return ( PAPI_ENOEVNT );

        break;
    }
    default:
        return ( PAPI_EINVAL );
    }
    return ( PAPI_EINVAL );
}
int CNKUNIT_ntv_name_to_code ( char *  name,
unsigned int *  event_code 
)

Definition at line 366 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_ntv_name_to_code\n" );
#endif
    int ret;
    
    /* Return event id matching a given event label string */
    ret = Bgpm_GetEventIdFromLabel ( name );
    
    if ( ret <= 0 ) {
#ifdef DEBUG_BGPM
        printf ("Error: ret value is %d for BGPM API function '%s'.\n",
                ret, "Bgpm_GetEventIdFromLabel" );
#endif
        return PAPI_ENOEVNT;
    }
    else if ( ret < OFFSET || ret > CNKUNIT_MAX_COUNTERS ) // not a CNKUnit event
        return PAPI_ENOEVNT;
    else
        *event_code = ( ret - OFFSET ) ;
    
    return PAPI_OK;
}
int CNKUNIT_read ( hwd_context_t ctx,
hwd_control_state_t ptr,
long_long **  events,
int  flags 
)

Definition at line 138 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_read\n" );
#endif
    ( void ) ctx;
    ( void ) flags;
    int i, numEvts;
    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
    
    numEvts = Bgpm_NumEvents( this_state->EventGroup );
    if ( numEvts == 0 ) {
#ifdef DEBUG_BGPM
        printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
#endif
        //return ( EXIT_FAILURE );
    }
        
    for ( i = 0; i < numEvts; i++ )
        this_state->counts[i] = _common_getEventValue( i, this_state->EventGroup );

    *events = this_state->counts;
    
    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_reset ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 276 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_reset\n" );
#endif
    ( void ) ctx;
    int retval;
    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;

    /* we can't simply call Bgpm_Reset() since PAPI doesn't have the 
     restriction that an EventSet has to be stopped before resetting is
     possible. However, BGPM does have this restriction. 
     Hence we need to stop, reset and start */
    retval = Bgpm_Stop( this_state->EventGroup );
    retval = _check_BGPM_error( retval, "Bgpm_Stop" );
    if ( retval < 0 ) return retval;

    retval = Bgpm_ResetStart( this_state->EventGroup );
    retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
    if ( retval < 0 ) return retval;

    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 248 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_set_domain\n" );
#endif
    int found = 0;
    ( void ) cntrl;

    if ( PAPI_DOM_USER & domain )
        found = 1;

    if ( PAPI_DOM_KERNEL & domain )
        found = 1;

    if ( PAPI_DOM_OTHER & domain )
        found = 1;

    if ( !found )
        return ( PAPI_EINVAL );

    return ( PAPI_OK );
}

Definition at line 170 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_shutdown_thread\n" );
#endif
    ( void ) ctx;
    return ( PAPI_OK );
}
int CNKUNIT_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 90 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_start\n" );
#endif
    ( void ) ctx;
    int retval;
    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
    
    retval = Bgpm_Apply( this_state->EventGroup ); 
    retval = _check_BGPM_error( retval, "Bgpm_Apply" );
    if ( retval < 0 ) return retval;

    /* Bgpm_Apply() does an implicit reset; 
     hence no need to use Bgpm_ResetStart */
    retval = Bgpm_Start( this_state->EventGroup );
    retval = _check_BGPM_error( retval, "Bgpm_Start" );
    if ( retval < 0 ) return retval;

    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_stop ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 117 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_stop\n" );
#endif
    ( void ) ctx;
    int retval;
    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
    
    retval = Bgpm_Stop( this_state->EventGroup );
    retval = _check_BGPM_error( retval, "Bgpm_Stop" );
    if ( retval < 0 ) return retval;

    return ( PAPI_OK );
}

Here is the call graph for this function:

int CNKUNIT_update_control_state ( hwd_control_state_t ptr,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 202 of file linux-CNKunit.c.

{
#ifdef DEBUG_BGQ
    printf( "CNKUNIT_update_control_state: count = %d\n", count );
#endif
    ( void ) ctx;
    int retval, index, i;
    CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
    
    // Delete and re-create BGPM eventset
    retval = _common_deleteRecreate( &this_state->EventGroup );
    if ( retval < 0 ) return retval;
    
    // otherwise, add the events to the eventset
    for ( i = 0; i < count; i++ ) {
        index = ( native[i].ni_event ) + OFFSET;
        
        native[i].ni_position = i;
        
#ifdef DEBUG_BGQ
        printf("CNKUNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index );
#endif
        
        /* Add events to the BGPM eventGroup */
        retval = Bgpm_AddEvent( this_state->EventGroup, index );
        retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
        if ( retval < 0 ) return retval;
    }
    
    return ( PAPI_OK );
}

Here is the call graph for this function:


Variable Documentation

Definition at line 23 of file linux-CNKunit.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines