PAPI  5.7.0.0
linux-pcp.c File Reference
Include dependency graph for linux-pcp.c:

Go to the source code of this file.

Data Structures

union  uPointer_t
 
union  convert_64_t
 
struct  _pcp_register_t
 
struct  _pcp_event_info_t
 
struct  _pcp_reg_alloc_t
 
struct  _pcp_control_state_t
 
struct  _pcp_context_t
 
struct  _pcp_hash_t
 
struct  _pcp_domain_cache_t
 

Macros

#define FUNC   __func__ /* force it. */
 
#define AGENT_NAME   "perfevent" /* Power9 PCP. */
 
#define MYPCPLIB   "libpcp.so"
 
#define PM_OPTFLAG_EXIT   (1<<5)
 
#define PM_CONTEXT_UNDEF   -1
 
#define PM_CONTEXT_HOST   1
 
#define PM_CONTEXT_ARCHIVE   2
 
#define PM_CONTEXT_LOCAL   3
 
#define HASH_SIZE   512 /* very roughly in the range of total events. full Saturn test, had ~ 11,000 events.*/
 
#define COUNT_ROUTINES   1 /* Change to zero to stop counting. */
 
#define mRtnCnt(funcname)
 
#define mConvertUsec(timeval_)   (timeval_.tv_sec*1000000+timeval_.tv_usec) /* avoid typos. */
 
#define _prog_fprintf   if (0) fprintf /* change to 1 to enable printing of progress debug messages. */
 
#define _time_fprintf   if (0) fprintf /* change to 1 to enable printing of performance timings. */
 
#define _time_gettimeofday   if (0) gettimeofday /* change to 1 to enable gettimeofday for performance timings. */
 
#define mCheck_DL_Status(err, str)
 
#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define mGet_DL_FPtr(Name)
 
#define hostnameLen   512 /* constant used multiple times. */
 
#define LNBLOCK   256 /* Power9 gets IPC errors if read block is too large. */
 
#define BlockSize   64 /* constant used multiple times. */
 

Enumerations

enum  {
  ctr_pcp_init_thread, ctr_pcp_init_component, ctr_pcp_init_control_state, ctr_pcp_start,
  ctr_pcp_stop, ctr_pcp_read, ctr_pcp_shutdown_thread, ctr_pcp_shutdown_component,
  ctr_pcp_ctl, ctr_pcp_update_control_state, ctr_pcp_set_domain, ctr_pcp_reset,
  ctr_pcp_ntv_enum_events, ctr_pcp_ntv_name_to_code, ctr_pcp_ntv_code_to_name, ctr_pcp_ntv_code_to_descr,
  ctr_pcp_ntv_code_to_info
}
 

Functions

static char * cachedGetInDom (pmInDom indom, int inst)
 
static char * pcp_pmErrStr (int code)
 
static int pcp_pmTraversePMNS (const char *name, void(*func)(const char *))
 
void pcp_pmFreeResult (pmResult *result)
 
static int pcp_pmNewContext (int type, const char *name)
 
static int pcp_pmDestroyContext (int handle)
 
static int pcp_pmFetch (int numpid, pmID *pmidlist, pmResult **result)
 
static int pcp_pmLookupDesc (pmID pmid, pmDesc *desc)
 
static int pcp_pmGetInDom (pmInDom indom, int **instlist, char ***namelist)
 
static int pcp_pmLookupText (pmID pmid, int level, char **buffer)
 
static char * pcp_pmUnitsStr_r (const pmUnits *pu, char *buf, int buflen)
 
unsigned int stringHash (char *str, unsigned int tableSize)
 
unsigned int addNameHash (char *key, int idx)
 
void freeNameHash (void)
 
int findNameHash (char *key)
 
int _local_linkDynamicLibraries (void)
 
int qsPMID (const void *arg1, const void *arg2)
 
void cbPopulateNameOnly (const char *name)
 
void makeQualifiedEvent (int baseEvent, int idx, char *qualifier)
 
void getPMDesc (int pcpIdx)
 
unsigned long long getULLValue (pmValueSet *vset, int value_index)
 
void subZero (_pcp_control_state_t *myCtl, int event)
 
int getHelpText (unsigned int pcpIdx, char **helpText)
 
static int _pcp_init_component (int cidx)
 
static int _pcp_init_thread (hwd_context_t *ctx)
 
static int _pcp_init_control_state (hwd_control_state_t *ctl)
 
static int _pcp_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int PCP_ReadList (hwd_control_state_t *ctl, pmResult **results)
 
static int _pcp_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _pcp_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _pcp_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
static int _pcp_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _pcp_shutdown_thread (hwd_context_t *ctx)
 
static int _pcp_shutdown_component (void)
 
static int _pcp_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int _pcp_set_domain (hwd_control_state_t *ctl, int domain)
 
static int _pcp_ntv_enum_events (unsigned int *EventCode, int modifier)
 
static int _pcp_ntv_name_to_code (const char *name, unsigned int *event_code)
 
static int _pcp_ntv_code_to_name (unsigned int pcpIdx, char *name, int len)
 
static int _pcp_ntv_code_to_descr (unsigned int pcpIdx, char *descr, int len)
 
static int _pcp_ntv_code_to_info (unsigned int pcpIdx, PAPI_event_info_t *info)
 

Variables

papi_vector_t _pcp_vector
 
int _papi_hwi_debug = DEBUG_SUBSTRATE
 
static int sEventInfoSize =0
 
static int sEventInfoBlock = ((8*1024) / sizeof(_pcp_event_info_t))
 
static _pcp_event_info_tpcp_event_info = NULL
 
static int sEventCount = 0
 
int ctxHandle = -1
 
char * pmProgname = "pcp"
 
static _pcp_hash_t sNameHash [HASH_SIZE]
 
int cnt [ctr_pcp_ntv_code_to_info+1] = {0}
 
static struct timeval t1 t2
 
static void * dllib1 = NULL
 
void(* _dl_non_dynamic_init )(void)
 

Macro Definition Documentation

◆ _prog_fprintf

#define _prog_fprintf   if (0) fprintf /* change to 1 to enable printing of progress debug messages. */

Definition at line 239 of file linux-pcp.c.

◆ _time_fprintf

#define _time_fprintf   if (0) fprintf /* change to 1 to enable printing of performance timings. */

Definition at line 240 of file linux-pcp.c.

◆ _time_gettimeofday

#define _time_gettimeofday   if (0) gettimeofday /* change to 1 to enable gettimeofday for performance timings. */

Definition at line 241 of file linux-pcp.c.

◆ AGENT_NAME

#define AGENT_NAME   "perfevent" /* Power9 PCP. */

Definition at line 42 of file linux-pcp.c.

◆ BlockSize

#define BlockSize   64 /* constant used multiple times. */

◆ COUNT_ROUTINES

#define COUNT_ROUTINES   1 /* Change to zero to stop counting. */

Definition at line 194 of file linux-pcp.c.

◆ FUNC

#define FUNC   __func__ /* force it. */

Definition at line 36 of file linux-pcp.c.

◆ HASH_SIZE

#define HASH_SIZE   512 /* very roughly in the range of total events. full Saturn test, had ~ 11,000 events.*/

Definition at line 191 of file linux-pcp.c.

◆ hostnameLen

#define hostnameLen   512 /* constant used multiple times. */

◆ LNBLOCK

#define LNBLOCK   256 /* Power9 gets IPC errors if read block is too large. */

◆ mCheck_DL_Status

#define mCheck_DL_Status (   err,
  str 
)
Value:
if( err ) \
{ \
return (PAPI_ENOSUPP ); \
}
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:637
#define PAPI_ENOSUPP
Definition: fpapi.h:123
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t _pcp_vector
Definition: linux-pcp.c:178
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43

Definition at line 400 of file linux-pcp.c.

◆ mConvertUsec

#define mConvertUsec (   timeval_)    (timeval_.tv_sec*1000000+timeval_.tv_usec) /* avoid typos. */

Definition at line 236 of file linux-pcp.c.

◆ mGet_DL_FPtr

#define mGet_DL_FPtr (   Name)
Value:
Name##_ptr = dlsym(dllib1, TOSTRING(Name)); \
mCheck_DL_Status(dlerror()!=NULL, "PCP library function " \
TOSTRING(Name) " not found in " MYPCPLIB ".");
static void * dllib1
Definition: linux-pcp.c:244
#define TOSTRING(x)
Definition: linux-pcp.c:413
#define MYPCPLIB
Definition: linux-pcp.c:55

Definition at line 414 of file linux-pcp.c.

◆ mRtnCnt

