PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-rapl.c
Go to the documentation of this file.
1 
18 #include <stdio.h>
19 #include <unistd.h>
20 #include <dirent.h>
21 #include <fcntl.h>
22 #include <string.h>
23 #include <stdint.h>
24 #include <errno.h>
25 
26 /* Headers required by PAPI */
27 #include "papi.h"
28 #include "papi_internal.h"
29 #include "papi_vector.h"
30 #include "papi_memory.h"
31 
32 
33 /*
34  * Platform specific RAPL Domains.
35  * Note that PP1 RAPL Domain is supported on 062A only
36  * And DRAM RAPL Domain is supported on 062D only
37  */
38 
39 
40 /* RAPL defines */
41 #define MSR_RAPL_POWER_UNIT 0x606
42 
43 /* Package */
44 #define MSR_PKG_RAPL_POWER_LIMIT 0x610
45 #define MSR_PKG_ENERGY_STATUS 0x611
46 #define MSR_PKG_PERF_STATUS 0x613
47 #define MSR_PKG_POWER_INFO 0x614
48 
49 /* PP0 */
50 #define MSR_PP0_POWER_LIMIT 0x638
51 #define MSR_PP0_ENERGY_STATUS 0x639
52 #define MSR_PP0_POLICY 0x63A
53 #define MSR_PP0_PERF_STATUS 0x63B
54 
55 /* PP1 */
56 #define MSR_PP1_POWER_LIMIT 0x640
57 #define MSR_PP1_ENERGY_STATUS 0x641
58 #define MSR_PP1_POLICY 0x642
59 
60 /* DRAM */
61 #define MSR_DRAM_POWER_LIMIT 0x618
62 #define MSR_DRAM_ENERGY_STATUS 0x619
63 #define MSR_DRAM_PERF_STATUS 0x61B
64 #define MSR_DRAM_POWER_INFO 0x61C
65 
66 /* PSYS RAPL Domain */
67 #define MSR_PLATFORM_ENERGY_STATUS 0x64d
68 
69 /* RAPL bitsmasks */
70 #define POWER_UNIT_OFFSET 0
71 #define POWER_UNIT_MASK 0x0f
72 
73 #define ENERGY_UNIT_OFFSET 0x08
74 #define ENERGY_UNIT_MASK 0x1f
75 
76 #define TIME_UNIT_OFFSET 0x10
77 #define TIME_UNIT_MASK 0x0f
78 
79 /* RAPL POWER UNIT MASKS */
80 #define POWER_INFO_UNIT_MASK 0x7fff
81 #define THERMAL_SHIFT 0
82 #define MINIMUM_POWER_SHIFT 16
83 #define MAXIMUM_POWER_SHIFT 32
84 #define MAXIMUM_TIME_WINDOW_SHIFT 48
85 
86 
87 typedef struct _rapl_register
88 {
89  unsigned int selector;
91 
92 typedef struct _rapl_native_event_entry
93 {
96  char description[PAPI_MAX_STR_LEN];
97  int fd_offset;
98  int msr;
99  int type;
103 
104 typedef struct _rapl_reg_alloc
105 {
108 
109 /* actually 32? But setting this to be safe? */
110 #define RAPL_MAX_COUNTERS 64
111 
112 typedef struct _rapl_control_state
113 {
114  int being_measured[RAPL_MAX_COUNTERS];
116  int need_difference[RAPL_MAX_COUNTERS];
117  long long lastupdate;
119 
120 
121 typedef struct _rapl_context
122 {
123  long long start_value[RAPL_MAX_COUNTERS];
126 
127 
129 
130 struct fd_array_t {
131  int fd;
132  int open;
133 };
134 
136 static int num_events = 0;
137 struct fd_array_t *fd_array=NULL;
138 static int num_packages=0,num_cpus=0;
139 
142 
143 #define PACKAGE_ENERGY 0
144 #define PACKAGE_THERMAL 1
145 #define PACKAGE_MINIMUM 2
146 #define PACKAGE_MAXIMUM 3
147 #define PACKAGE_TIME_WINDOW 4
148 #define PACKAGE_ENERGY_CNT 5
149 #define PACKAGE_THERMAL_CNT 6
150 #define PACKAGE_MINIMUM_CNT 7
151 #define PACKAGE_MAXIMUM_CNT 8
152 #define PACKAGE_TIME_WINDOW_CNT 9
153 #define DRAM_ENERGY 10
154 #define PLATFORM_ENERGY 11
155 
156 /***************************************************************************/
157 /****** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT *******/
158 /***************************************************************************/
159 
160 
161 static long long read_msr(int fd, int which) {
162 
163  uint64_t data;
164 
165  if ( fd<0 || pread(fd, &data, sizeof data, which) != sizeof data ) {
166  perror("rdmsr:pread");
167  exit(127);
168  }
169 
170  return (long long)data;
171 }
172 
173 static int open_fd(int offset) {
174 
175  int fd=-1;
176  char filename[BUFSIZ];
177 
178  if (fd_array[offset].open==0) {
179  sprintf(filename,"/dev/cpu/%d/msr_safe",offset);
180  fd = open(filename, O_RDONLY);
181  if (fd<0) {
182  sprintf(filename,"/dev/cpu/%d/msr",offset);
183  fd = open(filename, O_RDONLY);
184  }
185  if (fd>=0) {
186  fd_array[offset].fd=fd;
187  fd_array[offset].open=1;
188  }
189  }
190  else {
191  fd=fd_array[offset].fd;
192  }
193 
194  return fd;
195 }
196 
197 static long long read_rapl_value(int index) {
198 
199  int fd;
200 
201  fd=open_fd(rapl_native_events[index].fd_offset);
202  return read_msr(fd,rapl_native_events[index].msr);
203 
204 }
205 
206 static long long convert_rapl_energy(int index, long long value) {
207 
208  union {
209  long long ll;
210  double fp;
211  } return_val;
212 
213  return_val.ll = value; /* default case: return raw input value */
214 
215  if (rapl_native_events[index].type==PACKAGE_ENERGY) {
216  return_val.ll = (long long)(((double)value/cpu_energy_divisor)*1e9);
217  }
218 
219  if (rapl_native_events[index].type==DRAM_ENERGY) {
220  return_val.ll = (long long)(((double)value/dram_energy_divisor)*1e9);
221  }
222 
223  if (rapl_native_events[index].type==PLATFORM_ENERGY) {
224  return_val.ll = (long long)(((double)value/cpu_energy_divisor)*1e9);
225  }
226 
227  if (rapl_native_events[index].type==PACKAGE_THERMAL) {
228  return_val.fp = (double)
230  (double)power_divisor;
231  }
232 
233  if (rapl_native_events[index].type==PACKAGE_MINIMUM) {
234  return_val.fp = (double)
236  (double)power_divisor;
237  }
238 
239  if (rapl_native_events[index].type==PACKAGE_MAXIMUM) {
240  return_val.fp = (double)
242  (double)power_divisor;
243  }
244 
245  if (rapl_native_events[index].type==PACKAGE_TIME_WINDOW) {
246  return_val.fp = (double)
248  (double)time_divisor;
249  }
250 
251  if (rapl_native_events[index].type==PACKAGE_THERMAL_CNT) {
252  return_val.ll = ((value>>THERMAL_SHIFT)&POWER_INFO_UNIT_MASK);
253  }
254 
255  if (rapl_native_events[index].type==PACKAGE_MINIMUM_CNT) {
256  return_val.ll = ((value>>MINIMUM_POWER_SHIFT)&POWER_INFO_UNIT_MASK);
257  }
258 
259  if (rapl_native_events[index].type==PACKAGE_MAXIMUM_CNT) {
260  return_val.ll = ((value>>MAXIMUM_POWER_SHIFT)&POWER_INFO_UNIT_MASK);
261  }
262 
263  if (rapl_native_events[index].type==PACKAGE_TIME_WINDOW_CNT) {
264  return_val.ll = ((value>>MAXIMUM_TIME_WINDOW_SHIFT)&POWER_INFO_UNIT_MASK);
265  }
266 
267  return return_val.ll;
268 }
269 
270 static int
272 {
273  FILE *fff;
274  int num_read, nr_cpus = 1;
275  fff=fopen("/sys/devices/system/cpu/kernel_max","r");
276  if (fff==NULL) return nr_cpus;
277  num_read=fscanf(fff,"%d",&nr_cpus);
278  fclose(fff);
279  if (num_read==1) {
280  nr_cpus++;
281  } else {
282  nr_cpus = 1;
283  }
284  return nr_cpus;
285 }
286 
287 /************************* PAPI Functions **********************************/
288 
289 
290 /*
291  * This is called whenever a thread is initialized
292  */
293 static int
295 {
296  ( void ) ctx;
297 
298  return PAPI_OK;
299 }
300 
301 
302 
303 /*
304  * Called when PAPI process is initialized (i.e. PAPI_library_init)
305  */
306 static int
308 {
309  int i,j,k,fd;
310  FILE *fff;
311  char filename[BUFSIZ];
312 
313  int package_avail, dram_avail, pp0_avail, pp1_avail, psys_avail;
314  int different_units;
315 
316  long long result;
317  int package;
318 
319  const PAPI_hw_info_t *hw_info;
320 
321  int nr_cpus = get_kernel_nr_cpus();
322  int packages[nr_cpus];
323  int cpu_to_use[nr_cpus];
324 
325  /* Fill with sentinel values */
326  for (i=0; i<nr_cpus; ++i) {
327  packages[i] = -1;
328  cpu_to_use[i] = -1;
329  }
330 
331 
332  /* check if Intel processor */
333  hw_info=&(_papi_hwi_system_info.hw_info);
334 
335  /* Ugh can't use PAPI_get_hardware_info() if
336  PAPI library not done initializing yet */
337 
338  if (hw_info->vendor!=PAPI_VENDOR_INTEL) {
339  strncpy(_rapl_vector.cmp_info.disabled_reason,
340  "Not an Intel processor",PAPI_MAX_STR_LEN);
341  return PAPI_ENOSUPP;
342  }
343 
344  /* Make sure it is a family 6 Intel Chip */
345  if (hw_info->cpuid_family!=6) {
346  /* Not a family 6 machine */
347  strncpy(_rapl_vector.cmp_info.disabled_reason,
348  "CPU family not supported",PAPI_MAX_STR_LEN);
349  return PAPI_ENOIMPL;
350  }
351 
352  /* Detect RAPL support */
353  switch(hw_info->cpuid_model) {
354 
355  /* Desktop / Laptops */
356 
357  case 42: /* SandyBridge */
358  case 58: /* IvyBridge */
359  package_avail=1;
360  pp0_avail=1;
361  pp1_avail=1;
362  dram_avail=0;
363  psys_avail=0;
364  different_units=0;
365  break;
366 
367  case 60: /* Haswell */
368  case 69: /* Haswell ULT */
369  case 70: /* Haswell GT3E */
370  case 92: /* Atom Goldmont */
371  case 122: /* Atom Gemini Lake */
372  case 95: /* Atom Denverton */
373  package_avail=1;
374  pp0_avail=1;
375  pp1_avail=1;
376  dram_avail=1;
377  psys_avail=0;
378  different_units=0;
379  break;
380 
381  case 61: /* Broadwell */
382  case 71: /* Broadwell-H (GT3E) */
383  case 86: /* Broadwell XEON_D */
384  package_avail=1;
385  pp0_avail=1;
386  pp1_avail=0;
387  dram_avail=1;
388  psys_avail=0;
389  different_units=0;
390  break;
391 
392  case 78: /* Skylake Mobile */
393  case 94: /* Skylake Desktop (H/S) */
394  case 142: /* Kabylake Mobile */
395  case 158: /* Kabylake Desktop */
396  package_avail=1;
397  pp0_avail=1;
398  pp1_avail=0;
399  dram_avail=1;
400  psys_avail=1;
401  different_units=0;
402  break;
403 
404  /* Server Class Machines */
405 
406  case 45: /* SandyBridge-EP */
407  case 62: /* IvyBridge-EP */
408  package_avail=1;
409  pp0_avail=1;
410  pp1_avail=0;
411  dram_avail=1;
412  psys_avail=0;
413  different_units=0;
414  break;
415 
416  case 63: /* Haswell-EP */
417  case 79: /* Broadwell-EP */
418  case 85: /* Skylake-X */
419  package_avail=1;
420  pp0_avail=1;
421  pp1_avail=0;
422  dram_avail=1;
423  psys_avail=0;
424  different_units=1;
425  break;
426 
427 
428  case 87: /* Knights Landing (KNL) */
429  case 133: /* Knights Mill (KNM) */
430  package_avail=1;
431  pp0_avail=0;
432  pp1_avail=0;
433  dram_avail=1;
434  psys_avail=0;
435  different_units=1;
436  break;
437 
438  default: /* not a supported model */
439  strncpy(_rapl_vector.cmp_info.disabled_reason,
440  "CPU model not supported",
442  return PAPI_ENOIMPL;
443  }
444 
445  /* Detect how many packages */
446  j=0;
447  while(1) {
448  int num_read;
449 
450  sprintf(filename,
451  "/sys/devices/system/cpu/cpu%d/topology/physical_package_id",j);
452  fff=fopen(filename,"r");
453  if (fff==NULL) break;
454  num_read=fscanf(fff,"%d",&package);
455  fclose(fff);
456  if (num_read!=1) {
457  strcpy(_rapl_vector.cmp_info.disabled_reason, "Error reading file: ");
458  strncat(_rapl_vector.cmp_info.disabled_reason, filename, PAPI_MAX_STR_LEN - strlen(_rapl_vector.cmp_info.disabled_reason) - 1);
459  _rapl_vector.cmp_info.disabled_reason[PAPI_MAX_STR_LEN-1] = '\0';
460  return PAPI_ESYS;
461  }
462 
463  /* Check if a new package */
464  if ((package >= 0) && (package < nr_cpus)) {
465  if (packages[package] == -1) {
466  SUBDBG("Found package %d out of total %d\n",package,num_packages);
467  packages[package]=package;
468  cpu_to_use[package]=j;
469  num_packages++;
470  }
471  } else {
472  SUBDBG("Package outside of allowed range\n");
473  strncpy(_rapl_vector.cmp_info.disabled_reason,
474  "Package outside of allowed range",PAPI_MAX_STR_LEN);
475  return PAPI_ESYS;
476  }
477 
478  j++;
479  }
480  num_cpus=j;
481 
482  if (num_packages==0) {
483  SUBDBG("Can't access /dev/cpu/*/<msr_safe | msr>\n");
484  strncpy(_rapl_vector.cmp_info.disabled_reason,
485  "Can't access /dev/cpu/*/<msr_safe | msr>",PAPI_MAX_STR_LEN);
486  return PAPI_ESYS;
487  }
488 
489  SUBDBG("Found %d packages with %d cpus\n",num_packages,num_cpus);
490 
491  /* Init fd_array */
492 
493  fd_array=papi_calloc(num_cpus, sizeof(struct fd_array_t));
494  if (fd_array==NULL) return PAPI_ENOMEM;
495 
496  fd=open_fd(cpu_to_use[0]);
497  if (fd<0) {
498  sprintf(_rapl_vector.cmp_info.disabled_reason,
499  "Can't open fd for cpu0: %s",strerror(errno));
500  return PAPI_ESYS;
501  }
502 
503  /* Verify needed MSR is readable. In a guest VM it may not be readable*/
504  if (pread(fd, &result, sizeof result, MSR_RAPL_POWER_UNIT) != sizeof result ) {
505  strncpy(_rapl_vector.cmp_info.disabled_reason,
506  "Unable to access RAPL registers",PAPI_MAX_STR_LEN);
507  return PAPI_ESYS;
508  }
509 
510  /* Calculate the units used */
511  result=read_msr(fd,MSR_RAPL_POWER_UNIT);
512 
513  /* units are 0.5^UNIT_VALUE */
514  /* which is the same as 1/(2^UNIT_VALUE) */
515 
519 
520  /* Note! On Haswell-EP DRAM energy is fixed at 15.3uJ */
521  /* see https://lkml.org/lkml/2015/3/20/582 */
522  /* Knights Landing is the same */
523  /* so is Broadwell-EP */
524  if ( different_units ) {
525  dram_energy_divisor=1<<16;
526  }
527  else {
529  }
530 
531  SUBDBG("Power units = %.3fW\n",1.0/power_divisor);
532  SUBDBG("CPU Energy units = %.8fJ\n",1.0/cpu_energy_divisor);
533  SUBDBG("DRAM Energy units = %.8fJ\n",1.0/dram_energy_divisor);
534  SUBDBG("Time units = %.8fs\n",1.0/time_divisor);
535 
536  /* Allocate space for events */
537  /* Include room for both counts and scaled values */
538 
539  num_events= ((package_avail*num_packages) +
540  (pp0_avail*num_packages) +
541  (pp1_avail*num_packages) +
542  (dram_avail*num_packages) +
543  (psys_avail*num_packages) +
544  (4*num_packages)) * 2;
545 
546  rapl_native_events = (_rapl_native_event_entry_t*)
548 
549 
550  i = 0;
551  k = num_events/2;
552 
553  /* Create events for package power info */
554 
555  for(j=0;j<num_packages;j++) {
556  sprintf(rapl_native_events[i].name,
557  "THERMAL_SPEC_CNT:PACKAGE%d",j);
558  sprintf(rapl_native_events[i].description,
559  "Thermal specification in counts; package %d",j);
560  rapl_native_events[i].fd_offset=cpu_to_use[j];
561  rapl_native_events[i].msr=MSR_PKG_POWER_INFO;
562  rapl_native_events[i].resources.selector = i + 1;
563  rapl_native_events[i].type=PACKAGE_THERMAL_CNT;
564  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
565 
566  sprintf(rapl_native_events[k].name,
567  "THERMAL_SPEC:PACKAGE%d",j);
568  strncpy(rapl_native_events[k].units,"W",PAPI_MIN_STR_LEN);
569  sprintf(rapl_native_events[k].description,
570  "Thermal specification for package %d",j);
571  rapl_native_events[k].fd_offset=cpu_to_use[j];
572  rapl_native_events[k].msr=MSR_PKG_POWER_INFO;
573  rapl_native_events[k].resources.selector = k + 1;
574  rapl_native_events[k].type=PACKAGE_THERMAL;
575  rapl_native_events[k].return_type=PAPI_DATATYPE_FP64;
576 
577  i++;
578  k++;
579  }
580 
581  for(j=0;j<num_packages;j++) {
582  sprintf(rapl_native_events[i].name,
583  "MINIMUM_POWER_CNT:PACKAGE%d",j);
584  sprintf(rapl_native_events[i].description,
585  "Minimum power in counts; package %d",j);
586  rapl_native_events[i].fd_offset=cpu_to_use[j];
587  rapl_native_events[i].msr=MSR_PKG_POWER_INFO;
588  rapl_native_events[i].resources.selector = i + 1;
589  rapl_native_events[i].type=PACKAGE_MINIMUM_CNT;
590  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
591 
592  sprintf(rapl_native_events[k].name,
593  "MINIMUM_POWER:PACKAGE%d",j);
594  strncpy(rapl_native_events[k].units,"W",PAPI_MIN_STR_LEN);
595  sprintf(rapl_native_events[k].description,
596  "Minimum power for package %d",j);
597  rapl_native_events[k].fd_offset=cpu_to_use[j];
598  rapl_native_events[k].msr=MSR_PKG_POWER_INFO;
599  rapl_native_events[k].resources.selector = k + 1;
600  rapl_native_events[k].type=PACKAGE_MINIMUM;
601  rapl_native_events[k].return_type=PAPI_DATATYPE_FP64;
602 
603  i++;
604  k++;
605  }
606 
607  for(j=0;j<num_packages;j++) {
608  sprintf(rapl_native_events[i].name,
609  "MAXIMUM_POWER_CNT:PACKAGE%d",j);
610  sprintf(rapl_native_events[i].description,
611  "Maximum power in counts; package %d",j);
612  rapl_native_events[i].fd_offset=cpu_to_use[j];
613  rapl_native_events[i].msr=MSR_PKG_POWER_INFO;
614  rapl_native_events[i].resources.selector = i + 1;
615  rapl_native_events[i].type=PACKAGE_MAXIMUM_CNT;
616  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
617 
618  sprintf(rapl_native_events[k].name,
619  "MAXIMUM_POWER:PACKAGE%d",j);
620  strncpy(rapl_native_events[k].units,"W",PAPI_MIN_STR_LEN);
621  sprintf(rapl_native_events[k].description,
622  "Maximum power for package %d",j);
623  rapl_native_events[k].fd_offset=cpu_to_use[j];
624  rapl_native_events[k].msr=MSR_PKG_POWER_INFO;
625  rapl_native_events[k].resources.selector = k + 1;
626  rapl_native_events[k].type=PACKAGE_MAXIMUM;
627  rapl_native_events[k].return_type=PAPI_DATATYPE_FP64;
628 
629  i++;
630  k++;
631  }
632 
633  for(j=0;j<num_packages;j++) {
634  sprintf(rapl_native_events[i].name,
635  "MAXIMUM_TIME_WINDOW_CNT:PACKAGE%d",j);
636  sprintf(rapl_native_events[i].description,
637  "Maximum time window in counts; package %d",j);
638  rapl_native_events[i].fd_offset=cpu_to_use[j];
639  rapl_native_events[i].msr=MSR_PKG_POWER_INFO;
640  rapl_native_events[i].resources.selector = i + 1;
641  rapl_native_events[i].type=PACKAGE_TIME_WINDOW_CNT;
642  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
643 
644  sprintf(rapl_native_events[k].name,
645  "MAXIMUM_TIME_WINDOW:PACKAGE%d",j);
646  strncpy(rapl_native_events[k].units,"s",PAPI_MIN_STR_LEN);
647  sprintf(rapl_native_events[k].description,
648  "Maximum time window for package %d",j);
649  rapl_native_events[k].fd_offset=cpu_to_use[j];
650  rapl_native_events[k].msr=MSR_PKG_POWER_INFO;
651  rapl_native_events[k].resources.selector = k + 1;
652  rapl_native_events[k].type=PACKAGE_TIME_WINDOW;
653  rapl_native_events[k].return_type=PAPI_DATATYPE_FP64;
654 
655  i++;
656  k++;
657  }
658 
659  /* Create Events for energy measurements */
660 
661  if (package_avail) {
662  for(j=0;j<num_packages;j++) {
663  sprintf(rapl_native_events[i].name,
664  "PACKAGE_ENERGY_CNT:PACKAGE%d",j);
665  sprintf(rapl_native_events[i].description,
666  "Energy used in counts by chip package %d",j);
667  rapl_native_events[i].fd_offset=cpu_to_use[j];
668  rapl_native_events[i].msr=MSR_PKG_ENERGY_STATUS;
669  rapl_native_events[i].resources.selector = i + 1;
670  rapl_native_events[i].type=PACKAGE_ENERGY_CNT;
671  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
672 
673  sprintf(rapl_native_events[k].name,
674  "PACKAGE_ENERGY:PACKAGE%d",j);
675  strncpy(rapl_native_events[k].units,"nJ",PAPI_MIN_STR_LEN);
676  sprintf(rapl_native_events[k].description,
677  "Energy used by chip package %d",j);
678  rapl_native_events[k].fd_offset=cpu_to_use[j];
679  rapl_native_events[k].msr=MSR_PKG_ENERGY_STATUS;
680  rapl_native_events[k].resources.selector = k + 1;
681  rapl_native_events[k].type=PACKAGE_ENERGY;
682  rapl_native_events[k].return_type=PAPI_DATATYPE_UINT64;
683 
684  i++;
685  k++;
686  }
687  }
688 
689  if (pp1_avail) {
690  for(j=0;j<num_packages;j++) {
691  sprintf(rapl_native_events[i].name,
692  "PP1_ENERGY_CNT:PACKAGE%d",j);
693  sprintf(rapl_native_events[i].description,
694  "Energy used in counts by Power Plane 1 (Often GPU) on package %d",j);
695  rapl_native_events[i].fd_offset=cpu_to_use[j];
696  rapl_native_events[i].msr=MSR_PP1_ENERGY_STATUS;
697  rapl_native_events[i].resources.selector = i + 1;
698  rapl_native_events[i].type=PACKAGE_ENERGY_CNT;
699  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
700 
701  sprintf(rapl_native_events[k].name,
702  "PP1_ENERGY:PACKAGE%d",j);
703  strncpy(rapl_native_events[k].units,"nJ",PAPI_MIN_STR_LEN);
704  sprintf(rapl_native_events[k].description,
705  "Energy used by Power Plane 1 (Often GPU) on package %d",j);
706  rapl_native_events[k].fd_offset=cpu_to_use[j];
707  rapl_native_events[k].msr=MSR_PP1_ENERGY_STATUS;
708  rapl_native_events[k].resources.selector = k + 1;
709  rapl_native_events[k].type=PACKAGE_ENERGY;
710  rapl_native_events[k].return_type=PAPI_DATATYPE_UINT64;
711 
712  i++;
713  k++;
714  }
715  }
716 
717  if (dram_avail) {
718  for(j=0;j<num_packages;j++) {
719  sprintf(rapl_native_events[i].name,
720  "DRAM_ENERGY_CNT:PACKAGE%d",j);
721  sprintf(rapl_native_events[i].description,
722  "Energy used in counts by DRAM on package %d",j);
723  rapl_native_events[i].fd_offset=cpu_to_use[j];
724  rapl_native_events[i].msr=MSR_DRAM_ENERGY_STATUS;
725  rapl_native_events[i].resources.selector = i + 1;
726  rapl_native_events[i].type=PACKAGE_ENERGY_CNT;
727  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
728 
729  sprintf(rapl_native_events[k].name,
730  "DRAM_ENERGY:PACKAGE%d",j);
731  strncpy(rapl_native_events[k].units,"nJ",PAPI_MIN_STR_LEN);
732  sprintf(rapl_native_events[k].description,
733  "Energy used by DRAM on package %d",j);
734  rapl_native_events[k].fd_offset=cpu_to_use[j];
735  rapl_native_events[k].msr=MSR_DRAM_ENERGY_STATUS;
736  rapl_native_events[k].resources.selector = k + 1;
737  rapl_native_events[k].type=DRAM_ENERGY;
738  rapl_native_events[k].return_type=PAPI_DATATYPE_UINT64;
739 
740  i++;
741  k++;
742  }
743  }
744 
745  if (psys_avail) {
746  for(j=0;j<num_packages;j++) {
747 
748  sprintf(rapl_native_events[i].name,
749  "PSYS_ENERGY_CNT:PACKAGE%d",j);
750  sprintf(rapl_native_events[i].description,
751  "Energy used in counts by SoC on package %d",j);
752  rapl_native_events[i].fd_offset=cpu_to_use[j];
753  rapl_native_events[i].msr=MSR_PLATFORM_ENERGY_STATUS;
754  rapl_native_events[i].resources.selector = i + 1;
755  rapl_native_events[i].type=PACKAGE_ENERGY_CNT;
756  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
757 
758  sprintf(rapl_native_events[k].name,
759  "PSYS_ENERGY:PACKAGE%d",j);
760  strncpy(rapl_native_events[k].units,"nJ",PAPI_MIN_STR_LEN);
761  sprintf(rapl_native_events[k].description,
762  "Energy used by SoC on package %d",j);
763  rapl_native_events[k].fd_offset=cpu_to_use[j];
764  rapl_native_events[k].msr=MSR_PLATFORM_ENERGY_STATUS;
765  rapl_native_events[k].resources.selector = k + 1;
766  rapl_native_events[k].type=PLATFORM_ENERGY;
767  rapl_native_events[k].return_type=PAPI_DATATYPE_UINT64;
768 
769  i++;
770  k++;
771  }
772  }
773 
774  if (pp0_avail) {
775  for(j=0;j<num_packages;j++) {
776  sprintf(rapl_native_events[i].name,
777  "PP0_ENERGY_CNT:PACKAGE%d",j);
778  sprintf(rapl_native_events[i].description,
779  "Energy used in counts by all cores in package %d",j);
780  rapl_native_events[i].fd_offset=cpu_to_use[j];
781  rapl_native_events[i].msr=MSR_PP0_ENERGY_STATUS;
782  rapl_native_events[i].resources.selector = i + 1;
783  rapl_native_events[i].type=PACKAGE_ENERGY_CNT;
784  rapl_native_events[i].return_type=PAPI_DATATYPE_UINT64;
785 
786  sprintf(rapl_native_events[k].name,
787  "PP0_ENERGY:PACKAGE%d",j);
788  strncpy(rapl_native_events[k].units,"nJ",PAPI_MIN_STR_LEN);
789  sprintf(rapl_native_events[k].description,
790  "Energy used by all cores in package %d",j);
791  rapl_native_events[k].fd_offset=cpu_to_use[j];
792  rapl_native_events[k].msr=MSR_PP0_ENERGY_STATUS;
793  rapl_native_events[k].resources.selector = k + 1;
794  rapl_native_events[k].type=PACKAGE_ENERGY;
795  rapl_native_events[k].return_type=PAPI_DATATYPE_UINT64;
796 
797  i++;
798  k++;
799  }
800  }
801 
802  /* Export the total number of events available */
803  _rapl_vector.cmp_info.num_native_events = num_events;
804 
805  _rapl_vector.cmp_info.num_cntrs = num_events;
806  _rapl_vector.cmp_info.num_mpx_cntrs = num_events;
807 
808 
809  /* Export the component id */
810  _rapl_vector.cmp_info.CmpIdx = cidx;
811 
812  return PAPI_OK;
813 }
814 
815 
816 /*
817  * Control of counters (Reading/Writing/Starting/Stopping/Setup)
818  * functions
819  */
820 static int
822 {
823 
825  int i;
826 
827  for(i=0;i<RAPL_MAX_COUNTERS;i++) {
828  control->being_measured[i]=0;
829  }
830 
831  return PAPI_OK;
832 }
833 
834 static int
836 {
837  _rapl_context_t* context = (_rapl_context_t*) ctx;
839  long long now = PAPI_get_real_usec();
840  int i;
841 
842  for( i = 0; i < RAPL_MAX_COUNTERS; i++ ) {
843  if ((control->being_measured[i]) && (control->need_difference[i])) {
844  context->start_value[i]=read_rapl_value(i);
845  }
846  }
847 
848  control->lastupdate = now;
849 
850  return PAPI_OK;
851 }
852 
853 static int
855 {
856 
857  /* read values */
858  _rapl_context_t* context = (_rapl_context_t*) ctx;
860  long long now = PAPI_get_real_usec();
861  int i;
862  long long temp;
863 
864  for ( i = 0; i < RAPL_MAX_COUNTERS; i++ ) {
865  if (control->being_measured[i]) {
866  temp = read_rapl_value(i);
867  if (context->start_value[i])
868  if (control->need_difference[i]) {
869  /* test for wrap around */
870  if (temp < context->start_value[i] ) {
871  SUBDBG("Wraparound!\nstart:\t%#016x\ttemp:\t%#016x",
872  (unsigned)context->start_value[i], (unsigned)temp);
873  temp += (0x100000000 - context->start_value[i]);
874  SUBDBG("\tresult:\t%#016x\n", (unsigned)temp);
875  } else {
876  temp -= context->start_value[i];
877  }
878  }
879  control->count[i] = convert_rapl_energy( i, temp );
880  }
881  }
882  control->lastupdate = now;
883  return PAPI_OK;
884 }
885 
886 /* Shutdown a thread */
887 static int
889 {
890  ( void ) ctx;
891  return PAPI_OK;
892 }
893 
894 int
896  long long **events, int flags)
897 {
898  (void) flags;
899 
900  _rapl_stop( ctx, ctl );
901 
902  /* Pass back a pointer to our results */
903  *events = ((_rapl_control_state_t*) ctl)->count;
904 
905  return PAPI_OK;
906 }
907 
908 
909 /*
910  * Clean up what was setup in rapl_init_component().
911  */
912 static int
914 {
915  int i;
916 
917  if (rapl_native_events) papi_free(rapl_native_events);
918  if (fd_array) {
919  for(i=0;i<num_cpus;i++) {
920  if (fd_array[i].open) close(fd_array[i].fd);
921  }
922  papi_free(fd_array);
923  }
924 
925  return PAPI_OK;
926 }
927 
928 
929 /* This function sets various options in the component
930  * The valid codes being passed in are PAPI_SET_DEFDOM,
931  * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL * and PAPI_SET_INHERIT
932  */
933 static int
934 _rapl_ctl( hwd_context_t *ctx, int code, _papi_int_option_t *option )
935 {
936  ( void ) ctx;
937  ( void ) code;
938  ( void ) option;
939 
940  return PAPI_OK;
941 }
942 
943 
944 static int
946  NativeInfo_t *native, int count,
947  hwd_context_t *ctx )
948 {
949  int i, index;
950  ( void ) ctx;
951 
953 
954  /* Ugh, what is this native[] stuff all about ?*/
955  /* Mostly remap stuff in papi_internal */
956 
957  for(i=0;i<RAPL_MAX_COUNTERS;i++) {
958  control->being_measured[i]=0;
959  }
960 
961  for( i = 0; i < count; i++ ) {
962  index=native[i].ni_event&PAPI_NATIVE_AND_MASK;
963  native[i].ni_position=rapl_native_events[index].resources.selector - 1;
964  control->being_measured[index]=1;
965 
966  /* Only need to subtract if it's a PACKAGE_ENERGY or ENERGY_CNT type */
967  control->need_difference[index]=
968  (rapl_native_events[index].type==PACKAGE_ENERGY ||
969  rapl_native_events[index].type==DRAM_ENERGY ||
970  rapl_native_events[index].type==PLATFORM_ENERGY ||
971  rapl_native_events[index].type==PACKAGE_ENERGY_CNT);
972  }
973 
974  return PAPI_OK;
975 }
976 
977 
978 /*
979  * This function has to set the bits needed to count different domains
980  * In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER
981  * By default return PAPI_EINVAL if none of those are specified
982  * and PAPI_OK with success
983  * PAPI_DOM_USER is only user context is counted
984  * PAPI_DOM_KERNEL is only the Kernel/OS context is counted
985  * PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses)
986  * PAPI_DOM_ALL is all of the domains
987  */
988 static int
990 {
991  ( void ) ctl;
992 
993  /* In theory we only support system-wide mode */
994  /* How to best handle that? */
995  if ( PAPI_DOM_ALL != domain )
996  return PAPI_EINVAL;
997 
998  return PAPI_OK;
999 }
1000 
1001 
1002 static int
1004 {
1005  ( void ) ctx;
1006  ( void ) ctl;
1007 
1008  return PAPI_OK;
1009 }
1010 
1011 
1012 /*
1013  * Native Event functions
1014  */
1015 static int
1016 _rapl_ntv_enum_events( unsigned int *EventCode, int modifier )
1017 {
1018 
1019  int index;
1020 
1021  switch ( modifier ) {
1022 
1023  case PAPI_ENUM_FIRST:
1024 
1025  if (num_events==0) {
1026  return PAPI_ENOEVNT;
1027  }
1028  *EventCode = 0;
1029 
1030  return PAPI_OK;
1031 
1032 
1033  case PAPI_ENUM_EVENTS:
1034 
1035  index = *EventCode & PAPI_NATIVE_AND_MASK;
1036 
1037  if ( index < num_events - 1 ) {
1038  *EventCode = *EventCode + 1;
1039  return PAPI_OK;
1040  } else {
1041  return PAPI_ENOEVNT;
1042  }
1043  break;
1044 
1045  default:
1046  return PAPI_EINVAL;
1047  }
1048 
1049  return PAPI_EINVAL;
1050 }
1051 
1052 /*
1053  *
1054  */
1055 static int
1056 _rapl_ntv_code_to_name( unsigned int EventCode, char *name, int len )
1057 {
1058 
1059  int index = EventCode & PAPI_NATIVE_AND_MASK;
1060 
1061  if ( index >= 0 && index < num_events ) {
1062  strncpy( name, rapl_native_events[index].name, len );
1063  return PAPI_OK;
1064  }
1065 
1066  return PAPI_ENOEVNT;
1067 }
1068 
1069 /*
1070  *
1071  */
1072 static int
1073 _rapl_ntv_code_to_descr( unsigned int EventCode, char *name, int len )
1074 {
1075  int index = EventCode;
1076 
1077  if ( index >= 0 && index < num_events ) {
1078  strncpy( name, rapl_native_events[index].description, len );
1079  return PAPI_OK;
1080  }
1081  return PAPI_ENOEVNT;
1082 }
1083 
1084 static int
1085 _rapl_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
1086 {
1087 
1088  int index = EventCode;
1089 
1090  if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
1091 
1092  strncpy( info->symbol, rapl_native_events[index].name, sizeof(info->symbol)-1);
1093  info->symbol[sizeof(info->symbol)-1] = '\0';
1094 
1095  strncpy( info->long_descr, rapl_native_events[index].description, sizeof(info->long_descr)-1);
1096  info->long_descr[sizeof(info->long_descr)-1] = '\0';
1097 
1098  strncpy( info->units, rapl_native_events[index].units, sizeof(info->units)-1);
1099  info->units[sizeof(info->units)-1] = '\0';
1100 
1101  info->data_type = rapl_native_events[index].return_type;
1102 
1103  return PAPI_OK;
1104 }
1105 
1106 
1107 
1108 papi_vector_t _rapl_vector = {
1109  .cmp_info = { /* (unspecified values are initialized to 0) */
1110  .name = "rapl",
1111  .short_name = "rapl",
1112  .description = "Linux RAPL energy measurements",
1113  .version = "5.3.0",
1114  .default_domain = PAPI_DOM_ALL,
1115  .default_granularity = PAPI_GRN_SYS,
1116  .available_granularities = PAPI_GRN_SYS,
1117  .hardware_intr_sig = PAPI_INT_SIGNAL,
1118  .available_domains = PAPI_DOM_ALL,
1119  },
1120 
1121  /* sizes of framework-opaque component-private structures */
1122  .size = {
1123  .context = sizeof ( _rapl_context_t ),
1124  .control_state = sizeof ( _rapl_control_state_t ),
1125  .reg_value = sizeof ( _rapl_register_t ),
1126  .reg_alloc = sizeof ( _rapl_reg_alloc_t ),
1127  },
1128  /* function pointers in this component */
1129  .init_thread = _rapl_init_thread,
1130  .init_component = _rapl_init_component,
1131  .init_control_state = _rapl_init_control_state,
1132  .start = _rapl_start,
1133  .stop = _rapl_stop,
1134  .read = _rapl_read,
1135  .shutdown_thread = _rapl_shutdown_thread,
1136  .shutdown_component = _rapl_shutdown_component,
1137  .ctl = _rapl_ctl,
1138 
1139  .update_control_state = _rapl_update_control_state,
1140  .set_domain = _rapl_set_domain,
1141  .reset = _rapl_reset,
1142 
1143  .ntv_enum_events = _rapl_ntv_enum_events,
1144  .ntv_code_to_name = _rapl_ntv_code_to_name,
1145  .ntv_code_to_descr = _rapl_ntv_code_to_descr,
1146  .ntv_code_to_info = _rapl_ntv_code_to_info,
1147 };
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
#define PAPI_ENOEVNT
Definition: papi.h:260
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
#define TIME_UNIT_MASK
Definition: linux-rapl.c:77
int errno
#define PACKAGE_MAXIMUM
Definition: linux-rapl.c:146
int close(int fd)
Definition: appio.c:175
static long long convert_rapl_energy(int index, long long value)
Definition: linux-rapl.c:206
_rapl_control_state_t state
Definition: linux-rapl.c:124
#define POWER_INFO_UNIT_MASK
Definition: linux-rapl.c:80
char name[PAPI_MAX_STR_LEN]
Definition: linux-rapl.c:94
static int num_events
Definition: linux-rapl.c:136
#define PLATFORM_ENERGY
Definition: linux-rapl.c:154
Hardware info structure.
Definition: papi.h:780
long long flags
Definition: iozone.c:12330
static long long read_msr(int fd, int which)
Definition: linux-rapl.c:161
#define papi_free(a)
Definition: papi_memory.h:35
#define PACKAGE_MAXIMUM_CNT
Definition: linux-rapl.c:151
#define PACKAGE_THERMAL
Definition: linux-rapl.c:144
long which
Definition: iozone.c:19600
#define PAPI_ENOSUPP
Definition: papi.h:271
off64_t offset
Definition: iozone.c:1279
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:969
static int _rapl_set_domain(hwd_control_state_t *ctl, int domain)
Definition: linux-rapl.c:989
int _rapl_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
Definition: linux-rapl.c:895
int fd
Definition: iozone.c:1291
char units[PAPI_MIN_STR_LEN]
Definition: linux-rapl.c:95
static int get_kernel_nr_cpus(void)
Definition: linux-rapl.c:271
static int num_packages
Definition: linux-rapl.c:138
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
#define PAPI_DOM_ALL
Definition: papi.h:303
#define ENERGY_UNIT_OFFSET
Definition: linux-rapl.c:73
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
char filename[MAXNAMESIZE]
Definition: iozone.c:1360
int type
Definition: linux-rapl.c:99
#define PACKAGE_ENERGY_CNT
Definition: linux-rapl.c:148
fclose(thread_wqfd)
#define DRAM_ENERGY
Definition: linux-rapl.c:153
void
Definition: iozone.c:18627
char units[MAX_EVENTS][BUFSIZ]
Definition: powercap_plot.c:15
return PAPI_EINVAL
Definition: linux-nvml.c:436
int power_divisor
Definition: linux-rapl.c:140
#define PACKAGE_TIME_WINDOW_CNT
Definition: linux-rapl.c:152
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define MSR_RAPL_POWER_UNIT
Definition: linux-rapl.c:41
#define MSR_PP1_ENERGY_STATUS
Definition: linux-rapl.c:57
static FILE * fp
void double value
Definition: iozone.c:18781
static double
Definition: fileop.c:1281
#define RAPL_MAX_COUNTERS
Definition: linux-rapl.c:110
Return codes and api definitions.
static int _rapl_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
Definition: linux-rapl.c:945
FILE * fff[MAX_EVENTS]
char events[MAX_EVENTS][BUFSIZ]
#define PACKAGE_ENERGY
Definition: linux-rapl.c:143
struct fd_array_t * fd_array
Definition: linux-rapl.c:137
static int _rapl_shutdown_thread(hwd_context_t *ctx)
Definition: linux-rapl.c:888
static int cidx
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
papi_vector_t _rapl_vector
Definition: linux-rapl.c:128
static int _rapl_shutdown_component(void)
Definition: linux-rapl.c:913
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
#define PACKAGE_MINIMUM_CNT
Definition: linux-rapl.c:150
int i
Definition: fileop.c:140
static long long read_rapl_value(int index)
Definition: linux-rapl.c:197
unsigned int selector
Definition: linux-rapl.c:89
static int _rapl_init_component(int cidx)
Definition: linux-rapl.c:307
static _rapl_native_event_entry_t * rapl_native_events
Definition: linux-rapl.c:135
int k
Definition: iozone.c:19136
static int open_fd(int offset)
Definition: linux-rapl.c:173
char description[PAPI_MAX_STR_LEN]
Definition: linux-rapl.c:96
#define PACKAGE_MINIMUM
Definition: linux-rapl.c:145
#define MSR_PP0_ENERGY_STATUS
Definition: linux-rapl.c:51
#define PAPI_ESYS
Definition: papi.h:255
int cpu_energy_divisor
Definition: linux-rapl.c:141
static int native
int cpuid_model
Definition: papi.h:793
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
long long
Definition: iozone.c:19827
#define PACKAGE_THERMAL_CNT
Definition: linux-rapl.c:149
static int _rapl_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-rapl.c:1003
#define ENERGY_UNIT_MASK
Definition: linux-rapl.c:74
#define POWER_UNIT_MASK
Definition: linux-rapl.c:71
#define PAPI_INT_SIGNAL
Definition: papi_internal.h:53
static int _rapl_init_thread(hwd_context_t *ctx)
Definition: linux-rapl.c:294
int dram_energy_divisor
Definition: linux-rapl.c:141
static int _rapl_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Definition: linux-rapl.c:934
int cpuid_family
Definition: papi.h:792
#define PAPI_ENOMEM
Definition: papi.h:254
#define PAPI_ENOIMPL
Definition: papi.h:272
#define MSR_PKG_ENERGY_STATUS
Definition: linux-rapl.c:45
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
strcpy(filename, default_filename)
_rapl_register_t ra_bits
Definition: linux-rapl.c:106
PAPI_hw_info_t hw_info
#define MSR_PLATFORM_ENERGY_STATUS
Definition: linux-rapl.c:67
Definition: linux-rapl.c:92
static int _rapl_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
Definition: linux-rapl.c:1085
#define MAXIMUM_TIME_WINDOW_SHIFT
Definition: linux-rapl.c:84
#define PAPI_VENDOR_INTEL
Definition: papi.h:348
static int num_cpus
Definition: linux-rapl.c:138
int vendor
Definition: papi.h:787
static int _rapl_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-rapl.c:854
#define THERMAL_SHIFT
Definition: linux-rapl.c:81
long long PAPI_get_real_usec(void)
Definition: papi.c:6264
char * name
Definition: iozone.c:23648
int time_divisor
Definition: linux-rapl.c:140
_rapl_register_t resources
Definition: linux-rapl.c:101
long long count[RAPL_MAX_COUNTERS]
Definition: linux-rapl.c:115
int being_measured[RAPL_MAX_COUNTERS]
Definition: linux-rapl.c:114
int return_type
Definition: linux-rapl.c:100
#define PAPI_MIN_STR_LEN
Definition: papi.h:464
int temp
Definition: iozone.c:22158
int fd_offset
Definition: linux-rapl.c:97
#define PAPI_NATIVE_AND_MASK
static int _rapl_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
Definition: linux-rapl.c:1073
#define MAXIMUM_POWER_SHIFT
Definition: linux-rapl.c:83
#define MINIMUM_POWER_SHIFT
Definition: linux-rapl.c:82
#define TIME_UNIT_OFFSET
Definition: linux-rapl.c:76
static int _rapl_init_control_state(hwd_control_state_t *ctl)
Definition: linux-rapl.c:821
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int msr
Definition: linux-rapl.c:98
static int _rapl_ntv_code_to_name(unsigned int EventCode, char *name, int len)
Definition: linux-rapl.c:1056
#define PAPI_GRN_SYS
Definition: papi.h:366
long j
Definition: iozone.c:19135
#define MSR_DRAM_ENERGY_STATUS
Definition: linux-rapl.c:62
int need_difference[RAPL_MAX_COUNTERS]
Definition: linux-rapl.c:116
#define PACKAGE_TIME_WINDOW
Definition: linux-rapl.c:147
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
static int _rapl_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-rapl.c:835
void exit()
#define POWER_UNIT_OFFSET
Definition: linux-rapl.c:70
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:975
#define MSR_PKG_POWER_INFO
Definition: linux-rapl.c:47
#define papi_calloc(a, b)
Definition: papi_memory.h:37
long long start_value[RAPL_MAX_COUNTERS]
Definition: linux-rapl.c:123
static int _rapl_ntv_enum_events(unsigned int *EventCode, int modifier)
Definition: linux-rapl.c:1016