Reading counters from two components

155 views
Skip to first unread message

Etienne André

unread,
Jul 23, 2019, 4:42:19 PM7/23/19
to ptools-perfapi
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;
}

Vince Weaver

unread,
Jul 23, 2019, 10:17:05 PM7/23/19
to Etienne André, ptools-perfapi
On Tue, 23 Jul 2019, Etienne André wrote:

> 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 :

I don't think you can add events from different components to one
eventset. You will need to create multiple eventsets (one for each
component).

Vince

Frank Winkler

unread,
Jul 24, 2019, 4:05:04 AM7/24/19
to Vince Weaver, Etienne André, ptools-perfapi
Hi André,

Alternatively, you can also try out the new high-level API, which automatically creates components and assigns events to the corresponding component.
However, the latest PAPI must be installed from the bitbucket repository, see http://icl.utk.edu/papi/software/.

Further information about the new high-level API can be found here:

Best
Frank



--
You received this message because you are subscribed to the Google Groups "ptools-perfapi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ptools-perfap...@icl.utk.edu.
To view this discussion on the web visit https://groups.google.com/a/icl.utk.edu/d/msgid/ptools-perfapi/alpine.DEB.2.21.1907232213220.17511%40macbook-air.

Etienne ANDRE

unread,
Jul 25, 2019, 5:53:48 AM7/25/19
to Frank Winkler, Vince Weaver, ptools-perfapi
Thanks a lot for the help.
Indeed, what I was doing wrong was adding events from different components into the same eventset. Now that I separated the culprits, it works as intended.
I was also unsure of the meaning of "component" : I assumed it was the part before :: in the event name (FP_ARITH, bdx_unc_imc0 and rapl in my case). But it seems that while FP_ARITH has component index 0, the two other ones share component index 1, and thus can be put in the same eventset. Can anyone enlighten me on that point ?

The high-level API isn't offering the functionality that I want, but was very helpful in understanding what I should do with the low-level API. If anyone is as confused as me, looking at the how the new high-level API seems like a very good idea. If you compile PAPI with debug enabled (./configure --with-debug), you can then launch your high-level programs with PAPI_DEBUG=HIGHLEVEL or PAPI_DEBUG=INT to get a better understanding of what's happening.

Regards,
Étienne
Reply all
Reply to author
Forward
0 new messages