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

int CNKUNIT_cleanup_eventset ( hwd_control_state_t ctrl  ) 

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

00308 {
00309 #ifdef DEBUG_BGQ
00310     printf( "CNKUNIT_cleanup_eventset\n" );
00311 #endif
00312     int retval;
00313 
00314     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ctrl;
00315         
00316     // create a new empty bgpm eventset
00317     // reason: bgpm doesn't permit to remove events from an eventset; 
00318     // hence we delete the old eventset and create a new one
00319     retval = _common_deleteRecreate( &this_state->EventGroup ); // HJ try to use delete() only
00320     if ( retval < 0 ) return retval;
00321 
00322     return ( PAPI_OK );
00323 }

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.

00186 {
00187 #ifdef DEBUG_BGQ
00188     printf( "CNKUNIT_ctl\n" );
00189 #endif
00190     ( void ) ctx;
00191     ( void ) code;
00192     ( void ) option;
00193     return ( PAPI_OK );
00194 }

int CNKUNIT_init_component ( int  cidx  ) 

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

00050 {  
00051 #ifdef DEBUG_BGQ
00052     printf( "CNKUNIT_init_component\n" );
00053 #endif
00054 
00055     _CNKunit_vector.cmp_info.CmpIdx = cidx;
00056 #ifdef DEBUG_BGQ
00057     printf( "CNKUNIT_init_component cidx = %d\n", cidx );
00058 #endif
00059     
00060     return ( PAPI_OK );
00061 }

int CNKUNIT_init_control_state ( hwd_control_state_t ptr  ) 

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

00070 {
00071 #ifdef DEBUG_BGQ
00072     printf( "CNKUNIT_init_control_state\n" );
00073 #endif
00074     int retval;
00075 
00076     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00077     
00078     this_state->EventGroup = Bgpm_CreateEventSet();
00079     retval = _check_BGPM_error( this_state->EventGroup, "Bgpm_CreateEventSet" );
00080     if ( retval < 0 ) return retval;
00081 
00082     return PAPI_OK;
00083 }

Here is the call graph for this function:

int CNKUNIT_init_thread ( hwd_context_t ctx  ) 

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

00034 {
00035 #ifdef DEBUG_BGQ
00036     printf( "CNKUNIT_init_thread\n" );
00037 #endif
00038     
00039     ( void ) ctx;
00040     return PAPI_OK;
00041 }

int CNKUNIT_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

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

00448 {
00449 #ifdef DEBUG_BGQ
00450     printf( "CNKUNIT_ntv_code_to_bits\n" );
00451 #endif
00452     ( void ) EventCode;
00453     ( void ) bits;
00454     return ( PAPI_OK );
00455 }

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

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

00427 {
00428 #ifdef DEBUG_BGQ
00429     //printf( "CNKUNIT_ntv_code_to_descr\n" );
00430 #endif
00431     int retval, index;
00432     
00433     index = ( EventCode ) + OFFSET;
00434     
00435     retval = Bgpm_GetLongDesc( index, name, &len );
00436     retval = _check_BGPM_error( retval, "Bgpm_GetLongDesc" );                        
00437     if ( retval < 0 ) return retval;
00438 
00439     return ( PAPI_OK );
00440 }

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.

00397 {
00398 #ifdef DEBUG_BGQ
00399     //printf( "CNKUNIT_ntv_code_to_name\n" );
00400 #endif
00401     int index;
00402     
00403     index = ( EventCode ) + OFFSET;
00404 
00405     if ( index >= MAX_COUNTERS )
00406         return PAPI_ENOEVNT;
00407 
00408     strncpy( name, Bgpm_GetEventIdLabel( index ), len );
00409     //printf("----%s----\n", name);
00410     
00411     if ( name == NULL ) {
00412 #ifdef DEBUG_BGPM
00413         printf ("Error: ret value is NULL for BGPM API function Bgpm_GetEventIdLabel.\n" );
00414 #endif
00415         return PAPI_ENOEVNT;
00416     }
00417     
00418     return ( PAPI_OK );
00419 }

int CNKUNIT_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

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

00331 {
00332 #ifdef DEBUG_BGQ
00333 //  printf( "CNKUNIT_ntv_enum_events\n" );
00334 #endif
00335 
00336     switch ( modifier ) {
00337     case PAPI_ENUM_FIRST:
00338         *EventCode = 0;
00339 
00340         return ( PAPI_OK );
00341         break;
00342 
00343     case PAPI_ENUM_EVENTS:
00344     {
00345         int index = ( *EventCode ) + OFFSET;
00346 
00347         if ( index < CNKUNIT_MAX_COUNTERS ) {
00348             *EventCode = *EventCode + 1;
00349             return ( PAPI_OK );
00350         } else
00351             return ( PAPI_ENOEVNT );
00352 
00353         break;
00354     }
00355     default:
00356         return ( PAPI_EINVAL );
00357     }
00358     return ( PAPI_EINVAL );
00359 }

int CNKUNIT_ntv_name_to_code ( char *  name,
unsigned int *  event_code 
)

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