#define mRtnCnt (   funcname)
Value:
if (COUNT_ROUTINES) { /* Note if (0) optimized out completely even if -O0. */ \
cnt[ctr##funcname]++; /* Increment counter. */ \
if (cnt[ctr##funcname] == 1) /* If first time entering a new function, report it. */ \
_prog_fprintf(stderr, "Entered " TOSTRING(funcname) "\n"); \
}
#define COUNT_ROUTINES
Definition: linux-pcp.c:194
#define TOSTRING(x)
Definition: linux-pcp.c:413
int cnt[ctr_pcp_ntv_code_to_info+1]
Definition: linux-pcp.c:215

Definition at line 217 of file linux-pcp.c.

◆ MYPCPLIB

#define MYPCPLIB   "libpcp.so"

Definition at line 55 of file linux-pcp.c.

◆ PM_CONTEXT_ARCHIVE

#define PM_CONTEXT_ARCHIVE   2

Definition at line 60 of file linux-pcp.c.

◆ PM_CONTEXT_HOST

#define PM_CONTEXT_HOST   1

Definition at line 59 of file linux-pcp.c.

◆ PM_CONTEXT_LOCAL

#define PM_CONTEXT_LOCAL   3

Definition at line 61 of file linux-pcp.c.

◆ PM_CONTEXT_UNDEF

#define PM_CONTEXT_UNDEF   -1

Definition at line 58 of file linux-pcp.c.

◆ PM_OPTFLAG_EXIT

#define PM_OPTFLAG_EXIT   (1<<5)

Definition at line 57 of file linux-pcp.c.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Definition at line 412 of file linux-pcp.c.

◆ TOSTRING

#define TOSTRING (   x)    STRINGIFY(x)

Definition at line 413 of file linux-pcp.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ctr_pcp_init_thread 
ctr_pcp_init_component 
ctr_pcp_init_control_state 
ctr_pcp_start 
ctr_pcp_stop 
ctr_pcp_read 
ctr_pcp_shutdown_thread 
ctr_pcp_shutdown_component 
ctr_pcp_ctl 
ctr_pcp_update_control_state 
ctr_pcp_set_domain 
ctr_pcp_reset 
ctr_pcp_ntv_enum_events 
ctr_pcp_ntv_name_to_code 
ctr_pcp_ntv_code_to_name 
ctr_pcp_ntv_code_to_descr 
ctr_pcp_ntv_code_to_info 

Definition at line 196 of file linux-pcp.c.

196  {
197 ctr_pcp_init_thread, // counter 0
198 ctr_pcp_init_component, // counter 1
199 ctr_pcp_init_control_state, // counter 2
200 ctr_pcp_start, // counter 3
201 ctr_pcp_stop, // counter 4
202 ctr_pcp_read, // counter 5
203 ctr_pcp_shutdown_thread, // counter 6
204 ctr_pcp_shutdown_component, // counter 7
205 ctr_pcp_ctl, // counter 8
206 ctr_pcp_update_control_state, // counter 9
207 ctr_pcp_set_domain, // counter 10
208 ctr_pcp_reset, // counter 11
209 ctr_pcp_ntv_enum_events, // counter 12
210 ctr_pcp_ntv_name_to_code, // counter 13
211 ctr_pcp_ntv_code_to_name, // counter 14
212 ctr_pcp_ntv_code_to_descr, // counter 15
213 ctr_pcp_ntv_code_to_info}; // counter 16

Function Documentation

◆ _local_linkDynamicLibraries()

int _local_linkDynamicLibraries ( void  )

Definition at line 419 of file linux-pcp.c.

420 {
421  if ( _dl_non_dynamic_init != NULL ) { // If weak var present, statically linked insted of dynamic.
422  strncpy( _pcp_vector.cmp_info.disabled_reason, "The pcp component REQUIRES dynamic linking capabilities.", PAPI_MAX_STR_LEN-1);
423  return PAPI_ENOSUPP; // EXIT not supported.
424  }
425 
426  dllib1 = dlopen(MYPCPLIB, RTLD_NOW | RTLD_GLOBAL); // Open lib. MYPCPLIB is defined macro above.
427  mCheck_DL_Status( !dllib1 , "Component library '" MYPCPLIB "' not found." );
428 
429 //-----------------------------------------------------------------------------
430 // Collect pointers for routines in shared library. All below will abort this
431 // routine with PAPI_ENOSUPP, if the routine is not found in the dynamic
432 // library.
433 //-----------------------------------------------------------------------------
434 
435  mGet_DL_FPtr(pmLookupName);
436  mGet_DL_FPtr(pmErrStr);
437  mGet_DL_FPtr(pmTraversePMNS);
438  mGet_DL_FPtr(pmFreeResult);
439  mGet_DL_FPtr(pmNewContext);
440  mGet_DL_FPtr(pmDestroyContext);
441  mGet_DL_FPtr(pmFetch);
442  mGet_DL_FPtr(pmLookupDesc);
443  mGet_DL_FPtr(pmGetInDom);
444  mGet_DL_FPtr(pmLookupText);
445  mGet_DL_FPtr(pmUnitsStr_r);
446  return PAPI_OK; // If we get here, all above succeeded.
447 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:637
#define mGet_DL_FPtr(Name)
Definition: linux-pcp.c:414
#define PAPI_ENOSUPP
Definition: fpapi.h:123
static void * dllib1
Definition: linux-pcp.c:244
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define mCheck_DL_Status(err, str)
Definition: linux-pcp.c:400
void(* _dl_non_dynamic_init)(void)
Definition: linux-pcp.c:253
#define MYPCPLIB
Definition: linux-pcp.c:55
papi_vector_t _pcp_vector
Definition: linux-pcp.c:178
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the caller graph for this function:

◆ _pcp_ctl()

static int _pcp_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)
static

Definition at line 1547 of file linux-pcp.c.

1548 {
1549  mRtnCnt(_pcp_ctl); // count this function.
1550  ( void ) ctx; // avoid var unused warning.
1551  ( void ) code; // avoid var unused warning.
1552  ( void ) option; // avoid var unused warning.
1553 
1554  switch (code) {
1555  case PAPI_DEFDOM:
1556  SUBDBG("PAPI_DEFDOM, option.domain=0x%08X\n", (unsigned int) option->domain.domain);
1557  break;
1558 
1559  case PAPI_DOMAIN:
1560  SUBDBG("PAPI_DOMAIN, option.domain=0x%08X\n", (unsigned int) option->domain.domain);
1561  break;
1562 
1563  case PAPI_DEFGRN:
1564  SUBDBG("PAPI_DEFGRN, option.granularity=0x%08X\n", (unsigned int) option->granularity.granularity);
1565  break;
1566 
1567  case PAPI_GRANUL:
1568  SUBDBG("PAPI_GRANUL, option.granularity=0x%08X\n", (unsigned int) option->granularity.granularity);
1569  break;
1570 
1571  case PAPI_INHERIT:
1572  SUBDBG("PAPI_INHERIT, option.inherit=0x%08X\n", (unsigned int) option->inherit.inherit);
1573  break;
1574 
1575  default:
1576  fprintf(stderr, "%s:%i:%s CODE 0x%08x IS INVALID "
1577  "OR UNRECOGNIZED.\n", __FILE__, __LINE__, FUNC, code);
1578  return PAPI_EINVAL; // Invalid code.
1579  break;
1580  } // end switch by code.
1581 
1582  return PAPI_OK;
1583 } // end routine.
static int _pcp_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Definition: linux-pcp.c:1547
#define PAPI_OK
Definition: fpapi.h:105
_papi_int_inherit_t inherit
#define PAPI_GRANUL
Definition: fpapi.h:52
#define PAPI_EINVAL
Definition: fpapi.h:106
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
#define PAPI_INHERIT
Definition: papi.h:459
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
_papi_int_granularity_t granularity
#define PAPI_DEFGRN
Definition: fpapi.h:51
#define PAPI_DEFDOM
Definition: fpapi.h:49
#define FUNC
Definition: linux-pcp.c:36
#define PAPI_DOMAIN
Definition: fpapi.h:50
_papi_int_domain_t domain

◆ _pcp_init_component()

static int _pcp_init_component ( int  cidx)
static

Definition at line 819 of file linux-pcp.c.

820 {
821 
822  char *reason = _papi_hwd[cidx]->cmp_info.disabled_reason; // For error messages.
823  int rLen = PAPI_MAX_STR_LEN-1; // Most I will print.
824  reason[rLen]=0; // last resort terminator.
825 
826  mRtnCnt(_pcp_init_component); // count the routine.
827  #define hostnameLen 512 /* constant used multiple times. */
828  char hostname[hostnameLen]; // host name.
829  int ret;
830 
832  if ( ret != PAPI_OK ) { // Failure to get lib.
833  snprintf(reason, rLen, "Failed attempt to link to PCP "
834  "library '%s'.\n", MYPCPLIB);
835  return PAPI_ESYS;
836  }
837 
838  ret = gethostname(hostname, hostnameLen); // Try to get the host hame.
839  if( gethostname(hostname, hostnameLen) != 0) { // If we can't get the hostname,
840  snprintf(reason, rLen, "Failed system call, gethostname() "
841  "returned %i.", ret);
842  return PAPI_ESYS;
843  }
844  #undef hostnameLen /* done with it. */
845 
846  _prog_fprintf(stderr, "%s:%i retrieved hostname='%s'\n", __FILE__, __LINE__, hostname); // show progress.
847 
848  ctxHandle = pcp_pmNewContext(PM_CONTEXT_HOST, hostname); // Set the new context to hostname retrieved.
849  if (ctxHandle < 0) {
850  snprintf(reason, rLen, "Cannot connect to PM Daemon on host \"%s\".\n "
851  "(Ensure this machine has Performance Co-Pilot installed.)\n", hostname);
852  return(ctxHandle); // contains PAPI error code, not handle.
853  }
854 
855  _prog_fprintf(stderr, "%s:%i Found ctxHandle=%i\n", __FILE__, __LINE__, ctxHandle); // show progress.
856 
857  sEventInfoSize = sEventInfoBlock; // first allocation.
859  calloc(sEventInfoSize, sizeof(_pcp_event_info_t)); // Make room for all events.
860 
861  sEventCount = 0; // begin at zero.
862  _time_gettimeofday(&t1, NULL);
863  ret = pcp_pmTraversePMNS(AGENT_NAME, cbPopulateNameOnly); // Timed on Saturn [Intel Xeon 2.0GHz]; typical 9ms, range 8.5-10.5ms.
864  if (ret < 0) { // Failure...
865  snprintf(reason, rLen, "pmTraversePMNS failed; ret=%i [%s]\n",
866  ret, pcp_pmErrStr(ret));
867  if (ret == PM_ERR_NAME) { // We know what this one is,
868  snprintf(reason, rLen, "pmTraversePMNS ret=PM_ERR_NAME: "
869  "Occurs if event filter '%s' unknown to PCP Daemon.\n", AGENT_NAME);
870  }
871 
872  return PAPI_ENOIMPL; // Not implemented.
873  }
874 
875  _time_gettimeofday(&t2, NULL);
876  _time_fprintf(stderr, "pmTraversePMNS PopulateNameOnly took %li uS.\n",
878  _time_fprintf(stderr, "Final sEventCount=%i, sEventInfoSize=%i, "
879  "sEventInfoBlock=%i.\n",
881 
882  if (sEventCount < 1) { // Failure...
883  snprintf(reason, rLen, "pmTraversePMNS returned zero events "
884  "for AGENT=\"%s\".\n", AGENT_NAME);
885  return PAPI_ENOIMPL; // Can't work with no names!
886  }
887 
888  int i,j,k;
889  char **allNames=calloc(sEventCount, sizeof(char*)); // Make an array for all names.
890  for (i=0; i<sEventCount; i++) { // ..
891  allNames[i] = pcp_event_info[i].name; // copy pointer into array.
892  } // end for each event.
893 
894  pmID *allPMID=calloc(sEventCount, sizeof(pmID)); // Make an array for results.
895  if (allPMID == NULL) { // If we failed,
896  snprintf(reason, rLen, "memory alloc denied for allPMID; "
897  "size=%i.\n", sEventCount);
898  return(PAPI_ENOMEM); // memory failure.
899  } // end if calloc failed.
900 
901  //----------------------------------------------------------------
902  // Unlike Saturn, on the Power9 we get an 'IPC protocol failure'
903  // if we try to read more than 946 names at a time. This is some
904  // limitation on a communication packet size. On our test system
905  // Power9; the maximum number we can read is 946. To allow leeway
906  // for other possible values; we read in blocks of 256.
907  //----------------------------------------------------------------
908  #define LNBLOCK 256 /* Power9 gets IPC errors if read block is too large. */
909  k = (__LINE__)-1; // where LNBLOCK is defined.
910 
911  _time_gettimeofday(&t1, NULL);
912 
913  i=0; // Starting index for allPMID.
914  while (i<sEventCount) { // read in blocks of LNBLOCK.
915  j = sEventCount-i; // .. presume we can read the rest.
916  if (j > LNBLOCK) j=LNBLOCK; // .. reduce if we cannot.
917  ret = pcp_pmLookupName(j, allNames+i, allPMID+i); // .. Get a block of PMIDs for a block of names.
918  if (ret < 0) { // .. Failure...
919  snprintf(reason, rLen, "pmLookupName for %i names failed; ret=%i [%s].\n",
921  if (ret == PM_ERR_IPC) { // .. If we know it, rewrite.
922  snprintf(reason, rLen, "pmLookupName ret=PM_ERR_IPC: one known cause is a readblock too large; reduce LNBLOCK (%s:%i).\n",
923  __FILE__,k);
924  return PAPI_EBUF; // Give buffer exceeded.
925  }
926 
927  return PAPI_ESYS; // .. .. Can't work with no names!
928  }
929 
930  i+=j; // .. Adjust the pointer forward by what we read.
931  } // end while to read names in chunks, and avoid IPC error.
932  #undef LNBLOCK /* Discard constant; no further use. */
933 
934  _time_gettimeofday(&t2, NULL);
935  _time_fprintf(stderr, "pmLookupName for all took %li uS, ret=%i.\n",
937 
938  for (i=0; i<sEventCount; i++) pcp_event_info[i].pmid = allPMID[i]; // copy all the pmid over to array.
939 
940  pmResult *allFetch = NULL; // result of pmFetch.
941  _time_gettimeofday(&t1, NULL);
942  ret = pcp_pmFetch(sEventCount, allPMID, &allFetch); // Fetch (read) all the events.
943  _time_gettimeofday(&t2, NULL);
944  _time_fprintf(stderr, "pmFetch for all took %li uS, for %i events; ret=%i.\n",
946 
947  //-------------------------------------------------------------------
948  // In processing fetches, if we find a multi-valued event, we need
949  // to force an event for every value (PAPI only returns 1 value per
950  // event; not an array). In experiments thus far, all multi-valued
951  // events have had domain descriptor names; so we just concat with
952  // the name and make a new Event. We use a helper for that,
953  // afterward we set the number of values in the original 'base name'
954  // to zero; so it will be deleted by the cleanup routine.
955  //-------------------------------------------------------------------
956 
957  _time_gettimeofday(&t1, NULL); // time this index explosion.
958  int origEventCount = sEventCount; // sEventCount may change in below routine.
959 
960  for (i=0; i<origEventCount; i++) { // process all the fetch results.
961  pcp_event_info[i].desc.pmid = PM_ID_NULL; // This indicates the description is NOT loaded yet.
962  pmValueSet *vset = allFetch->vset[i]; // get the result for event[i].
963 
964  // On Saturn test system, never saw this happen.
965  if (vset == NULL) { // .. should not happen. leave numVal=0 for deletion.
966  fprintf(stderr, "%s:%i vset=NULL for name='%s'\n",
967  __FILE__, __LINE__, pcp_event_info[i].name);
968  continue; // .. next in loop.
969  }
970 
971  pcp_event_info[i].numVal = vset->numval; // Show we have a value.
972  if (vset->numval == 0) { // If the value is zero,
973 // _prog_fprintf(stderr, "%s:%i Discarding, no values for event '%s'.\n", __FILE__, __LINE__, pcp_event_info[i].name);
974  continue; // If no values, leave numVal = 0 for deletion. (We do see this in tests).
975  }
976 
977  pcp_event_info[i].valfmt = vset->valfmt; // Get the value format. (INSITU or not).
978  getPMDesc(i); // Get the value descriptor.
979  unsigned long long ullval= (long long) -1; // debug stuff.
980  convert_64_t convert;
981 
982  if (vset->valfmt != PM_VAL_INSITU) { // If not in situ, must get the type.
983  pmValue *pmval = &vset->vlist[0]; // .. Get the first value.
984  pmValueBlock *pB = pmval->value.pval; // .. get it.
985  if (pcp_event_info[i].valType != pB->vtype) {
986  snprintf(reason, rLen, "Disagreement between var descriptor and fetch on event %s. %i vs %i. Possible version incompatibiity.\n",
987  pcp_event_info[i].name, pcp_event_info[i].valType, pB->vtype);
988  return PAPI_ENOSUPP; // .. in
989  }
990 
991 // pcp_event_info[i].valType = pB->vtype; // .. get the type.
992  ullval = getULLValue(vset, 0); // .. get the first value.
993 
994  switch(pB->vtype) { // PCP's variable type; an int flag.
995  case PM_TYPE_32: // 32-bit signed integer
996  _prog_fprintf(stderr, "type I32, desc.sem=%i, event '%s'=", pcp_event_info[i].desc.sem, pcp_event_info[i].name);
997  break;
998  case PM_TYPE_U32: // 32-bit unsigned integer
999  _prog_fprintf(stderr, "type U32, desc.sem=%i, event '%s'=", pcp_event_info[i].desc.sem, pcp_event_info[i].name);
1000  break;
1001  case PM_TYPE_FLOAT: // 32-bit floating point
1002  _prog_fprintf(stderr, "type F32, desc.sem=%i, event '%s'=", pcp_event_info[i].desc.sem, pcp_event_info[i].name);
1003  break; // END CASE.
1004 
1005  case PM_TYPE_64: // 64-bit signed integer
1006  convert.ull = ullval;
1007  _prog_fprintf(stderr, "type I64, desc.sem=%i, event '%s'= (ll) %lli =", pcp_event_info[i].desc.sem, pcp_event_info[i].name, convert.ll);
1008  break;
1009  case PM_TYPE_U64: // 64-bit unsigned integer
1010  _prog_fprintf(stderr, "type U64, desc.sem=%i, event '%s'= (ull) %llu =", pcp_event_info[i].desc.sem, pcp_event_info[i].name, convert.ull);
1011  break;
1012  case PM_TYPE_DOUBLE: // 64-bit floating point
1013  convert.ull = ullval;
1014  _prog_fprintf(stderr, "type U64, desc.sem=%i, event '%s'= (double) %f =", pcp_event_info[i].desc.sem, pcp_event_info[i].name, convert.d);
1015  break; // END CASE.
1016 
1017  // IF YOU want to return string values, this is a place
1018  // to change; currently all string-valued events are
1019  // rejected. But, pB->vbuf is the string value. I would
1020  // copy it into a new pcp_event_info[] field; it would
1021  // need to be malloc'd here and free'd at component
1022  // shutdown. Also PAPI would need a new way to accept a
1023  // char* or void*.
1024 
1025  case PM_TYPE_STRING: // pB->vbuf is char* to string value.
1026  _prog_fprintf(stderr, "%s:%i Discarding PM_TYPE_STRING event, desc.sem=%i, event '%s'=", __FILE__, __LINE__, pcp_event_info[i].desc.sem, pcp_event_info[i].name);
1027  pcp_event_info[i].numVal = 0; // .. .. set numVal = 0 for deletion.
1028  break;
1029 
1030  default: // If we don't recognize the type,
1031  _prog_fprintf(stderr, "%s:%i Dsicarding PM_UNKNOWN_TYPE event, desc.sem=%i, event '%s'=", __FILE__, __LINE__, pcp_event_info[i].desc.sem, pcp_event_info[i].name);
1032  pcp_event_info[i].numVal = 0; // .. set numVal = 0 for deletion.
1033  break;
1034  } // end switch.
1035  } // If not In Situ.
1036  else {
1037  _prog_fprintf(stderr, "type IST, desc.sem=%i, event '%s'=", pcp_event_info[i].desc.sem, pcp_event_info[i].name);
1038  }
1039 
1040  convert.ull = ullval;
1041  _prog_fprintf(stderr, "%02X%02X%02X%02X %02X%02X%02X%02X\n", convert.ch[0], convert.ch[1], convert.ch[2], convert.ch[3], convert.ch[4], convert.ch[5], convert.ch[6], convert.ch[7]);
1042  // Lookup description takes time; so we only do it for
1043  // multi-valued events here. For other events, we will do it
1044  // as needed for EventInfo filling.
1045 
1046  if (pcp_event_info[i].numVal > 1) { // If a domain qualifier is possible;
1047  getPMDesc(i); // .. Get the event descriptor.
1048  _prog_fprintf(stderr, "Event %s has %i values, indom=%i.\n", pcp_event_info[i].name, pcp_event_info[i].numVal, pcp_event_info[i].desc.indom);
1049  if (pcp_event_info[i].desc.indom != PM_INDOM_NULL) { // .. If we have a non-null domain,
1050  for (j=0; j<vset->numval; j++) { // .. for every value present,
1051  pmValue *pmval = &vset->vlist[j]; // .. .. get that guy.
1052 
1053  char *dname = cachedGetInDom( // .. .. read from cached domains (and populate it when needed).
1054  pcp_event_info[i].desc.indom,
1055  pmval->inst); // .. .. get the name. Not malloced so don't free dName.
1056 
1057  makeQualifiedEvent(i, j, dname); // .. .. helper routine; may realloc pcp_event_info[], change sEventCount.
1058  } // end value list.
1059 
1060  pcp_event_info[i].numVal = 0; // .. let the base event be discarded.
1061  } // end if we have a domain.
1062  } // end if multiple valued.
1063  } // end for each event.
1064 
1065  // Trim the fat! We get rid of everything with numVal == 0.
1066  // We do that by compaction; moving valid entries to backfill
1067  // invalid ones.
1068 
1069  j=0; // first destination.
1070  for (i=0; i<sEventCount; i++) { // loop thorugh all old and new.
1071  if (pcp_event_info[i].numVal > 0) { // If we have a valid entry,
1072  if (i != j) pcp_event_info[j] = pcp_event_info[i]; // move if it isn't already there.
1073  j++; // count one moved; new count of valid ones.
1074  }
1075  }
1076 
1077  sEventCount = j; // this is our new count.
1078  pcp_event_info = realloc(pcp_event_info, // release any extra memory.
1079  sEventCount*sizeof(_pcp_event_info_t)); // ..
1080  if (pcp_event_info == NULL) { // If we failed,
1081  snprintf(reason, rLen, "memory realloc denied for "
1082  "pcp_event_info; size=%i.\n", sEventCount);
1083  return PAPI_ENOMEM; // no memory.
1084  } // end if realloc failed.
1085 
1086  qsort(pcp_event_info, sEventCount, // sort by PMID, idx, name.
1087  sizeof(_pcp_event_info_t), qsPMID); // ..
1088 
1089  _time_gettimeofday(&t2, NULL); // done with index explosion.
1090  _time_fprintf(stderr, "indexedExplosion for all took %li uS.\n",
1092 
1093  for (i=0; i<HASH_SIZE; i++) { // init hash table.
1094  sNameHash[i].idx = -1; // unused entry.
1095  sNameHash[i].next = NULL; // ..
1096  }
1097 
1098  unsigned int myHash;
1099  for (i=0; i<sEventCount; i++) {
1100  myHash = addNameHash(pcp_event_info[i].name, i); // Point this hash to this entry.
1101  }
1102 
1103  //-----------------------------------------------------------------------------------------------------------------------
1104  // *************************************** DEBUG REPORT OF INFORMATION DISCOVERED ***************************************
1105  //-----------------------------------------------------------------------------------------------------------------------
1106  // We use -O2, but even in -O0, if(0){...} is completely removed from code. It costs us nothing to leave this code in.
1107  if (0) { // change to 1 to enable debug report.
1108  unsigned int current, prev=0;
1109  printf("count, hash, name, pmid, value[idx]\n");
1110  for (i=0; i<sEventCount; i++) {
1111  myHash = stringHash(pcp_event_info[i].name, HASH_SIZE); // Get the hash value.
1112  current = pcp_event_info[i].pmid;
1113  if (prev > 0 && current != (prev+1) && current != prev) // print separators.
1114  printf("----,----,----,----\n");
1115  printf("%i, %u, \"%s\", 0x%08X, %i\n", i, myHash, // quote name, may contain \,/,comma, etc.
1116  pcp_event_info[i].name,
1117  pcp_event_info[i].pmid,
1118  pcp_event_info[i].idx);
1119  prev=current; // for finding pmid skips.
1120  }
1121 
1122  // Test hashing.
1123  int hashErr = 0;
1124  _time_gettimeofday(&t1, NULL);
1125  for (i=0; i<sEventCount; i++) {
1126  int f = findNameHash(pcp_event_info[i].name); // Try to find this name.
1127  if (f != i) hashErr++;
1128  }
1129 
1130  _time_gettimeofday(&t2, NULL);
1131 
1132  _time_fprintf(stderr, "HashLookup avg uS: %3.6f\n", ((double) (mConvertUsec(t2)-mConvertUsec(t1)) )/((double) sEventCount) );
1133  _time_fprintf(stderr, "Hash Errors: %i of %i.\n", hashErr, sEventCount);
1134 
1135  } // END DEBUG REPORT.
1136  //-----------------------------------------------------------------------------------------------------------------------
1137  // *************************************** END DEBUG REPORT INFORMATION DISCOVERED **************************************
1138  //-----------------------------------------------------------------------------------------------------------------------
1139 
1140  free(allNames); // Locals allocations not needed anymore.
1141  free(allPMID); // .. the pmIDs we read.
1142  pcp_pmFreeResult(allFetch); // .. release the results we fetched.
1143 
1144 // For PCP, we can read any number of events at once
1145 // in a single event set. Set vector elements for PAPI.
1146 
1147  _pcp_vector.cmp_info.num_native_events = sEventCount; // Setup our pcp vector.
1150  _pcp_vector.cmp_info.CmpIdx = cidx; // export the component ID.
1151 
1152  return PAPI_OK;
1153 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
void getPMDesc(int pcpIdx)
Definition: linux-pcp.c:539
static int sEventInfoSize
Definition: linux-pcp.c:184
double f(double a)
Definition: cpi.c:23
#define PAPI_ENOMEM
Definition: fpapi.h:107
static const char * name
Definition: fork_overflow.c:31
#define PAPI_EBUF
Definition: fpapi.h:125
int ctxHandle
Definition: linux-pcp.c:188
unsigned int addNameHash(char *key, int idx)
Definition: linux-pcp.c:329
#define PAPI_ENOSUPP
Definition: fpapi.h:123
static char * cachedGetInDom(pmInDom indom, int inst)
Definition: linux-pcp.c:575
#define hostnameLen
static _pcp_hash_t sNameHash[HASH_SIZE]
Definition: linux-pcp.c:192
unsigned int stringHash(char *str, unsigned int tableSize)
Definition: linux-pcp.c:313
void * next
Definition: linux-pcp.c:161
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static struct timeval t1 t2
Definition: linux-pcp.c:235
static int pcp_pmNewContext(int type, const char *name)
Definition: linux-pcp.c:283
static int sEventInfoBlock
Definition: linux-pcp.c:185
volatile double t1
#define AGENT_NAME
Definition: linux-pcp.c:42
#define PAPI_ENOIMPL
Definition: fpapi.h:124
static int pcp_pmFetch(int numpid, pmID *pmidlist, pmResult **result)
Definition: linux-pcp.c:289
void cbPopulateNameOnly(const char *name)
Definition: linux-pcp.c:474
#define PAPI_ESYS
Definition: fpapi.h:108
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
#define _time_fprintf
Definition: linux-pcp.c:240
static int sEventCount
Definition: linux-pcp.c:187
static int cidx
static char * pcp_pmErrStr(int code)
Definition: linux-pcp.c:274
unsigned char ch[8]
Definition: benchSANVML.c:141
int findNameHash(char *key)
Definition: linux-pcp.c:370
static int pcp_pmTraversePMNS(const char *name, void(*func)(const char *))
Definition: linux-pcp.c:277
#define MYPCPLIB
Definition: linux-pcp.c:55
long long ret
Definition: iozone.c:1346
unsigned long long ull
Definition: benchSANVML.c:138
#define LNBLOCK
static int _pcp_init_component(int cidx)
Definition: linux-pcp.c:819
#define _time_gettimeofday
Definition: linux-pcp.c:241
#define mConvertUsec(timeval_)
Definition: linux-pcp.c:236
long long ll
Definition: benchSANVML.c:137
#define _prog_fprintf
Definition: linux-pcp.c:239
void pcp_pmFreeResult(pmResult *result)
Definition: linux-pcp.c:280
struct papi_vectors * _papi_hwd[]
#define PM_CONTEXT_HOST
Definition: linux-pcp.c:59
#define HASH_SIZE
Definition: linux-pcp.c:191
int qsPMID(const void *arg1, const void *arg2)
Definition: linux-pcp.c:453
char name[PAPI_MAX_STR_LEN]
Definition: linux-pcp.c:104
papi_vector_t _pcp_vector
Definition: linux-pcp.c:178
void makeQualifiedEvent(int baseEvent, int idx, char *qualifier)
Definition: linux-pcp.c:495
unsigned long long getULLValue(pmValueSet *vset, int value_index)
Definition: linux-pcp.c:652
int i
Definition: fileop.c:140
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int _local_linkDynamicLibraries(void)
Definition: linux-pcp.c:419
Here is the call graph for this function:

◆ _pcp_init_control_state()

static int _pcp_init_control_state ( hwd_control_state_t ctl)
static

Definition at line 1178 of file linux-pcp.c.

1179 {
1180  mRtnCnt(_pcp_init_control_state); // count this function.
1181  _pcp_control_state_t* control = ( _pcp_control_state_t* ) ctl;
1182  // contents: _pcp_control_state state at this writing:
1183  // contents of state:
1184  // int numEvents; // The number of events we have.
1185  // int maxAllocated; // the current entries in pcpIndex.
1186  // int *pcpIndex; // array of indices into pcp_event_info[].
1187  // long long *values; // Values read from our PCP events.
1188 
1189  memset(control, 0, sizeof(_pcp_control_state_t)); // zero it.
1190 
1191  return PAPI_OK;
1192 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_init_control_state(hwd_control_state_t *ctl)
Definition: linux-pcp.c:1178

◆ _pcp_init_thread()

static int _pcp_init_thread ( hwd_context_t ctx)
static

Definition at line 1166 of file linux-pcp.c.

1167 {
1168  mRtnCnt(_pcp_init_thread); // count this function.
1169  _pcp_context_t* myCtx = (_pcp_context_t*) ctx; // recast.
1170  myCtx->initDone = 1; // Nothing else to do for init.
1171  return PAPI_OK;
1172 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
static int _pcp_init_thread(hwd_context_t *ctx)
Definition: linux-pcp.c:1166
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217

◆ _pcp_ntv_code_to_descr()

static int _pcp_ntv_code_to_descr ( unsigned int  pcpIdx,
char *  descr,
int  len 
)
static

Definition at line 1710 of file linux-pcp.c.

1711 {
1712  mRtnCnt(_pcp_ntv_code_to_descr); // count this function.
1713 
1714  pcpIdx &= PAPI_NATIVE_AND_MASK; // We might be called with the NATIVE bit set.
1715  if (pcpIdx >= (unsigned int) sEventCount) { // out of range?
1716  fprintf(stderr, "%s:%i:%s called with out-of-range pcpIdx=%u.\n",
1717  __FILE__, __LINE__, FUNC, pcpIdx);
1718  return PAPI_EINVAL; // exit with error.
1719  }
1720 
1721  if (len < 1) { // If length is ridiculous,
1722  fprintf(stderr, "%s:%i:%s called with out-of-range descr len=%i.\n",
1723  __FILE__, __LINE__, FUNC, len);
1724  return PAPI_EINVAL; // exit with error.
1725  }
1726 
1727  char *helpText = NULL; // pointer to receive the result.
1728  int ret = getHelpText(pcpIdx, &helpText); // get it.
1729  if (ret != PAPI_OK) { // If there is any error,
1730  if (helpText != NULL) free(helpText); // .. no memory leak.
1731  fprintf(stderr, "%s:%i:%s failed getHelpText; it returned %s.\n",
1732  __FILE__, __LINE__, FUNC, PAPI_strerror(ret));
1733  return ret; // exit with whatever PAPI error routine had.
1734  }
1735 
1736  strncpy(descr, helpText, len); // copy it over.
1737  descr[len-1] = 0; // force a z-terminator.
1738  free(helpText); // release text alloc by pm routine.
1739  return PAPI_OK; // EXIT, all good.
1740 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int sEventCount
Definition: linux-pcp.c:187
long long ret
Definition: iozone.c:1346
static int _pcp_ntv_code_to_descr(unsigned int pcpIdx, char *descr, int len)
Definition: linux-pcp.c:1710
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define FUNC
Definition: linux-pcp.c:36
#define PAPI_NATIVE_AND_MASK
int getHelpText(unsigned int pcpIdx, char **helpText)
Definition: linux-pcp.c:778
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _pcp_ntv_code_to_info()

static int _pcp_ntv_code_to_info ( unsigned int  pcpIdx,
PAPI_event_info_t info 
)
static

Definition at line 1763 of file linux-pcp.c.

1764 {
1765  mRtnCnt(_pcp_ntv_code_to_info); // count this function.
1766  int len, ret;
1767 
1768  pcpIdx &= PAPI_NATIVE_AND_MASK; // remove any high order bits.
1769  if (pcpIdx >= (unsigned int) sEventCount) { // out of range?
1770  fprintf(stderr, "%s:%i:%s called with out-of-range pcpIdx=%u.\n",
1771  __FILE__, __LINE__, FUNC, pcpIdx);
1772  return PAPI_EINVAL; // exit with error.
1773  }
1774 
1775  len=sizeof(info->symbol); // get length.
1776  strncpy(info->symbol, pcp_event_info[pcpIdx].name, len); // Copy.
1777  info->symbol[len-1] = 0; // force z-terminator.
1778 
1779  len=sizeof(info->long_descr); // get length.
1780  ret = _pcp_ntv_code_to_descr(pcpIdx, info->long_descr, len); // copy to info.
1781  if (ret != PAPI_OK) return(ret); // return on failure. _pcp_ntv_code_to_descr already printed error.
1782 
1783  // Units resides in pmDesc; we need to get it if we don't already
1784  // have it (multi-valued events got it during init).
1785 
1786  getPMDesc(pcpIdx); // get the description.
1787 
1788  char unitStr[64];
1789  // This routine has been timed over 19600 trials on Saturn;
1790  // it requires an average of 2 uS. No daemon comm needed.
1791 
1792  pcp_pmUnitsStr_r(&pcp_event_info[pcpIdx].desc.units, unitStr, 64); // Construct the unit string; needs at least 60 char.
1793  if ( strlen(unitStr) == 0) {
1794  sprintf(unitStr, "fraction"); // Only ever seen for 'dutycycle' events.
1795 
1796  // Following is for debug purposes.
1797  if (0) { // Alternatively, show the details of the PCP units descriptor.
1798  sprintf(unitStr, "[%u, %i, %u, %u, %i, %i, %i]",
1799  pcp_event_info[pcpIdx].desc.units.pad,
1800  pcp_event_info[pcpIdx].desc.units.scaleCount,
1801  pcp_event_info[pcpIdx].desc.units.scaleTime,
1802  pcp_event_info[pcpIdx].desc.units.scaleSpace,
1803  pcp_event_info[pcpIdx].desc.units.dimCount,
1804  pcp_event_info[pcpIdx].desc.units.dimTime,
1805  pcp_event_info[pcpIdx].desc.units.dimSpace
1806  );
1807  }
1808  }
1809 
1810  len = sizeof(info->units); // length of destination.
1811  strncpy( info->units, unitStr, len); // copy it over.
1812  info->units[len-1] = 0; // ensure a z-terminator.
1813 
1814  switch (pcp_event_info[pcpIdx].valType) { // Translate this to a papi value.
1815 
1816  case PM_TYPE_32: // 32 bit was converted to long long.
1817  case PM_TYPE_64: // long long.
1818  info->data_type = PAPI_DATATYPE_INT64; // What papi needs.
1819  break; // END CASE.
1820 
1821  case PM_TYPE_U32: // 32-bit was converted to 64 bit.
1822  case PM_TYPE_U64: // 64-bit unsigned integer
1823  case PM_TYPE_STRING: // array of char pointer.
1824  info->data_type = PAPI_DATATYPE_UINT64; // What papi needs.
1825  break; // END CASE.
1826 
1827  case PM_TYPE_FLOAT: // 32-bit was converted to double.
1828  case PM_TYPE_DOUBLE: // 64-bit floating point
1829  info->data_type = PAPI_DATATYPE_FP64; // What papi needs.
1830  break; // END CASE.
1831  };
1832 
1833  if (pcp_event_info[pcpIdx].desc.sem == PM_SEM_COUNTER) { // If we have a counter,
1834  info->timescope = PAPI_TIMESCOPE_SINCE_START; // .. normal stuff.
1835  } else { // An instantaneous value.
1836  info->timescope = PAPI_TIMESCOPE_POINT; // .. What PAPI calls that.
1837  }
1838 
1839  return PAPI_OK; // exit.
1840 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
void getPMDesc(int pcpIdx)
Definition: linux-pcp.c:539
#define PAPI_EINVAL
Definition: fpapi.h:106
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:976
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:970
static int _pcp_ntv_code_to_info(unsigned int pcpIdx, PAPI_event_info_t *info)
Definition: linux-pcp.c:1763
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static int sEventCount
Definition: linux-pcp.c:187
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:967
static char * pcp_pmUnitsStr_r(const pmUnits *pu, char *buf, int buflen)
Definition: linux-pcp.c:301
long long ret
Definition: iozone.c:1346
static int _pcp_ntv_code_to_descr(unsigned int pcpIdx, char *descr, int len)
Definition: linux-pcp.c:1710
#define FUNC
Definition: linux-pcp.c:36
#define PAPI_NATIVE_AND_MASK
char name[PAPI_MAX_STR_LEN]
Definition: linux-pcp.c:104
Here is the call graph for this function:

◆ _pcp_ntv_code_to_name()

static int _pcp_ntv_code_to_name ( unsigned int  pcpIdx,
char *  name,
int  len 
)
static

Definition at line 1681 of file linux-pcp.c.

1682 {
1683  mRtnCnt(_pcp_ntv_code_to_name); // count this function.
1684 
1685  pcpIdx &= PAPI_NATIVE_AND_MASK; // We can be called with the NATIVE bit set.
1686  if (pcpIdx >= (unsigned int) sEventCount) { // out of range?
1687  fprintf(stderr, "%s:%i:%s called with out-of-range pcpIdx=%u.\n",
1688  __FILE__, __LINE__, FUNC, pcpIdx);
1689  return PAPI_EINVAL; // exit with error.
1690  }
1691 
1692  if (len < 1) { // If length is ridiculous,
1693  fprintf(stderr, "%s:%i:%s called with out-of-range descr len=%i.\n",
1694  __FILE__, __LINE__, FUNC, len);
1695  return PAPI_EINVAL; // exit with error.
1696  }
1697 
1698  strncpy(name, pcp_event_info[pcpIdx].name, len); // just copy the name.
1699  name[len-1]=0; // force z-termination.
1700 
1701  return PAPI_OK;
1702 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define PAPI_EINVAL
Definition: fpapi.h:106
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_ntv_code_to_name(unsigned int pcpIdx, char *name, int len)
Definition: linux-pcp.c:1681
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static int sEventCount
Definition: linux-pcp.c:187
#define FUNC
Definition: linux-pcp.c:36
#define PAPI_NATIVE_AND_MASK

◆ _pcp_ntv_enum_events()

static int _pcp_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)
static

Definition at line 1614 of file linux-pcp.c.

1615 {
1616  mRtnCnt(_pcp_ntv_enum_events); // count this function.
1617  int idx;
1618 
1619  switch (modifier) { // modifier is type of enum operation desired.
1620  case PAPI_ENUM_FIRST: // Returns event code of first event created.
1621  EventCode[0] = 0; // Return 0 as event code after a start.
1622  return PAPI_OK; // EXIT.
1623  break; // END CASE.
1624 
1625  // return EventCode of next available event.
1626  case PAPI_ENUM_EVENTS: // enum base events (which is all events).
1627  idx = EventCode[0] & PAPI_NATIVE_AND_MASK; // Take off any hi order flag bits.
1628  if ((++idx) >= sEventCount) return PAPI_ENOEVNT; // If we reach an invalid idx for pcp_event_info[], exit. Does nothing to EventCode.
1629  EventCode[0] = idx | PAPI_NATIVE_MASK; // If index was valid, we return it.
1630  return PAPI_OK; // And exit.
1631  break; // END CASE.
1632 
1633  case PAPI_NTV_ENUM_UMASKS: // Note we HAVE no qualifiers or masks.
1634  return PAPI_ENOEVNT; // There are no qualifiers to list.
1635 
1636  default: // If we don't understand the modifier,
1637  return PAPI_ENOEVNT; // .. Presets or other stuff, just say we have none.
1638  break; // END CASE.
1639  } // end switch(modifier).
1640 
1641  return PAPI_EBUG; // Dummy return; should have exited from inside switch.
1642 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_NATIVE_MASK
#define PAPI_EBUG
Definition: fpapi.h:111
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int sEventCount
Definition: linux-pcp.c:187
static int _pcp_ntv_enum_events(unsigned int *EventCode, int modifier)
Definition: linux-pcp.c:1614
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_NATIVE_AND_MASK

◆ _pcp_ntv_name_to_code()

static int _pcp_ntv_name_to_code ( const char *  name,
unsigned int *  event_code 
)
static

Definition at line 1648 of file linux-pcp.c.

1649 {
1650  mRtnCnt(_pcp_ntv_name_to_code); // count this function.
1651 
1652  if (name == NULL || strlen(name)<1) { // Invalid name argument.
1653  fprintf(stderr, "%s:%i:%s Invalid name.\n", // .. report it.
1654  __FILE__, __LINE__, FUNC);
1655  return PAPI_EINVAL; // .. Invalid argument.
1656  }
1657 
1658  if (event_code == NULL) { // Invalid event_code pointer.
1659  fprintf(stderr, "%s:%i:%s event_code is not a valid pointer.\n", // .. report it.
1660  __FILE__, __LINE__, FUNC);
1661  return PAPI_EINVAL; // .. Invalid argument.
1662  }
1663 
1664  int idx = findNameHash((char*) name); // Use our hash to find it.
1665  if (idx < 0) { // If we failed,
1666  fprintf(stderr, "%s:%i:%s Failed to find name='%s', hash=%i.\n", // .. report it.
1667  __FILE__, __LINE__, FUNC, name,
1668  stringHash((char*) name, HASH_SIZE)); // ..
1669  return PAPI_EINVAL; // .. Invalid argument.
1670  }
1671 
1672  *event_code = idx; // return with the index we found.
1673  return PAPI_OK;
1674 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define PAPI_EINVAL
Definition: fpapi.h:106
unsigned int stringHash(char *str, unsigned int tableSize)
Definition: linux-pcp.c:313
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
int findNameHash(char *key)
Definition: linux-pcp.c:370
static int _pcp_ntv_name_to_code(const char *name, unsigned int *event_code)
Definition: linux-pcp.c:1648
#define FUNC
Definition: linux-pcp.c:36
#define HASH_SIZE
Definition: linux-pcp.c:191
Here is the call graph for this function:

◆ _pcp_read()

static int _pcp_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)
static

Definition at line 1445 of file linux-pcp.c.

1449 {
1450  mRtnCnt(_pcp_read); // count this function.
1451  (void) ctx; // avoid unused var warning.
1452  (void) flags; // ..
1453 
1454  _pcp_control_state_t* myCtl = ( _pcp_control_state_t* ) ctl; // make a shortcut.
1455  int i, ret;
1456  pmResult *allFetch; // vars to be allocated by call.
1457  if (events == NULL) {
1458  fprintf(stderr, "%s:%i:%s 'events' is null.\n",
1459  __FILE__, __LINE__, FUNC); // report error.
1460  return(PAPI_EINVAL); // invalid argument.
1461  }
1462 
1463  ret = PCP_ReadList(ctl, &allFetch); // Read the list of events we were given.
1464  if (ret != PAPI_OK) { // If that failed,
1465  fprintf(stderr, "%s:%i:%s PCP_ReadList failed, return=%s.\n",
1466  __FILE__, __LINE__, FUNC, PAPI_strerror(ret)); // report error.
1467  return(ret); // exit with that error.
1468  }
1469 
1470  // We have all the results and values extracted from them.
1471  // Now subtract zero value from them.
1472 
1473  for (i=0; i<myCtl->numEvents; i++) { // for each event,
1474  subZero(myCtl, i); // .. subtract zero value in proper type. [TONY DON"T COMMENT OUT, JUST DEBUG]
1475  } // end loop through all events in this event set.
1476 
1477  // Done, point the caller to our results list.
1478  *events = (long long *) myCtl->pcpValue; // pointer the caller needs.
1479  pcp_pmFreeResult(allFetch); // Clean up.
1480  return PAPI_OK; // exit, all okay.
1481 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
void subZero(_pcp_control_state_t *myCtl, int event)
Definition: linux-pcp.c:726
#define PAPI_EINVAL
Definition: fpapi.h:106
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
char events[MAX_EVENTS][BUFSIZ]
long long ret
Definition: iozone.c:1346
static int _pcp_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
Definition: linux-pcp.c:1445
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define FUNC
Definition: linux-pcp.c:36
void pcp_pmFreeResult(pmResult *result)
Definition: linux-pcp.c:280
unsigned long long * pcpValue
Definition: linux-pcp.c:140
int PCP_ReadList(hwd_control_state_t *ctl, pmResult **results)
Definition: linux-pcp.c:1308
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _pcp_reset()

static int _pcp_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 1385 of file linux-pcp.c.

1386 {
1387  mRtnCnt(_pcp_reset); // count this function.
1388  ( void ) ctx; // avoid unused var warning.
1389  int i, k, ret;
1390  unsigned long long aValue;
1391 
1392  pmResult *allFetch; // vars to be allocated by call.
1393  _pcp_control_state_t* myCtl = ( _pcp_control_state_t* ) ctl; // make a shortcut.
1394 
1395  ret = PCP_ReadList(ctl, &allFetch); // Read the list of events we were given.
1396  if (ret != PAPI_OK) { // If that failed,
1397  fprintf(stderr, "%s:%i:%s PCP_ReadList failed, return=%s.\n",
1398  __FILE__, __LINE__, FUNC, PAPI_strerror(ret)); // report error.
1399  if (allFetch != NULL) pcp_pmFreeResult(allFetch); // free if it was allocated.
1400  return(ret); // exit with that error.
1401  }
1402 
1403  // We have all the results; the values read have been extracted
1404  // and stored the control state. Now set them as the zeroValue
1405  // in each pcp_event_info[].
1406 
1407  for (i=0; i<myCtl->numEvents; i++) { // for each event,
1408  k = myCtl->pcpIndex[i]; // .. get pcp_event_info[] index.
1409  aValue = myCtl->pcpValue[i]; // .. get the value for that event.
1410  pcp_event_info[k].zeroValue = aValue; // .. reset the counter.
1411  } // end loop through all events in this event set.
1412 
1413  // That is all we do; reset the zeroValue to the current value.
1414  // For efficiency we do not check if it is a counter, instantaneous
1415  // or discrete value; that is done in subZero.
1416  pcp_pmFreeResult(allFetch); // .. Clean up.
1417  return PAPI_OK;
1418 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
unsigned long long zeroValue
Definition: linux-pcp.c:112
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
long long ret
Definition: iozone.c:1346
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define FUNC
Definition: linux-pcp.c:36
void pcp_pmFreeResult(pmResult *result)
Definition: linux-pcp.c:280
static int _pcp_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-pcp.c:1385
unsigned long long * pcpValue
Definition: linux-pcp.c:140
int PCP_ReadList(hwd_control_state_t *ctl, pmResult **results)
Definition: linux-pcp.c:1308
int i
Definition: fileop.c:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _pcp_set_domain()

static int _pcp_set_domain ( hwd_control_state_t ctl,
int  domain 
)
static

Definition at line 1594 of file linux-pcp.c.

1595 {
1596  mRtnCnt(_pcp_set_domain); // count this function.
1597  (void) ctl; // avoid var unused warning.
1598  if ( PAPI_DOM_ALL != domain ) return PAPI_EINVAL; // Reject if not this one.
1599  return PAPI_OK; // Otherwise, OK, nothing to do.
1600 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_set_domain(hwd_control_state_t *ctl, int domain)
Definition: linux-pcp.c:1594
#define PAPI_DOM_ALL
Definition: fpapi.h:25

◆ _pcp_shutdown_component()

static int _pcp_shutdown_component ( void  )
static

Definition at line 1511 of file linux-pcp.c.

1512 {
1513  int i;
1514  mRtnCnt(_pcp_shutdown_component); // count this function.
1515  pcp_pmDestroyContext(ctxHandle); // context handle; fails to free malloced memory, says valgrind.
1516  ctxHandle = -1; // reset to prevent reuse.
1517  free(pcp_event_info); pcp_event_info=NULL; // then pcp_event_info, reset.
1518  freeNameHash(); // free sNameHash. resets itself.
1519  cachedGetInDom(PM_INDOM_NULL, -1); // -1 for inst == free its local static mallocs.
1520  sEventCount = 0; // clear number of events.
1521 
1522  for (i=0; i<=ctr_pcp_ntv_code_to_info; i++)
1523  _prog_fprintf(stderr, "routine counter %i = %i.\n", i, cnt[i]);
1524 
1525  return PAPI_OK;
1526 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
int ctxHandle
Definition: linux-pcp.c:188
static char * cachedGetInDom(pmInDom indom, int inst)
Definition: linux-pcp.c:575
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_shutdown_component(void)
Definition: linux-pcp.c:1511
static int pcp_pmDestroyContext(int handle)
Definition: linux-pcp.c:286
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static int sEventCount
Definition: linux-pcp.c:187
int cnt[ctr_pcp_ntv_code_to_info+1]
Definition: linux-pcp.c:215
void freeNameHash(void)
Definition: linux-pcp.c:351
#define _prog_fprintf
Definition: linux-pcp.c:239
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _pcp_shutdown_thread()

static int _pcp_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 1499 of file linux-pcp.c.

1500 {
1501  mRtnCnt(_pcp_shutdown_thread); // count this function.
1502  ( void ) ctx; // avoid var unused warning.
1503 
1504  return PAPI_OK;
1505 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_shutdown_thread(hwd_context_t *ctx)
Definition: linux-pcp.c:1499

◆ _pcp_start()

static int _pcp_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 1426 of file linux-pcp.c.

1427 {
1428  mRtnCnt(_pcp_start); // count this function.
1429  _pcp_reset(ctx, ctl); // Just reset counters.
1430  return PAPI_OK;
1431 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-pcp.c:1426
static int _pcp_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-pcp.c:1385
Here is the call graph for this function:

◆ _pcp_stop()

static int _pcp_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 1487 of file linux-pcp.c.

1488 {
1489  mRtnCnt(_pcp_stop); // count this function.
1490  (void) ctx; // avoid var unused warning.
1491  (void) ctl; // avoid var unused warning.
1492  return PAPI_OK;
1493 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
static int _pcp_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-pcp.c:1487

◆ _pcp_update_control_state()

static int _pcp_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 1221 of file linux-pcp.c.

1226 {
1227  mRtnCnt(_pcp_update_control_state); // count this function.
1228  int i, index = 0;
1229  ( void ) ctx;
1230 
1231  _pcp_control_state_t* MyCtl = ( _pcp_control_state_t* ) ctl; // Recast ctl.
1232 
1233  MyCtl->numEvents = count; // remember how many there are.
1234  if (count == 0) { // If we are deleting a set,
1235  if (MyCtl->pcpIndex != NULL) { // If we have space allocated,
1236  free(MyCtl->pcpIndex); // .. discard it,
1237  free(MyCtl->pcpValue); // .. and values.
1238  MyCtl->pcpIndex = NULL; // .. never free it again.
1239  MyCtl->pcpValue = NULL; // .. never free it again.
1240  }
1241 
1242  MyCtl->maxAllocated = 0; // .. no longer tracking max.
1243  return PAPI_OK; // .. get out.
1244  }
1245 
1246  // henceforth, count != 0.
1247  #define BlockSize 64 /* constant used multiple times. */
1248  int newalloc = ((count/BlockSize)*BlockSize+BlockSize); // .. pick next up multiple of BlockSize.
1249  #undef BlockSize /*prevent bugs if same name used elsewhere.*/
1250 
1251  if (MyCtl->pcpIndex != NULL) { // If I have a previous list of variables,
1252  if (count > MyCtl->maxAllocated) { // .. If I will need more room,
1253  MyCtl->pcpIndex = realloc(MyCtl->pcpIndex, // .. .. reallocate to make more room.
1254  newalloc*sizeof(int)); // .. .. ..
1255  MyCtl->pcpValue = realloc(MyCtl->pcpValue, // .. .. reallocate to make more room.
1256  newalloc*sizeof(long long)); // .. .. ..
1257  MyCtl->maxAllocated = newalloc; // .. .. remember what we've got.
1258  }
1259  } else { // If NULL then I have no previous set,
1260  MyCtl->maxAllocated = newalloc; // .. pick next up multiple of BlockSize.
1261  MyCtl->pcpIndex = // .. make room for 'count' indices,
1262  calloc(MyCtl->maxAllocated, sizeof(int)); // ..
1263  MyCtl->pcpValue = // .. make room for 'count' values.
1264  calloc(MyCtl->maxAllocated, sizeof(long long)); // ..
1265  }
1266 
1267  if (MyCtl->pcpIndex == NULL) { // If malloc failed,
1268  return PAPI_ENOMEM; // .. out of memory.
1269  } // end if malloc failed.
1270 
1271  //------------------------------------------------------------------
1272  // pcpIndex alloc managed, now process all events passed in.
1273  // pcpIndex[i] holds the event pcp_event_info[] index for
1274  // EventSet[i], and we populate the caller's ni_position for
1275  // EventSet[i] with the index into pcpIndex[].
1276  //------------------------------------------------------------------
1277 
1278  for (i=0; i<count; i++) { // for each event passed in,
1279  index = native[i].ni_event & PAPI_NATIVE_AND_MASK; // get index.
1280  if (index < 0 || index >= sEventCount) { // if something is wrong,
1281  return PAPI_ENOEVNT; // no such event.
1282  } // end if index invalid.
1283 
1284  MyCtl->pcpIndex[i]=index; // remember the index.
1285  MyCtl->pcpValue[i]=0; // clear the value.
1286  native[i].ni_position = i; // Tell PAPI about its location (doesn't matter to us), we have no restrictions on position.
1287  getPMDesc(index); // Any time an event is added, ensure we have its variable descriptor.
1288  } // end for each event listed.
1289 
1290  return PAPI_OK;
1291 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
void getPMDesc(int pcpIdx)
Definition: linux-pcp.c:539
#define PAPI_ENOMEM
Definition: fpapi.h:107
#define mRtnCnt(funcname)
Definition: linux-pcp.c:217
#define BlockSize
static int sEventCount
Definition: linux-pcp.c:187
static int native
static int _pcp_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
Definition: linux-pcp.c:1221
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_NATIVE_AND_MASK
static long count
unsigned long long * pcpValue
Definition: linux-pcp.c:140
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ addNameHash()

unsigned int addNameHash ( char *  key,
int  idx 
)

Definition at line 329 of file linux-pcp.c.

330 {
331  unsigned int slot = stringHash(key, HASH_SIZE); // compute hash code.
332  if (sNameHash[slot].idx < 0) { // If not occupied,
333  sNameHash[slot].idx = idx; // ..Now it is.
334  return(slot); // and we are done.
335  }
336 
337  // slot was occupied (collision).
338  _pcp_hash_t *newGuy = calloc(1, sizeof(_pcp_hash_t)); // make a new entry.
339  newGuy->idx = sNameHash[slot].idx; // copy the idx sitting in table.
340  newGuy->next = sNameHash[slot].next; // copy the chain pointer.
341  sNameHash[slot].idx = idx; // this one goes into table.
342  sNameHash[slot].next = (void*) newGuy; // and chains to that new guy.
343  return(slot); // and we are done.
344 } // end routine.
static _pcp_hash_t sNameHash[HASH_SIZE]
Definition: linux-pcp.c:192
unsigned int stringHash(char *str, unsigned int tableSize)
Definition: linux-pcp.c:313
void * next
Definition: linux-pcp.c:161
static pthread_key_t key
#define HASH_SIZE
Definition: linux-pcp.c:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cachedGetInDom()

static char * cachedGetInDom ( pmInDom  indom,
int  inst 
)
static

Definition at line 575 of file linux-pcp.c.

576 {
577  static int domains=0; // None cached to begin.
578  static _pcp_domain_cache_t* cachedDomains = NULL; // Empty pointer.
579  int i, domIdx;
580 
581  if (inst == -1) { // If we are shutting down,
582  if (cachedDomains == NULL) return(NULL); // exit if we never built an array.
583  for (i=0; i<domains; i++) { // for every one cached,
584  free(cachedDomains[i].instances); // .. free malloced memory.
585  free(cachedDomains[i].names); // .. free malloced memory.
586  }
587 
588  free(cachedDomains); // discard our table.
589  domains = 0; // reset.
590  cachedDomains = NULL; // never free twice.
591  return(NULL); // exit.
592  } // end if shutting down.
593 
594  // Check if we have it already.
595  for (i=0; i<domains; i++) {
596  if (indom == cachedDomains[i].domainId) break; // Exit loop if found.
597  }
598 
599  domIdx = i; // The domain index.
600  if (i == domains) { // If not found; make a new one and read it.
601  domains++; // .. add one to count.
602 
603  if (domains == 1) { // for first domain,
604  cachedDomains = malloc(sizeof(_pcp_domain_cache_t)); // ..malloc.
605  } else { // for subsequent domains,
606  cachedDomains = realloc(cachedDomains,
607  domains*sizeof(_pcp_domain_cache_t)); // realloc, retain first.
608  }
609 
610  if (cachedDomains == NULL) { // If we failed malloc/realloc,
611  fprintf(stderr, "%s:%i:%s malloc/realloc denied for "
612  "cachedDomains; size=%i.\n",
613  __FILE__, __LINE__, __func__, domains);
614  exit(-1);
615  } // end if realloc failed.
616 
617  cachedDomains[domIdx].domainId = indom; // .. The domain we are getting.
618  cachedDomains[domIdx].numInstances = pcp_pmGetInDom(indom,
619  &cachedDomains[domIdx].instances, // .. store pointer lists in struct too.
620  &cachedDomains[domIdx].names); // ..
621  for (i=0; i<cachedDomains[domIdx].numInstances; i++) { // DEBUG, vet the strings.
622  if (cachedDomains[domIdx].names[i] == NULL ||
623  strlen(cachedDomains[domIdx].names[i]) == 0 ||
624  strlen(cachedDomains[domIdx].names[i]) >= PAPI_MAX_STR_LEN) {
625  fprintf(stderr, "%s:%i:%s ERROR: cachedGetInDom: domain=%u, domIdx=%i, name idx %i invalid string.\n",
626  __FILE__, __LINE__, FUNC, indom, domIdx, i);
627  exit(-1);
628  } // end if domain string is nonsense.
629  }
630  } // end if we need to cache a new domain.
631 
632  // We got the domain index, Now we can try to look up the
633  // instance name.
634 
635  for (i=0; i < cachedDomains[domIdx].numInstances; i++) { // look through all instances.
636  if (cachedDomains[domIdx].instances[i] == inst) // .. If found,
637  return cachedDomains[domIdx].names[i]; // .. .. return matching name.
638  } // end search for inst.
639 
640  fprintf(stderr, "%s:%i:%s ERROR: cachedGetInDom: domain=%u, domIdx=%i, numInstances=%i, failed to find inst=%i.\n",
641  __FILE__, __LINE__, FUNC, indom, domIdx, cachedDomains[domIdx].numInstances, inst);
642  exit(-1); // Cannot continue; should not have happened.
643 
644  return NULL; // Code cannot be reached. Couldn't find it.
645 } // end routine.
static int pcp_pmGetInDom(pmInDom indom, int **instlist, char ***namelist)
Definition: linux-pcp.c:295
#define FUNC
Definition: linux-pcp.c:36
const char * names[NUM_EVENTS]
void exit()
int i
Definition: fileop.c:140
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbPopulateNameOnly()

void cbPopulateNameOnly ( const char *  name)

Definition at line 474 of file linux-pcp.c.

475 {
476  if (sEventCount >= sEventInfoSize) { // If we must realloc,
477  sEventInfoSize += sEventInfoBlock; // .. Add another page.
478  pcp_event_info = realloc(pcp_event_info, // .. do realloc.
479  sEventInfoSize*sizeof(_pcp_event_info_t)); // ..
480  memset(&pcp_event_info[sEventCount], 0, // .. clear to zeros.
481  sEventInfoBlock*sizeof(_pcp_event_info_t)); // ..
482  }
483 
484  strncpy(pcp_event_info[sEventCount].name, name, PAPI_MAX_STR_LEN-1); // copy name.
485  sEventCount++; // increment our count of events.
486 } // end routine.
static int sEventInfoSize
Definition: linux-pcp.c:184
static const char * name
Definition: fork_overflow.c:31
static int sEventInfoBlock
Definition: linux-pcp.c:185
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static int sEventCount
Definition: linux-pcp.c:187
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the caller graph for this function:

◆ findNameHash()

int findNameHash ( char *  key)

Definition at line 370 of file linux-pcp.c.

371 {
372  int idx;
373  unsigned int slot = stringHash(key, HASH_SIZE); // compute hash code.
374  idx = sNameHash[slot].idx; // get the index.
375  if (idx < 0) return(-1); // No good slot for it.
376  if (strcmp(key, pcp_event_info[idx].name) == 0) { // If we found it straight away,
377  return(idx); // .. quick return.
378  }
379 
380  _pcp_hash_t *next = (_pcp_hash_t*) sNameHash[slot].next; // get the next guy.
381 
382  while (next != NULL) { // follow the chain.
383  idx = next->idx; // .. get the idx.
384  if (strcmp(key, pcp_event_info[idx].name) == 0) { // If we found a match,
385  return(idx); // .. return with answer.
386  }
387 
388  next = next->next; // get the next guy in the link.
389  } // end chain follow for collisions.
390 
391  return(-1); // did not find it.
392 } // end routine.
static const char * name
Definition: fork_overflow.c:31
static _pcp_hash_t sNameHash[HASH_SIZE]
Definition: linux-pcp.c:192
unsigned int stringHash(char *str, unsigned int tableSize)
Definition: linux-pcp.c:313
void * next
Definition: linux-pcp.c:161
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static pthread_key_t key
#define HASH_SIZE
Definition: linux-pcp.c:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeNameHash()

void freeNameHash ( void  )

Definition at line 351 of file linux-pcp.c.

352 {
353  int i;
354  for (i=0; i<HASH_SIZE; i++) { // loop through table.
355  void *next = sNameHash[i].next; // Get any pointer.
356  while (next != NULL) { // follow the chain.
357  void *tofree = next; // remember what we have to free.
358  next = ((_pcp_hash_t*) next)->next; // follow the chain.
359  free(tofree); // free the one we are standing on.
360  }
361  }
362 } // end routine.
static _pcp_hash_t sNameHash[HASH_SIZE]
Definition: linux-pcp.c:192
void * next
Definition: linux-pcp.c:161
#define HASH_SIZE
Definition: linux-pcp.c:191
int i
Definition: fileop.c:140
Here is the caller graph for this function:

◆ getHelpText()

int getHelpText ( unsigned int  pcpIdx,
char **  helpText 
)

Definition at line 778 of file linux-pcp.c.

779 {
780  char *p;
781  int ret;
782  char errMsg[]="Help Text is not available for this event."; // for an error we have seen.
783 
784  pmID myPMID = pcp_event_info[pcpIdx].pmid; // collect the pmid.
785  ret = pcp_pmLookupText(myPMID, PM_TEXT_HELP, helpText); // collect a line of text, routine mallocs helpText.
786  if (ret != 0) { // If larger help is not available, Try oneline.
787  if (*helpText != NULL) free(*helpText); // .. Free anything allocated.
788  *helpText = NULL; // .. start it as null.
789  ret = pcp_pmLookupText(myPMID, PM_TEXT_ONELINE, helpText); // .. collect a line of text, routine mallocs helpText.
790  }
791 
792  if (ret == PM_ERR_TEXT) { // If not available,
793  *helpText = strdup(errMsg); // duplicate this error message.
794  } else if (ret != 0) { // If PCP has any other error, report and exit.
795  fprintf(stderr, "%s:%i:%s pmLookupText failed; return=%s.\n",
796  __FILE__, __LINE__, FUNC, pcp_pmErrStr(ret));
797  return PAPI_EATTR; // .. invalid or missing event attribute.
798  }
799 
800  // Replace all /n with '|'.
801  for (p=(*helpText); p[0] != 0; p++) { // loop through string routine allocated,
802  if (p[0] == '\n') p[0] = '|'; // .. If we found a \n, replace with '|'.
803  } // end scan for \n.
804 
805  return PAPI_OK; // Presumably all went well.
806 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EATTR
Definition: fpapi.h:127
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static char * pcp_pmErrStr(int code)
Definition: linux-pcp.c:274
long long ret
Definition: iozone.c:1346
#define FUNC
Definition: linux-pcp.c:36
static int pcp_pmLookupText(pmID pmid, int level, char **buffer)
Definition: linux-pcp.c:298
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPMDesc()

void getPMDesc ( int  pcpIdx)

Definition at line 539 of file linux-pcp.c.

539  { // Reads the variable descriptor.
540  int ret;
541  if (pcp_event_info[pcpIdx].pmid == PM_ID_NULL) return; // Already have it.
542  ret = pcp_pmLookupDesc(pcp_event_info[pcpIdx].pmid, // Get the event descriptor.
543  &pcp_event_info[pcpIdx].desc); // .. into the table; will set desc.pmid to not null.
544  if (ret == PM_ERR_PMID) { // If we failed for PMID,
545  fprintf(stderr, "%s:%i:%s Invalid PMID.\n",
546  __FILE__, __LINE__, __func__);
547  exit(-1);
548  } // end if realloc failed.
549 
550  if (ret == PM_ERR_NOAGENT) { // If we failed for agent,
551  fprintf(stderr, "%s:%i:%s PMDA Agent not available to respond..\n",
552  __FILE__, __LINE__, __func__);
553  exit(-1);
554  } // end if realloc failed.
555 
556  if (ret != 0) { // Unknown error,
557  fprintf(stderr, "%s:%i:%s Unknown error code ret=%i.\n",
558  __FILE__, __LINE__, __func__, ret);
559  exit(-1);
560  } // end if realloc failed.
561 
562  pcp_event_info[pcpIdx].valType = pcp_event_info[pcpIdx].desc.type; // Always copy type over.
563  return; // No error.
564 } // END code.
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
long long ret
Definition: iozone.c:1346
static int pcp_pmLookupDesc(pmID pmid, pmDesc *desc)
Definition: linux-pcp.c:292
void exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getULLValue()

unsigned long long getULLValue ( pmValueSet *  vset,
int  value_index 
)

Definition at line 652 of file linux-pcp.c.

653 {
654  unsigned long long value; // our return value.
655  convert_64_t convert; // union for conversion.
656  uPointer_t myPtr; // a union helper to avoid warnings.
657 
658  if (vset->valfmt == PM_VAL_INSITU) { // If the value format is in situ; a 32 bit value.
659  convert.ll = vset->vlist[value_index].value.lval; // .. we can just collect the value immediately.
660  value = convert.ull; // ..
661  } else { // If it is either static or dynamic alloc table,
662  pmValueBlock *pmvb = vset->vlist[value_index].value.pval; // .. value given is a pointer to value block.
663  myPtr.cPtr = pmvb->vbuf; // .. use cPtr because vbuf defined as char[1] in pmValueBlock.
664  switch (pmvb->vtype) { // Note we restricted the types in init; these cases should agree.
665  case PM_TYPE_32: // 32-bit signed integer
666  convert.ll = myPtr.iPtr[0];
667  value = convert.ull;
668  break;
669 
670  case PM_TYPE_U32: // 32-bit unsigned integer
671  value = myPtr.uiPtr[0];
672  break;
673 
674  case PM_TYPE_64: // 64-bit signed integer
675  convert.ll = myPtr.llPtr[0];
676  value = convert.ull;
677  break;
678 
679  case PM_TYPE_U64: // 64-bit unsigned integer
680  value = myPtr.ullPtr[0];
681  break;
682 
683  case PM_TYPE_FLOAT: // 32-bit floating point
684  convert.d = myPtr.fPtr[0]; // convert first.
685  value = convert.ull;
686  break;
687 
688  case PM_TYPE_DOUBLE: // 64-bit floating point
689  convert.d = myPtr.dPtr[0];
690  value = convert.ull;
691  break;
692 
693  case PM_TYPE_STRING: // array of char
694  convert.vp = myPtr.cPtr;
695  value = convert.ull;
696  break;
697 
698  default:
699  fprintf(stderr, "%s:%i pmValueBlock (from PCP) contains an unrecognized value type=%i.\n",
700  __FILE__, __LINE__, pmvb->vtype);
701  convert.ll = -1; // A flag besides zero
702  value = convert.ull;
703  } // end switch on type.
704  } // if pmValueBlock value.
705 
706  return(value); // exit with result.
707 } // end routine.
int * iPtr
Definition: benchSANVML.c:125
unsigned long long * ullPtr
Definition: benchSANVML.c:129
long long * llPtr
Definition: benchSANVML.c:128
unsigned long long ull
Definition: benchSANVML.c:138
unsigned int * uiPtr
Definition: benchSANVML.c:126
float * fPtr
Definition: benchSANVML.c:130
char * cPtr
Definition: benchSANVML.c:132
long long ll
Definition: benchSANVML.c:137
double * dPtr
Definition: benchSANVML.c:131
Here is the caller graph for this function:

◆ makeQualifiedEvent()

void makeQualifiedEvent ( int  baseEvent,
int  idx,
char *  qualifier 
)

Definition at line 495 of file linux-pcp.c.

496 {
497  int prevSize;
498  if (sEventCount >= sEventInfoSize) { // If we must realloc,
499  prevSize = sEventInfoSize;
500  sEventInfoSize += sEventInfoBlock; // .. Add another block.
501  pcp_event_info = realloc(pcp_event_info, // .. attempt reallocation.
502  sEventInfoSize*sizeof(_pcp_event_info_t)); // .. ..
503  if (pcp_event_info == NULL) { // If realloc failed, report it.
504  fprintf(stderr, "%s:%i:%s realloc denied; "
505  "pcp_event_info=%p at size=%i.\n",
506  __FILE__, __LINE__, __func__,
508  exit(-1);
509  } // end if realloc failed.
510 
511  memset(&pcp_event_info[prevSize], 0, // .. clear the new block to zeros..
512  sEventInfoBlock*sizeof(_pcp_event_info_t)); // ..
513  } // end if realloc needed.
514 
515  pcp_event_info[sEventCount] = pcp_event_info[baseEvent]; // copy the structure.
516  pcp_event_info[sEventCount].numVal = 1; // Just one value.
517  pcp_event_info[sEventCount].idx = idx; // Set the right index.
518  pcp_event_info[sEventCount].zeroValue = 0; // Set the base value.
519  int slen = strlen(pcp_event_info[sEventCount].name); // get length of user name.
520  char *c = qualifier; // point at qualifier.
521  pcp_event_info[sEventCount].name[slen++] = ':'; // place a colon.
522 
523  while ( (*c) != 0 && slen < PAPI_MAX_STR_LEN-1) { // .. appending qualifier,
524  char v=*c++; // .. what we intend to append, point at next.
525  // your chance to invalidate any chars, right here!
526  pcp_event_info[sEventCount].name[slen++] = v; // .. add to name, inc slen.
527  }
528 
529  pcp_event_info[sEventCount].name[slen] = 0; // ensure z-terminator.
530  sEventCount++; // increment our count of events.
531 } // end routine.
static int sEventInfoSize
Definition: linux-pcp.c:184
static const char * name
Definition: fork_overflow.c:31
unsigned long long zeroValue
Definition: linux-pcp.c:112
static int sEventInfoBlock
Definition: linux-pcp.c:185
double c
Definition: multiplex.c:22
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
static int sEventCount
Definition: linux-pcp.c:187
char name[PAPI_MAX_STR_LEN]
Definition: linux-pcp.c:104
void exit()
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcp_pmDestroyContext()

static int pcp_pmDestroyContext ( int  handle)
static

Definition at line 286 of file linux-pcp.c.

287  { return ((*pmDestroyContext_ptr) (handle));}
Here is the caller graph for this function:

◆ pcp_pmErrStr()

static char* pcp_pmErrStr ( int  code)
static

Definition at line 274 of file linux-pcp.c.

275  { return ((*pmErrStr_ptr) (code)); }
Here is the caller graph for this function:

◆ pcp_pmFetch()

static int pcp_pmFetch ( int  numpid,
pmID *  pmidlist,
pmResult **  result 
)
static

Definition at line 289 of file linux-pcp.c.

290  { return ((*pmFetch_ptr) (numpid,pmidlist,result)); }
Here is the caller graph for this function:

◆ pcp_pmFreeResult()

void pcp_pmFreeResult ( pmResult *  result)

Definition at line 280 of file linux-pcp.c.

281  { return ((*pmFreeResult_ptr) (result)); }
Here is the caller graph for this function:

◆ pcp_pmGetInDom()

static int pcp_pmGetInDom ( pmInDom  indom,
int **  instlist,
char ***  namelist 
)
static

Definition at line 295 of file linux-pcp.c.

296  { return ((*pmGetInDom_ptr) (indom,instlist,namelist)); }
Here is the caller graph for this function:

◆ pcp_pmLookupDesc()

static int pcp_pmLookupDesc ( pmID  pmid,
pmDesc *  desc 
)
static

Definition at line 292 of file linux-pcp.c.

293  { return ((*pmLookupDesc_ptr) (pmid,desc)); }
Here is the caller graph for this function:

◆ pcp_pmLookupText()

static int pcp_pmLookupText ( pmID  pmid,
int  level,
char **  buffer 
)
static

Definition at line 298 of file linux-pcp.c.

299  { return ((*pmLookupText_ptr) (pmid, level, buffer)); }
char * buffer
Definition: iozone.c:1366
Here is the caller graph for this function:

◆ pcp_pmNewContext()

static int pcp_pmNewContext ( int  type,
const char *  name 
)
static

Definition at line 283 of file linux-pcp.c.

284  { return ((*pmNewContext_ptr) (type,name)); }
static const char * name
Definition: fork_overflow.c:31
Here is the caller graph for this function:

◆ pcp_pmTraversePMNS()

static int pcp_pmTraversePMNS ( const char *  name,
void(*)(const char *)  func 
)
static

Definition at line 277 of file linux-pcp.c.

278  { return ((*pmTraversePMNS_ptr) (name, func)); }
static const char * name
Definition: fork_overflow.c:31
void(* func[])()
Definition: iozone.c:1198
Here is the caller graph for this function:

◆ pcp_pmUnitsStr_r()

static char* pcp_pmUnitsStr_r ( const pmUnits *  pu,
char *  buf,
int  buflen 
)
static

Definition at line 301 of file linux-pcp.c.

302  {return ((*pmUnitsStr_r_ptr) (pu, buf, buflen)); }
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
Here is the caller graph for this function:

◆ PCP_ReadList()

int PCP_ReadList ( hwd_control_state_t ctl,
pmResult **  results 
)

Definition at line 1308 of file linux-pcp.c.

1310 {
1311  int i, j, ret;
1312  _pcp_control_state_t* myCtl = ( _pcp_control_state_t* ) ctl;
1313  *results = NULL; // Nothing allocated.
1314  if (myCtl->numEvents < 1) return PAPI_ENOEVNT; // No events to start.
1315  int nPMID = 0; // To count number of **unique** PMIDs.
1316 
1317  pmID *allPMID=malloc((myCtl->numEvents)*sizeof(pmID)); // Make maximum possible room.
1318 
1319  // We build a list of all *unique* PMIDs. Because PMID can return
1320  // an array of N values for a single event (e.g. one per CPU), we
1321  // 'explode' such events into N events for PAPI, which can only
1322  // return 1 value per event. Thus PAPI could add several to an
1323  // EventSet that all have the same PMID (PCP's ID). We only need
1324  // to read those once, our pcp_event_info[] contains the index
1325  // for each exploded event into the array returned for that PMID.
1326 
1327  allPMID[nPMID++] = pcp_event_info[myCtl->pcpIndex[0]].pmid; // Move the first, increment total so far.
1328 
1329  for (i=1; i<myCtl->numEvents; i++) { // For every event in the event set,
1330  int myIdx = myCtl->pcpIndex[i]; // .. Get pcp_event_info[] index of the event,
1331  pmID myPMID = pcp_event_info[myIdx].pmid; // .. get the PMID for that event,
1332  for (j=0; j<nPMID; j++) { // .. Search the unique PMID list for a match.
1333  if (myPMID == allPMID[j]) break; // .. .. found it. break out.
1334  }
1335 
1336  if (j == nPMID) { // full loop ==> myPMID was not found in list,
1337  allPMID[nPMID++] = myPMID; // .. store the unique pmid in list, inc count.
1338  }
1339  } // done building list of unique pmid.
1340 
1341  // nPMID is # of unique PMID, now ready to read all the pmid needed.
1342  pmResult *allFetch = NULL; // result of pmFetch.
1343  ret = pcp_pmFetch(nPMID, allPMID, &allFetch); // Fetch them all.
1344  *results = allFetch; // For either success or failure.
1345 
1346  if( ret != PAPI_OK) { // If fetch failed ..
1347  fprintf(stderr, "%s:%i:%s pcp_pmFetch failed, return=%s.\n",
1348  __FILE__, __LINE__, FUNC, PAPI_strerror(ret)); // .. report error.
1349  if (allPMID != NULL) free(allPMID); // .. no memory leak.
1350  allPMID = NULL; // .. prevent future use.
1351  return(ret); // .. exit with that error.
1352  }
1353 
1354  // For each unique PMID we just read, we must map it to the event
1355  // sets, which may contain multiple entries with that same PMID.
1356  // This is because PCP returns arrays, and PAPI does not, so each
1357  // of our names translates to a PMID + an index.
1358 
1359  for (i=0; i<nPMID; i++) { // process all the fetch results.
1360  pmValueSet *vset = allFetch->vset[i]; // get the result for event[i].
1361  pmID myPMID = allPMID[i]; // get the pmid from this read.
1362 
1363  // Now we must search for any events with this pmid, and get
1364  // the corresponding value (may be more than one, since we
1365  // treat each idx as its own value).
1366 
1367  for (j=0; j<myCtl->numEvents; j++) { // for each event,
1368  int myPCPIdx = myCtl->pcpIndex[j]; // .. get my pcp_event_info[] index.
1369  pmID thisPMID = pcp_event_info[myPCPIdx].pmid; // .. collect its pmid.
1370  if (thisPMID == myPMID) { // .. If this result services that event,
1371  int myArrayIdx = pcp_event_info[myPCPIdx].idx; // .. .. get array index within result array, for result value list.
1372  myCtl->pcpValue[j] = getULLValue(vset, myArrayIdx); // .. .. translate as needed, put back into pcpValue array.
1373  } // end if counter was found for this PMID.
1374  } // end loop through all events in this event set.
1375  } // end for each pmID read.
1376 
1377  if (allPMID != NULL) free(allPMID); // Done with this work area; no memory leak.
1378  return PAPI_OK; // All done.
1379 } // end routine.
#define PAPI_OK
Definition: fpapi.h:105
static int pcp_pmFetch(int numpid, pmID *pmidlist, pmResult **result)
Definition: linux-pcp.c:289
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
long long ret
Definition: iozone.c:1346
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define FUNC
Definition: linux-pcp.c:36
unsigned long long * pcpValue
Definition: linux-pcp.c:140
unsigned long long getULLValue(pmValueSet *vset, int value_index)
Definition: linux-pcp.c:652
int i
Definition: fileop.c:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ qsPMID()

int qsPMID ( const void *  arg1,
const void *  arg2 
)

Definition at line 453 of file linux-pcp.c.

454 {
455  _pcp_event_info_t *p1 = (_pcp_event_info_t*) arg1;
456  _pcp_event_info_t *p2 = (_pcp_event_info_t*) arg2;
457 
458  if (p1->pmid < p2->pmid) return (-1); // 1 comes before 2.
459  if (p1->pmid > p2->pmid) return ( 1); // 1 comes after 2.
460  if (p1->idx < p2->idx ) return (-1); // same pmid, try idx into vlist.
461  if (p1->idx > p2->idx ) return ( 1); // 1 comes after 2.
462  return (strcmp(p1->name, p2->name)); // sort by name if same PMID and idx.
463 } // end routine.
char name[PAPI_MAX_STR_LEN]
Definition: linux-pcp.c:104
Here is the caller graph for this function:

◆ stringHash()

unsigned int stringHash ( char *  str,
unsigned int  tableSize 
)

Definition at line 313 of file linux-pcp.c.

314 {
315  unsigned long hash = 5381; // seed value.
316  int c;
317  while ((c = (*str++))) { // ends when c == 0.
318  hash = ((hash << 5) + hash) + c; // hash * 33 + c.
319  }
320 
321  return (hash % tableSize); // compute index and exit.
322 } // end function.
double c
Definition: multiplex.c:22
Here is the caller graph for this function:

◆ subZero()

void subZero ( _pcp_control_state_t myCtl,
int  event 
)

Definition at line 726 of file linux-pcp.c.

727 {
728  int k = myCtl->pcpIndex[event]; // get pcp_event_info[] index.
729  if (pcp_event_info[k].desc.sem != PM_SEM_COUNTER) return; // Don't subtract from instantaneous values.
730 
731  convert_64_t zero, rawval;
732  rawval.ull = myCtl->pcpValue[event]; // collect the raw value.
733  zero.ull = pcp_event_info[k].zeroValue; // collect the zero (base) value.
734  switch (pcp_event_info[k].valType) { // Note we restricted the types in init; these cases should agree.
735  case PM_TYPE_32: // 32 bit was converted to long long.
736  case PM_TYPE_64: // long long.
737  rawval.ll -= zero.ll; // converted.
738  break;
739 
740  case PM_TYPE_U32: // 32-bit was converted to 64 bit.
741  case PM_TYPE_U64: // 64-bit unsigned integer
742  rawval.ull -= zero.ull; // converted.
743  break;
744 
745  case PM_TYPE_FLOAT: // 32-bit was converted to double.
746  case PM_TYPE_DOUBLE: // 64-bit floating point
747  rawval.d -= zero.d; // converted.
748  break;
749 
750  case PM_TYPE_STRING: // array of char, do nothing for pointer.
751  break;
752 
753  default:
754  fprintf(stderr, "%s:%i pcp_event_info[%s] contains an unrecognized value type=%i.\n",
755  __FILE__, __LINE__, pcp_event_info[k].name, pcp_event_info[k].valType);
756  exit(-1); // Quit, this shouldn't happen; something needs updating.
757  break;
758  } // end switch on type.
759 
760  myCtl->pcpValue[event] = rawval.ull; // The adjusted value.
761 } // end routine.
static const char * name
Definition: fork_overflow.c:31
unsigned long long zeroValue
Definition: linux-pcp.c:112
static _pcp_event_info_t * pcp_event_info
Definition: linux-pcp.c:186
unsigned long long ull
Definition: benchSANVML.c:138
long long ll
Definition: benchSANVML.c:137
void exit()
unsigned long long * pcpValue
Definition: linux-pcp.c:140
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _dl_non_dynamic_init

void(* _dl_non_dynamic_init) (void)

Definition at line 253 of file linux-pcp.c.

272  { return ((*pmLookupName_ptr) (numpid, namelist, pmidlist)); }

◆ _papi_hwi_debug

int _papi_hwi_debug = DEBUG_SUBSTRATE

Definition at line 183 of file linux-pcp.c.

◆ _pcp_vector

papi_vector_t _pcp_vector

Definition at line 178 of file linux-pcp.c.

◆ cnt

int cnt[ctr_pcp_ntv_code_to_info+1] = {0}

Definition at line 215 of file linux-pcp.c.

◆ ctxHandle

int ctxHandle = -1

Definition at line 188 of file linux-pcp.c.

◆ dllib1

void* dllib1 = NULL
static

Definition at line 244 of file linux-pcp.c.

◆ pcp_event_info

_pcp_event_info_t* pcp_event_info = NULL
static

Definition at line 186 of file linux-pcp.c.

◆ pmProgname

char* pmProgname = "pcp"

Definition at line 189 of file linux-pcp.c.

◆ sEventCount

int sEventCount = 0
static

Definition at line 187 of file linux-pcp.c.

◆ sEventInfoBlock

int sEventInfoBlock = ((8*1024) / sizeof(_pcp_event_info_t))
static

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

◆ sEventInfoSize

int sEventInfoSize =0
static

Definition at line 184 of file linux-pcp.c.

◆ sNameHash

_pcp_hash_t sNameHash[HASH_SIZE]
static

Definition at line 192 of file linux-pcp.c.

◆ t2

struct timeval t1 t2
static

Definition at line 235 of file linux-pcp.c.