1

I wrote the following code to get L3 cache miss information.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <papi.h>

int main( int argc, char *argv[] ) {
  int i;

  long long counters[3];
  counters[0] = counters[1] = counters[2] = 0;
  int PAPI_events[] = {
    PAPI_TOT_CYC,
    PAPI_L3_TCM,
    PAPI_L3_DCA };

  PAPI_library_init(PAPI_VER_CURRENT);

  i = PAPI_start_counters(PAPI_events, 3);

  printf("Measuring instruction count for this printf\n");

  PAPI_read_counters(counters, 3);

  printf("%lld L3 cache misses %lld L3 cache accesses in %lld cycles"
   counters[1], counters[2], counters[0] );

  return 0;
}

But I get an error and zero values for counters as below. What could be wrong?

PAPI Error: pfm_find_full_event(RETIRED_MISPREDICTED_BRANCH_INSTRUCTIONS,0x7fff22fe65a0): event not found.
PAPI Error: 1 of 4 events in papi_events.csv were not valid.
Measuring instruction count for this printf
0 L3 cache misses 0 L3 cache accesses in 0 cycles

I checked available counters with papi_avail -a and the counters seem to be supported. CPU information given below.

Available events and hardware information.
--------------------------------------------------------------------------------
PAPI Version             : 5.1.1.0
Vendor string and code   : GenuineIntel (1)
Model string and code    : Intel(R) Xeon(R) CPU E7- 4830  @ 2.13GHz (47)
CPU Revision             : 2.000000
CPUID Info               : Family: 6  Model: 47  Stepping: 2
CPU Max Megahertz        : 2128
CPU Min Megahertz        : 2128
Hdw Threads per core     : 1
Cores per Socket         : 8
NUMA Nodes               : 4
CPUs per Node            : 8
Total CPUs               : 32
Running in a VM          : no
Number Hardware Counters : 7
Max Multiplex Counters   : 64

uname output

2.6.32-431.17.1.el6.x86_64 #1 SMP Fri Apr 11 17:27:00 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
chamibuddhika
  • 1,419
  • 2
  • 20
  • 36
  • Did you run the program from root user? Why to use so old kernel on so modern CPU? – osgx Mar 22 '15 at 02:47
  • I don't have root access to the machine. Unfortunately it's the version that is present in the system. – chamibuddhika Mar 22 '15 at 05:40
  • chamibuddhika, http://comments.gmane.org/gmane.comp.linux.papi/675 "*L3 events may likely require root as those are in the 'uncore' PMU I believe.*" - you have no access to uncore counters without root; try L1 and L2 events. – osgx Mar 22 '15 at 14:35

0 Answers0