linux-NWunit.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-NWunit.c:

Go to the source code of this file.

Functions

int NWUNIT_init_thread (hwd_context_t *ctx)
int NWUNIT_init_component (int cidx)
int NWUNIT_init_control_state (hwd_control_state_t *ptr)
int NWUNIT_start (hwd_context_t *ctx, hwd_control_state_t *ptr)
int NWUNIT_stop (hwd_context_t *ctx, hwd_control_state_t *ptr)
int NWUNIT_read (hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **events, int flags)
int NWUNIT_shutdown_thread (hwd_context_t *ctx)
int NWUNIT_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
int NWUNIT_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
int NWUNIT_set_domain (hwd_control_state_t *cntrl, int domain)
int NWUNIT_reset (hwd_context_t *ctx, hwd_control_state_t *ptr)
int NWUNIT_cleanup_eventset (hwd_control_state_t *ctrl)
int NWUNIT_ntv_enum_events (unsigned int *EventCode, int modifier)
int NWUNIT_ntv_name_to_code (char *name, unsigned int *event_code)
int NWUNIT_ntv_code_to_name (unsigned int EventCode, char *name, int len)
int NWUNIT_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
int NWUNIT_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)

Variables

papi_vector_t _NWunit_vector

Detailed Description

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

Tested version of bgpm (early access)

Definition in file linux-NWunit.c.


Function Documentation

int NWUNIT_cleanup_eventset ( hwd_control_state_t ctrl  ) 

Definition at line 310 of file linux-NWunit.c.

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

Here is the call graph for this function:

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

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

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

int NWUNIT_init_component ( int  cidx  ) 

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

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

int NWUNIT_init_control_state ( hwd_control_state_t ptr  ) 

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

00070 {
00071 #ifdef DEBUG_BGQ
00072     printf( "NWUNIT_init_control_state\n" );
00073 #endif
00074     int retval;
00075 
00076     NWUNIT_control_state_t * this_state = ( NWUNIT_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 NWUNIT_init_thread ( hwd_context_t ctx  ) 

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

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

int NWUNIT_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

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

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

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

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

00427 {
00428 #ifdef DEBUG_BGQ
00429     //printf( "NWUNIT_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 NWUNIT_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 397 of file linux-NWunit.c.

00398 {
00399 #ifdef DEBUG_BGQ
00400     //printf( "NWUNIT_ntv_code_to_name\n" );
00401 #endif
00402     int index;
00403     
00404     index = ( EventCode ) + OFFSET;
00405 
00406     if ( index >= MAX_COUNTERS )
00407         return PAPI_ENOEVNT;
00408 
00409     strncpy( name, Bgpm_GetEventIdLabel( index ), len );
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 NWUNIT_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

Definition at line 333 of file linux-NWunit.c.

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

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

Definition at line 367 of file linux-NWunit.c.

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

int NWUNIT_read ( hwd_context_t ctx,
hwd_control_state_t ptr,
long_long **  events,
int  flags 
)

Definition at line 137 of file linux-NWunit.c.

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

Here is the call graph for this function:

int NWUNIT_reset ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 279 of file linux-NWunit.c.

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

Here is the call graph for this function:

int NWUNIT_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 251 of file linux-NWunit.c.

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

int NWUNIT_shutdown_thread ( hwd_context_t ctx  ) 

Definition at line 169 of file linux-NWunit.c.

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

int NWUNIT_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

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

00091 {
00092 #ifdef DEBUG_BGQ
00093     printf( "NWUNIT_start\n" );
00094 #endif
00095     
00096     ( void ) ctx;
00097     int retval;
00098     NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
00099 
00100     retval = Bgpm_Attach( this_state->EventGroup, UPC_NW_ALL_LINKS, 0); 
00101     retval = _check_BGPM_error( retval, "Bgpm_Attach" );
00102     if ( retval < 0 ) return retval;
00103 
00104     retval = Bgpm_ResetStart( this_state->EventGroup );
00105     retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
00106     if ( retval < 0 ) return retval;
00107 
00108     return ( PAPI_OK );
00109 }

Here is the call graph for this function:

int NWUNIT_stop ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 116 of file linux-NWunit.c.

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

Here is the call graph for this function:

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

Definition at line 205 of file linux-NWunit.c.

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

Here is the call graph for this function:


Variable Documentation

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


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1