00367 {
00368 #ifdef DEBUG_BGQ
00369     printf( "CNKUNIT_ntv_name_to_code\n" );
00370 #endif
00371     int ret;
00372     
00373     /* Return event id matching a given event label string */
00374     ret = Bgpm_GetEventIdFromLabel ( name );
00375     
00376     if ( ret <= 0 ) {
00377 #ifdef DEBUG_BGPM
00378         printf ("Error: ret value is %d for BGPM API function '%s'.\n",
00379                 ret, "Bgpm_GetEventIdFromLabel" );
00380 #endif
00381         return PAPI_ENOEVNT;
00382     }
00383     else if ( ret < OFFSET || ret > CNKUNIT_MAX_COUNTERS ) // not a CNKUnit event
00384         return PAPI_ENOEVNT;
00385     else
00386         *event_code = ( ret - OFFSET ) ;
00387     
00388     return PAPI_OK;
00389 }

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.

00140 {
00141 #ifdef DEBUG_BGQ
00142     printf( "CNKUNIT_read\n" );
00143 #endif
00144     ( void ) ctx;
00145     ( void ) flags;
00146     int i, numEvts;
00147     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00148     
00149     numEvts = Bgpm_NumEvents( this_state->EventGroup );
00150     if ( numEvts == 0 ) {
00151 #ifdef DEBUG_BGPM
00152         printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
00153 #endif
00154         //return ( EXIT_FAILURE );
00155     }
00156         
00157     for ( i = 0; i < numEvts; i++ )
00158         this_state->counts[i] = _common_getEventValue( i, this_state->EventGroup );
00159 
00160     *events = this_state->counts;
00161     
00162     return ( PAPI_OK );
00163 }

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.

00277 {
00278 #ifdef DEBUG_BGQ
00279     printf( "CNKUNIT_reset\n" );
00280 #endif
00281     ( void ) ctx;
00282     int retval;
00283     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00284 
00285     /* we can't simply call Bgpm_Reset() since PAPI doesn't have the 
00286      restriction that an EventSet has to be stopped before resetting is
00287      possible. However, BGPM does have this restriction. 
00288      Hence we need to stop, reset and start */
00289     retval = Bgpm_Stop( this_state->EventGroup );
00290     retval = _check_BGPM_error( retval, "Bgpm_Stop" );
00291     if ( retval < 0 ) return retval;
00292 
00293     retval = Bgpm_ResetStart( this_state->EventGroup );
00294     retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
00295     if ( retval < 0 ) return retval;
00296 
00297     return ( PAPI_OK );
00298 }

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.

00249 {
00250 #ifdef DEBUG_BGQ
00251     printf( "CNKUNIT_set_domain\n" );
00252 #endif
00253     int found = 0;
00254     ( void ) cntrl;
00255 
00256     if ( PAPI_DOM_USER & domain )
00257         found = 1;
00258 
00259     if ( PAPI_DOM_KERNEL & domain )
00260         found = 1;
00261 
00262     if ( PAPI_DOM_OTHER & domain )
00263         found = 1;
00264 
00265     if ( !found )
00266         return ( PAPI_EINVAL );
00267 
00268     return ( PAPI_OK );
00269 }

int CNKUNIT_shutdown_thread ( hwd_context_t ctx  ) 

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

00171 {
00172 #ifdef DEBUG_BGQ
00173     printf( "CNKUNIT_shutdown_thread\n" );
00174 #endif
00175     ( void ) ctx;
00176     return ( PAPI_OK );
00177 }

int CNKUNIT_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

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

00091 {
00092 #ifdef DEBUG_BGQ
00093     printf( "CNKUNIT_start\n" );
00094 #endif
00095     ( void ) ctx;
00096     int retval;
00097     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00098     
00099     retval = Bgpm_Apply( this_state->EventGroup ); 
00100     retval = _check_BGPM_error( retval, "Bgpm_Apply" );
00101     if ( retval < 0 ) return retval;
00102 
00103     /* Bgpm_Apply() does an implicit reset; 
00104      hence no need to use Bgpm_ResetStart */
00105     retval = Bgpm_Start( this_state->EventGroup );
00106     retval = _check_BGPM_error( retval, "Bgpm_Start" );
00107     if ( retval < 0 ) return retval;
00108 
00109     return ( PAPI_OK );
00110 }

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.

00118 {
00119 #ifdef DEBUG_BGQ
00120     printf( "CNKUNIT_stop\n" );
00121 #endif
00122     ( void ) ctx;
00123     int retval;
00124     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00125     
00126     retval = Bgpm_Stop( this_state->EventGroup );
00127     retval = _check_BGPM_error( retval, "Bgpm_Stop" );
00128     if ( retval < 0 ) return retval;
00129 
00130     return ( PAPI_OK );
00131 }

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.

00205 {
00206 #ifdef DEBUG_BGQ
00207     printf( "CNKUNIT_update_control_state: count = %d\n", count );
00208 #endif
00209     ( void ) ctx;
00210     int retval, index, i;
00211     CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
00212     
00213     // Delete and re-create BGPM eventset
00214     retval = _common_deleteRecreate( &this_state->EventGroup );
00215     if ( retval < 0 ) return retval;
00216     
00217     // otherwise, add the events to the eventset
00218     for ( i = 0; i < count; i++ ) {
00219         index = ( native[i].ni_event ) + OFFSET;
00220         
00221         native[i].ni_position = i;
00222         
00223 #ifdef DEBUG_BGQ
00224         printf("CNKUNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index );
00225 #endif
00226         
00227         /* Add events to the BGPM eventGroup */
00228         retval = Bgpm_AddEvent( this_state->EventGroup, index );
00229         retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
00230         if ( retval < 0 ) return retval;
00231     }
00232     
00233     return ( PAPI_OK );
00234 }

Here is the call graph for this function:


Variable Documentation

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


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1