src/components/pcp/linux-pcp.c
//---------------------------------------------------------------------
// read several pcp values. 
// This is triggered by PAPI_read( int EventSet, long long *values).
// However, the **events that we see is NOT the *values which is an
// array done by the application (or caller of PAPI_read). Instead,
// we must give *event the address of an array of our values. 
// The eventSet is represented by ctx and ctl, for us ctx is empty.
// The flags are a copy of PAPI's EventSetInfo_t.state, including
// PAPI_RUNNING, PAPI_STOPPED and other flags. We ignore that here.
//---------------------------------------------------------------------
read several pcp values.
This is triggered by PAPI_read( int EventSet, long long *values).
However, the **events that we see is NOT the *values which is an
array done by the application (or caller of PAPI_read). Instead,
we must give *event the address of an array of our values.
The eventSet is represented by ctx and ctl, for us ctx is empty.
The flags are a copy of PAPI's EventSetInfo_t.state, including
PAPI_RUNNING, PAPI_STOPPED and other flags. We ignore that here.
read several pcp values . This is triggered by PAPI_read ( int EventSet long long * values ) . However the ** events that we see is NOT the * values which is an array done by the application ( or caller of PAPI_read ) . Instead we must give * event the address of an array of our values . The eventSet is represented by ctx and ctl for us ctx is empty . The flags are a copy of PAPI ' s EventSetInfo_t . state including PAPI_RUNNING PAPI_STOPPED and other flags . We ignore that here .
static int _pcp_read(hwd_context_t *ctx,                                
         hwd_control_state_t *ctl,                                      
         long long **events,                                            
         int flags)                                                     
{
   mRtnCnt(_pcp_read);                                                  
   (void) ctx;                                                          
   (void) flags;                                                        
   _pcp_control_state_t* myCtl = ( _pcp_control_state_t* ) ctl;         
   int i, ret;
   pmResult *allFetch;                                                  
   if (events == NULL) {
      fprintf(stderr, "%s:%i:%s 'events' is null.\n", 
         __FILE__, __LINE__, FUNC);                                     
      return(PAPI_EINVAL);                                              
   }
   ret = PCP_ReadList(ctl, &allFetch);                                  
   if (ret != PAPI_OK) {                                                
      fprintf(stderr, "%s:%i:%s PCP_ReadList failed, return=%s.\n", 
         __FILE__, __LINE__, FUNC, PAPI_strerror(ret));                 
      return(ret);                                                      
   }
   for (i=0; i<myCtl->numEvents; i++) {                                 
      subZero(myCtl, i);                                                 subtract zero value in proper type. [TONY DON"T COMMENT OUT, JUST DEBUG]
   } 
   *events = (long long *) myCtl->pcpValue;                             
   pcp_pmFreeResult(allFetch);                                          
   return PAPI_OK;                                                      
}
static int _pcp_read ( hwd_context_t * ctx , hwd_control_state_t * ctl , long long * * events , int flags ) { mRtnCnt ( _pcp_read ) ; ( void ) ctx ; ( void ) flags ; _pcp_control_state_t * myCtl = ( _pcp_control_state_t * ) ctl ; int i , ret ; pmResult * allFetch ; if ( events == NULL ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ , FUNC ) ; return ( PAPI_EINVAL ) ; } ret = PCP_ReadList ( ctl , & allFetch ) ; if ( ret != PAPI_OK ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ , FUNC , PAPI_strerror ( ret ) ) ; return ( ret ) ; } for ( i = 0 ; i < myCtl -> numEvents ; i ++ ) { subZero ( myCtl , i ) ; } * events = ( long long * ) myCtl -> pcpValue ; pcp_pmFreeResult ( allFetch ) ; return PAPI_OK ; }
read several pcp values.
read several pcp values .
// unused. // contains pmIDs in event set. // for our returns. // unused; EventSetInfo_t.state. // count this function. // avoid unused var warning. // .. // make a shortcut. // vars to be allocated by call. // report error. // invalid argument. // Read the list of events we were given. // If that failed,  // report error. // exit with that error. // We have all the results and values extracted from them. // Now subtract zero value from them. // for each event,  // .. subtract zero value in proper type. [TONY DON"T COMMENT OUT, JUST DEBUG] // end loop through all events in this event set. // Done, point the caller to our results list. // pointer the caller needs.  // Clean up. // exit, all okay.