Hi,
I'm trying to access the following counters on a broadwell-EP CPU (Xeon E5-2680 v4):
"FP_ARITH:SCALAR_DOUBLE:cpu=0",
"FP_ARITH:128B_PACKED_DOUBLE:cpu=0",
"FP_ARITH:256B_PACKED_DOUBLE:cpu=0",
"bdx_unc_imc0::UNC_M_CAS_COUNT:RD:e=0:i=0:t=0:cpu=0",
"bdx_unc_imc0::UNC_M_CAS_COUNT:WR:e=0:i=0:t=0:cpu=0",
"rapl::RAPL_ENERGY_PKG:cpu=0",
"rapl::RAPL_ENERGY_DRAM:cpu=0",
The first three are from the perf_event component, the last four are from perf_event_uncore.
The small C program provided below fails at adding events, with the following output :
Adding event FP_ARITH:SCALAR_DOUBLE:cpu=0 code=1073741870
Adding event FP_ARITH:128B_PACKED_DOUBLE:cpu=0 code=1073741871
Adding event FP_ARITH:256B_PACKED_DOUBLE:cpu=0 code=1073741872
Adding event bdx_unc_imc0::UNC_M_CAS_COUNT:RD:e=0:i=0:t=0:cpu=0 code=1073741873
PAPI Error: Error Code -1,Invalid argument
Running the same program with only the events from the perf_event component uncommented works as expected, and only the ones from perf_event_uncore, too.
What am I missing here ? Isn't reading from several components at the same time possible ?
Any help would be appreciated. I can provide a detailed debug log if needed.
papitest.c :
#include <papi.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void print_events(long long values[], size_t size) {
for (size_t i = 0; i < size; i++) {
printf("Read (%ld) = %lld\n", i, values[i]);
}
}
int main() {
int EventSet = PAPI_NULL;
PAPI_set_debug(PAPI_VERB_ESTOP);
/* Initialize PAPI */
if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
perror("fail init");
exit(1);
}
/* Create an EventSet */
PAPI_create_eventset(&EventSet);
char* event_names[] = {
"FP_ARITH:SCALAR_DOUBLE:cpu=0",
"FP_ARITH:128B_PACKED_DOUBLE:cpu=0",
"FP_ARITH:256B_PACKED_DOUBLE:cpu=0",
"bdx_unc_imc0::UNC_M_CAS_COUNT:RD:e=0:i=0:t=0:cpu=0",
"bdx_unc_imc0::UNC_M_CAS_COUNT:WR:e=0:i=0:t=0:cpu=0",
"rapl::RAPL_ENERGY_PKG:cpu=0",
"rapl::RAPL_ENERGY_DRAM:cpu=0",
};
size_t n_events = sizeof(event_names) / sizeof(char*);
for (size_t i=0; i<n_events; i++) {
int code;
PAPI_event_name_to_code(event_names[i], &code);
printf("Adding event %s code=%d\n", event_names[i], code);
PAPI_add_event(EventSet, code);
}
PAPI_start(EventSet);
long long values[n_events];
while (1) {
sleep(1);
PAPI_accum(EventSet, values);
print_events(values, n_events);
}
return 0;
}