PAPI  5.0.1.0
linux-bgq-common.c
Go to the documentation of this file.
00001 /****************************/
00002 /* THIS IS OPEN SOURCE CODE */
00003 /****************************/
00004 
00021 #include "papi.h"
00022 #include "linux-bgq-common.h"
00023 
00024 /*******************************************************************************
00025  ********  BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT **********
00026  ******************************************************************************/
00027 
00028 void _check_BGPM_error( int err, char* bgpmfunc )
00029 {
00030     if ( err < 0 ) {
00031 #ifdef DEBUG_BGPM
00032         printf ( "Error: ret value is %d for BGPM API function '%s'.\n",
00033                  err, bgpmfunc);
00034 #endif
00035     }
00036 }
00037 
00038 
00039 /*
00040  * Returns all event values from the BGPM eventGroup 
00041  */
00042 long_long
00043 _common_getEventValue( unsigned event_id, int EventGroup )
00044 {   
00045     uint64_t value;
00046     int retval;
00047     
00048     retval = Bgpm_ReadEvent( EventGroup, event_id, &value );
00049     CHECK_BGPM_ERROR( retval, "Bgpm_ReadEvent" );
00050     
00051     return ( ( long_long ) value ); 
00052 }
00053 
00054 
00055 /*
00056  * Delete BGPM eventGroup and create an new empty one
00057  */
00058 void
00059 _common_deleteRecreate( int *EventGroup_ptr )
00060 {
00061 #ifdef DEBUG_BGQ
00062     printf( _AT_ " _common_deleteRecreate: *EventGroup_ptr=%d\n", *EventGroup_ptr);
00063 #endif
00064     int retval;
00065     
00066     // delete previous bgpm eventset
00067     retval = Bgpm_DeleteEventSet( *EventGroup_ptr );
00068     CHECK_BGPM_ERROR( retval, "Bgpm_DeleteEventSet" );
00069     
00070     // create a new empty bgpm eventset
00071     *EventGroup_ptr = Bgpm_CreateEventSet();
00072     CHECK_BGPM_ERROR( *EventGroup_ptr, "Bgpm_CreateEventSet" );
00073 
00074 #ifdef DEBUG_BGQ
00075     printf( _AT_ " _common_deleteRecreate: *EventGroup_ptr=%d\n", *EventGroup_ptr);
00076 #endif  
00077 }
00078 
00079 
00080 /*
00081  * Rebuild BGPM eventGroup with the events as it was prior to deletion 
00082  */
00083 void
00084 _common_rebuildEventgroup( int count, int *EventGroup_local, int *EventGroup_ptr )
00085 {
00086 #ifdef DEBUG_BGQ
00087     printf( "_common_rebuildEventgroup\n" );
00088 #endif  
00089     int i, retval;
00090     
00091     // rebuild BGPM EventGroup
00092     for ( i = 0; i < count; i++ ) {
00093         retval = Bgpm_AddEvent( *EventGroup_ptr, EventGroup_local[i] );
00094         CHECK_BGPM_ERROR( retval, "Bgpm_AddEvent" );
00095     
00096 #ifdef DEBUG_BGQ
00097         printf( "_common_rebuildEventgroup: After emptying EventGroup, event re-added: %d\n",
00098                 EventGroup_local[i] );
00099 #endif
00100     }
00101 }
00102 
00103 
00104 
00105 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines