857{
861 reason[rLen-1]=0;
862
864 #define hostnameLen 512
866 int ret;
867
871 goto fn_fail;
872 }
873
875 if (ret != 0) {
876 int strErr=snprintf(reason, rLen, "Failed system call, gethostname() "
877 "returned %i.", ret);
878 reason[rLen-1]=0;
881 goto fn_fail;
882 }
883 #undef hostnameLen
884
886
889 int strErr=snprintf(reason, rLen, "Cannot connect to PM Daemon on \"%s\".\n "
890 "(Is the Performance Co-Pilot running?)\n", hostname);
891 reason[rLen-1]=0;
892 if (strErr > rLen)
SUBDBG(
"%s:%i Warning! Error's 'reason' string truncated:\n%s\n",__FILE__,__LINE__,reason);
894 goto fn_fail;
895 }
896
898
908 goto fn_fail;
909 }
910
914 if (ret < 0) {
915 int strErr=snprintf(reason, rLen, "pmTraversePMNS failed; ret=%i [%s]\n",
917 if (ret == PM_ERR_NAME) {
918 strErr=snprintf(reason, rLen, "pmTraversePMNS ret=PM_ERR_NAME: "
919 "Occurs if event filter '%s' unknown to PCP Daemon.\n",
AGENT_NAME);
920 }
921 reason[rLen-1]=0;
924 goto fn_fail;
925 }
926
931 "sEventInfoBlock=%i.\n",
933
935 int strErr=snprintf(reason, rLen, "pmTraversePMNS returned zero events "
937 reason[rLen-1]=0;
940 goto fn_fail;
941 }
942
944 char **allNames=calloc(
sEventCount,
sizeof(
char*));
947 }
948
950 if (allPMID == NULL) {
951 snprintf(reason, rLen, "memory alloc denied for allPMID; "
953 int strErr=snprintf(reason, rLen,
"Could not allocate %lu bytes of memory for allPMID.",
sEventCount*
sizeof(pmID));
954 free(allNames);
957 goto fn_fail;
958 }
959
960
961
962
963
964
965
966
967 #define LNBLOCK 256
968 k = (__LINE__)-1;
969
971
976 ret = pcp_pmLookupName(j, allNames+
i, allPMID+
i);
977 if (ret < 0) {
978 int strErr=snprintf(reason, rLen, "pmLookupName for %i names failed; ret=%i [%s].\n",
980 reason[rLen-1]=0;
982
983 if (ret == PM_ERR_IPC) {
984 strErr=snprintf(reason, rLen, "pmLookupName ret=PM_ERR_IPC: one known cause is a readblock too large; reduce LNBLOCK (%s:%i).\n",
985 __FILE__,k);
986 reason[rLen-1]=0;
989 goto fn_fail;
990 }
991
993 goto fn_fail;
994 }
995
997 }
998 #undef LNBLOCK
999
1003
1005
1006 pmResult *allFetch = NULL;
1010 if (ret != 0) {
1011 int strErr=snprintf(reason, rLen, "pcp_pmFetch failed, retcode=%d.", ret);
1012 reason[rLen-1]=0;
1015 goto fn_fail;
1016 }
1017
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1033
1034 for (
i=0;
i<origEventCount;
i++) {
1036 pmValueSet *vset = allFetch->vset[
i];
1037
1038
1039 if (vset == NULL) {
1040 fprintf(
stderr,
"%s:%i vset=NULL for name='%s'\n",
1042 continue;
1043 }
1044
1046 if (vset->numval == 0) {
1047
1048 continue;
1049 }
1050
1053 unsigned long long ullval= (
long long) -1;
1055
1056 if (vset->valfmt != PM_VAL_INSITU) {
1057 pmValue *pmval = &vset->vlist[0];
1058 pmValueBlock *pB = pmval->value.pval;
1060 int strErr=snprintf(reason, rLen, "Unexpected value type fetched for %s. %i vs %i. Possible version incompatibiity.\n",
1062 reason[rLen-1]=0;
1065 goto fn_fail;
1066 }
1067
1068
1070
1071 switch(pB->vtype) {
1072 case PM_TYPE_32:
1074 break;
1075 case PM_TYPE_U32:
1077 break;
1078 case PM_TYPE_FLOAT:
1080 break;
1081
1082 case PM_TYPE_64:
1083 convert.
ull = ullval;
1085 break;
1086 case PM_TYPE_U64:
1088 break;
1089 case PM_TYPE_DOUBLE:
1090 convert.
ull = ullval;
1092 break;
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102 case PM_TYPE_STRING:
1105 break;
1106
1107 default:
1110 break;
1111 }
1112 }
1113 else {
1115 }
1116
1117 convert.
ull = ullval;
1118 _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]);
1119
1120
1121
1122
1127 for (j=0; j<vset->numval; j++) {
1128 pmValue *pmval = &vset->vlist[j];
1129
1132 pmval->inst);
1133
1135 }
1136
1138 }
1139 }
1140 }
1141
1142
1143
1144
1145
1146 j=0;
1150 j++;
1151 }
1152 }
1153
1158 int strErr=snprintf(reason, rLen,
1160 reason[rLen-1]=0;
1163 goto fn_fail;
1164 }
1165
1168
1172
1176 }
1177
1178 unsigned int myHash;
1181 }
1182
1183
1184
1185
1186
1187 if (0) {
1188 unsigned int current, prev=0;
1189 printf("count, hash, name, pmid, value[idx]\n");
1193 if (prev > 0 && current != (prev+1) && current != prev)
1194 printf("----,----,----,----\n");
1195 printf(
"%i, %u, \"%s\", 0x%08X, %i\n",
i, myHash,
1199 prev=current;
1200 }
1201
1202
1203 int hashErr = 0;
1207 if (
f !=
i) hashErr++;
1208 }
1209
1211
1214
1215 }
1216
1217
1218
1219
1220 free(allNames);
1221 free(allPMID);
1223
1224
1225
1226
1231
1232 fn_exit:
1235 fn_fail:
1236 goto fn_exit;
1237}
struct papi_vectors * _papi_hwd[]
static unsigned long long getULLValue(pmValueSet *vset, int value_index)
static int _local_linkDynamicLibraries(void)
#define mConvertUsec(timeval_)
#define _time_gettimeofday
static unsigned int stringHash(char *str, unsigned int tableSize)
static void pcp_pmFreeResult(pmResult *result)
static char * pcp_pmErrStr(int code)
static int sEventInfoBlock
static void makeQualifiedEvent(int baseEvent, int idx, char *qualifier)
static int _pcp_init_component(int cidx)
static void cbPopulateNameOnly(const char *name)
static int pcp_pmTraversePMNS(const char *name, void(*func)(const char *))
static _pcp_hash_t sNameHash[HASH_SIZE]
static unsigned int addNameHash(char *key, int idx)
static int findNameHash(char *key)
static int sEventInfoSize
static _pcp_event_info_t * pcp_event_info
static struct timeval t1 t2
static int pcp_pmNewContext(int type, const char *name)
static void getPMDesc(int pcpIdx)
static int qsPMID(const void *arg1, const void *arg2)
static int pcp_pmFetch(int numpid, pmID *pmidlist, pmResult **result)
static char * cachedGetInDom(pmInDom indom, int inst)
char name[PAPI_MAX_STR_LEN]