PAPI  5.7.0.0
linux-common.c
Go to the documentation of this file.
1 /*
2 * File: linux-common.c
3 */
4 
5 #include <unistd.h>
6 #include <string.h>
7 #include <stdlib.h>
8 #include <ctype.h>
9 #include <err.h>
10 #include <stdarg.h>
11 #include <stdio.h>
12 #include <errno.h>
13 #include <syscall.h>
14 #include <sys/utsname.h>
15 #include <sys/time.h>
16 
17 #include "papi.h"
18 #include "papi_internal.h"
19 #include "papi_vector.h"
20 
21 #include "linux-memory.h"
22 #include "linux-common.h"
23 #include "linux-timer.h"
24 
25 #include "x86_cpuid_info.h"
26 
28 
29 /* The locks used by Linux */
30 
31 #if defined(USE_PTHREAD_MUTEXES)
33 #else
34 volatile unsigned int _papi_hwd_lock_data[PAPI_MAX_LOCK];
35 #endif
36 
37 
38 static int _linux_init_locks(void) {
39 
40  int i;
41 
42  for ( i = 0; i < PAPI_MAX_LOCK; i++ ) {
43 #if defined(USE_PTHREAD_MUTEXES)
44  pthread_mutex_init(&_papi_hwd_lock_data[i],NULL);
45 #else
47 #endif
48  }
49 
50  return PAPI_OK;
51 }
52 
53 
54 int
55 _linux_detect_hypervisor(char *virtual_vendor_name) {
56 
57  int retval=0;
58 
59 #if defined(__i386__)||defined(__x86_64__)
60  retval=_x86_detect_hypervisor(virtual_vendor_name);
61 #else
62  (void) virtual_vendor_name;
63 #endif
64 
65  return retval;
66 }
67 
68 
69 #define _PATH_SYS_SYSTEM "/sys/devices/system"
70 #define _PATH_SYS_CPU0 _PATH_SYS_SYSTEM "/cpu/cpu0"
71 
72 static char pathbuf[PATH_MAX] = "/";
73 
74 static char *
75 search_cpu_info( FILE * f, char *search_str)
76 {
77  static char line[PAPI_HUGE_STR_LEN] = "";
78  char *s, *start = NULL;
79 
80  rewind(f);
81 
82  while (fgets(line,PAPI_HUGE_STR_LEN,f)!=NULL) {
83  s=strstr(line,search_str);
84  if (s!=NULL) {
85  /* skip all characters in line up to the colon */
86  /* and then spaces */
87  s=strchr(s,':');
88  if (s==NULL) break;
89  s++;
90  while (isspace(*s)) {
91  s++;
92  }
93  start = s;
94  /* Find and clear newline */
95  s=strrchr(start,'\n');
96  if (s!=NULL) *s = 0;
97  break;
98  }
99  }
100  return start;
101 }
102 
103 static void
104 decode_vendor_string( char *s, int *vendor )
105 {
106  if ( strcasecmp( s, "GenuineIntel" ) == 0 )
107  *vendor = PAPI_VENDOR_INTEL;
108  else if ( ( strcasecmp( s, "AMD" ) == 0 ) ||
109  ( strcasecmp( s, "AuthenticAMD" ) == 0 ) )
110  *vendor = PAPI_VENDOR_AMD;
111  else if ( strcasecmp( s, "IBM" ) == 0 )
112  *vendor = PAPI_VENDOR_IBM;
113  else if ( strcasecmp( s, "Cray" ) == 0 )
114  *vendor = PAPI_VENDOR_CRAY;
115  else if ( strcasecmp( s, "ARM" ) == 0 )
116  *vendor = PAPI_VENDOR_ARM;
117  else if ( strcasecmp( s, "MIPS" ) == 0 )
118  *vendor = PAPI_VENDOR_MIPS;
119  else if ( strcasecmp( s, "SiCortex" ) == 0 )
120  *vendor = PAPI_VENDOR_MIPS;
121  else
122  *vendor = PAPI_VENDOR_UNKNOWN;
123 }
124 
125 static FILE *
126 xfopen( const char *path, const char *mode )
127 {
128  FILE *fd = fopen( path, mode );
129  if ( !fd )
130  err( EXIT_FAILURE, "error: %s", path );
131  return fd;
132 }
133 
134 static FILE *
135 path_vfopen( const char *mode, const char *path, va_list ap )
136 {
137  vsnprintf( pathbuf, sizeof ( pathbuf ), path, ap );
138  return xfopen( pathbuf, mode );
139 }
140 
141 
142 static int
143 path_sibling( const char *path, ... )
144 {
145  int c;
146  long n;
147  int result = 0;
148  char s[2];
149  FILE *fp;
150  va_list ap;
151  va_start( ap, path );
152  fp = path_vfopen( "r", path, ap );
153  va_end( ap );
154 
155  while ( ( c = fgetc( fp ) ) != EOF ) {
156  if ( isxdigit( c ) ) {
157  s[0] = ( char ) c;
158  s[1] = '\0';
159  for ( n = strtol( s, NULL, 16 ); n > 0; n /= 2 ) {
160  if ( n % 2 )
161  result++;
162  }
163  }
164  }
165 
166  fclose( fp );
167  return result;
168 }
169 
170 static int
171 path_exist( const char *path, ... )
172 {
173  va_list ap;
174  va_start( ap, path );
175  vsnprintf( pathbuf, sizeof ( pathbuf ), path, ap );
176  va_end( ap );
177  return access( pathbuf, F_OK ) == 0;
178 }
179 
180 static int
182 {
183  int tmp;
184  unsigned int strSize;
185  char *s;
186 
187  /* Stepping */
188  s = search_cpu_info( f, "stepping");
189  if ( s ) {
190  if (sscanf( s, "%d", &tmp ) ==1 ) {
191  hwinfo->revision = ( float ) tmp;
192  hwinfo->cpuid_stepping = tmp;
193  }
194  }
195 
196  /* Model Name */
197  s = search_cpu_info( f, "model name");
198  strSize = sizeof(hwinfo->model_string);
199  if ( s ) {
200  strncpy( hwinfo->model_string, s, strSize);
201  }
202 
203  /* Family */
204  s = search_cpu_info( f, "cpu family");
205  if ( s ) {
206  sscanf( s, "%d", &tmp );
207  hwinfo->cpuid_family = tmp;
208  }
209 
210 
211  /* CPU Model */
212  s = search_cpu_info( f, "model");
213  if ( s ) {
214  sscanf( s , "%d", &tmp );
215  hwinfo->model = tmp;
216  hwinfo->cpuid_model = tmp;
217  }
218 
219  return PAPI_OK;
220 }
221 
222 static int
224 {
225 
226  int tmp;
227  unsigned int strSize;
228  char *s;
229 
230  /* Revision */
231  s = search_cpu_info( f, "revision");
232  if ( s ) {
233  sscanf( s, "%d", &tmp );
234  hwinfo->revision = ( float ) tmp;
235  hwinfo->cpuid_stepping = tmp;
236  }
237 
238  /* Model Name */
239  s = search_cpu_info( f, "model");
240  strSize = sizeof(hwinfo->model_string);
241  if ( s ) {
242  strncpy( hwinfo->model_string, s, strSize);
243  }
244 
245  return PAPI_OK;
246 }
247 
248 
249 
250 static int
252 {
253 
254  int tmp;
255  unsigned int strSize;
256  char *s, *t;
257 
258  /* revision */
259  s = search_cpu_info( f, "CPU revision");
260  if ( s ) {
261  sscanf( s, "%d", &tmp );
262  hwinfo->revision = ( float ) tmp;
263  /* For compatability with old PAPI */
264  hwinfo->model = tmp;
265  }
266 
267  /* Model Name */
268  s = search_cpu_info( f, "model name");
269  strSize = sizeof(hwinfo->model_string);
270  if ( s ) {
271  strncpy( hwinfo->model_string, s, strSize );
272  }
273 
274  /* Architecture (ARMv6, ARMv7, ARMv8, etc.) */
275 
276  /* Parsing this is a bit fragile. */
277  /* On ARM64 the "CPU architecture field" */
278  /* Prior to Linux 3.19: always "AArch64" */
279  /* Since Linux 3.19: always "8" */
280  /* On ARM32 the "CPU architecture field" is a value and not */
281  /* necessarily an integer, so it might be 7 or 7M */
282  /* also, unknown architectures are assigned a value */
283  /* such as (10) where 10 does not mean version 10, just */
284  /* the 10th element in an array */
285  /* Note the original Raspberry Pi lies in the CPU architecture line */
286  /* (it's ARMv6 not ARMv7) */
287  /* So we should actually get the value from the */
288  /* Processor/ model name line */
289 
290 
291  s = search_cpu_info( f, "CPU architecture");
292  if ( s ) {
293 
294  /* Handle old (prior to Linux 3.19) ARM64 */
295  if (strstr(s,"AArch64")) {
296  hwinfo->cpuid_family = 8;
297  }
298  else {
299  hwinfo->cpuid_family=strtol(s, NULL, 10);
300  }
301 
302  /* Old Fallbacks if the above didn't work */
303  if (hwinfo->cpuid_family<0) {
304 
305  /* Try the processor field and look inside of parens */
306  s = search_cpu_info( f, "Processor" );
307  if (s) {
308  t=strchr(s,'(');
309  tmp=*(t+2)-'0';
310  hwinfo->cpuid_family = tmp;
311  }
312  /* Try the model name and look inside of parens */
313  else {
314  s = search_cpu_info( f, "model name" );
315  if (s) {
316  t=strchr(s,'(');
317  tmp=*(t+2)-'0';
318  hwinfo->cpuid_family = tmp;
319  }
320  }
321  }
322  }
323 
324  /* CPU Model */
325  s = search_cpu_info( f, "CPU part" );
326  if ( s ) {
327  sscanf( s, "%x", &tmp );
328  hwinfo->cpuid_model = tmp;
329  }
330 
331  /* CPU Variant */
332  s = search_cpu_info( f, "CPU variant" );
333  if ( s ) {
334  sscanf( s, "%x", &tmp );
335  hwinfo->cpuid_stepping = tmp;
336  }
337 
338  return PAPI_OK;
339 
340 }
341 
342 
343 int
344 _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
345 {
346  int retval = PAPI_OK;
347  char *s;
348  float mhz = 0.0;
349  FILE *f;
350  char cpuinfo_filename[]="/proc/cpuinfo";
351 
352  if ( ( f = fopen( cpuinfo_filename, "r" ) ) == NULL ) {
353  PAPIERROR( "fopen(/proc/cpuinfo) errno %d", errno );
354  return PAPI_ESYS;
355  }
356 
357  /* All of this information may be overwritten by the component */
358 
359  /***********************/
360  /* Attempt to find MHz */
361  /***********************/
362  s = search_cpu_info( f, "cpu MHz" );
363  if ( !s ) {
364  s = search_cpu_info( f, "clock" );
365  }
366  if ( s ) {
367  sscanf( s, "%f", &mhz );
368  *cpuinfo_mhz = mhz;
369  }
370  else {
371  // PAPIWARN("Failed to find a clock speed in /proc/cpuinfo");
372  }
373 
374  /*******************************/
375  /* Vendor Name and Vendor Code */
376  /*******************************/
377 
378  /* First try to read "vendor_id" field */
379  /* Which is the most common field */
380  s = search_cpu_info( f, "vendor_id");
381  if ( s ) {
382  strcpy( hwinfo->vendor_string, s );
383  }
384  else {
385  /* If not found, try "vendor" which seems to be Itanium specific */
386  s = search_cpu_info( f, "vendor" );
387  if ( s ) {
388  strcpy( hwinfo->vendor_string, s );
389  }
390  else {
391  /* "system type" seems to be MIPS and Alpha */
392  s = search_cpu_info( f, "system type");
393  if ( s ) {
394  strcpy( hwinfo->vendor_string, s );
395  }
396  else {
397  /* "platform" indicates Power */
398  s = search_cpu_info( f, "platform");
399  if ( s ) {
400  if ( ( strcasecmp( s, "pSeries" ) == 0 ) ||
401  ( strcasecmp( s, "PowerNV" ) == 0 ) ||
402  ( strcasecmp( s, "PowerMac" ) == 0 ) ) {
403  strcpy( hwinfo->vendor_string, "IBM" );
404  }
405  }
406  else {
407  /* "CPU implementer" indicates ARM */
408  s = search_cpu_info( f, "CPU implementer");
409  if ( s ) {
410  strcpy( hwinfo->vendor_string, "ARM" );
411  }
412  }
413  }
414  }
415  }
416 
417  /* Decode the string to a PAPI specific implementer value */
418  if ( strlen( hwinfo->vendor_string ) ) {
419  decode_vendor_string( hwinfo->vendor_string, &hwinfo->vendor );
420  }
421 
422  /**********************************************/
423  /* Provide more stepping/model/family numbers */
424  /**********************************************/
425 
426  if ((hwinfo->vendor==PAPI_VENDOR_INTEL) ||
427  (hwinfo->vendor==PAPI_VENDOR_AMD)) {
428 
429  decode_cpuinfo_x86(f,hwinfo);
430  }
431 
432  if (hwinfo->vendor==PAPI_VENDOR_IBM) {
433 
434  decode_cpuinfo_power(f,hwinfo);
435  }
436 
437  if (hwinfo->vendor==PAPI_VENDOR_ARM) {
438 
439  decode_cpuinfo_arm(f,hwinfo);
440  }
441 
442 
443 
444 
445  /* The following members are set using the same methodology */
446  /* used in lscpu. */
447 
448  /* Total number of CPUs */
449  /* The following line assumes totalcpus was initialized to zero! */
450  while ( path_exist( _PATH_SYS_SYSTEM "/cpu/cpu%d", hwinfo->totalcpus ) )
451  hwinfo->totalcpus++;
452 
453  /* Number of threads per core */
454  if ( path_exist( _PATH_SYS_CPU0 "/topology/thread_siblings" ) )
455  hwinfo->threads =
456  path_sibling( _PATH_SYS_CPU0 "/topology/thread_siblings" );
457 
458  /* Number of cores per socket */
459  if ( path_exist( _PATH_SYS_CPU0 "/topology/core_siblings" ) &&
460  hwinfo->threads > 0 )
461  hwinfo->cores =
462  path_sibling( _PATH_SYS_CPU0 "/topology/core_siblings" ) /
463  hwinfo->threads;
464 
465  /* Number of NUMA nodes */
466  /* The following line assumes nnodes was initialized to zero! */
467  while ( path_exist( _PATH_SYS_SYSTEM "/node/node%d", hwinfo->nnodes ) ) {
468  hwinfo->nnodes++;
469  }
470 
471  /* Number of CPUs per node */
472  hwinfo->ncpu = hwinfo->nnodes > 1 ?
473  hwinfo->totalcpus / hwinfo->nnodes : hwinfo->totalcpus;
474 
475  /* Number of sockets */
476  if ( hwinfo->threads > 0 && hwinfo->cores > 0 ) {
477  hwinfo->sockets = hwinfo->totalcpus / hwinfo->cores / hwinfo->threads;
478  }
479 
480 #if 0
481  int *nodecpu;
482  /* cpumap data is not currently part of the _papi_hw_info struct */
483  nodecpu = malloc( (unsigned int) hwinfo->nnodes * sizeof(int) );
484  if ( nodecpu ) {
485  int i;
486  for ( i = 0; i < hwinfo->nnodes; ++i ) {
487  nodecpu[i] = path_sibling(
488  _PATH_SYS_SYSTEM "/node/node%d/cpumap", i );
489  }
490  } else {
491  PAPIERROR( "malloc failed for variable not currently used" );
492  }
493 #endif
494 
495 
496  /* Fixup missing Megahertz Value */
497  /* This is missing from cpuinfo on ARM and MIPS */
498  if (*cpuinfo_mhz < 1.0) {
499  s = search_cpu_info( f, "BogoMIPS" );
500  if ((!s) || (sscanf( s, "%f", &mhz ) != 1)) {
501  INTDBG("MHz detection failed. "
502  "Please edit file %s at line %d.\n",
503  __FILE__,__LINE__);
504  }
505 
506  if (hwinfo->vendor == PAPI_VENDOR_MIPS) {
507  /* MIPS has 2x clock multiplier */
508  *cpuinfo_mhz = 2*(((int)mhz)+1);
509 
510  /* Also update version info on MIPS */
511  s = search_cpu_info( f, "cpu model");
512  s = strstr(s," V")+2;
513  strtok(s," ");
514  sscanf(s, "%f ", &hwinfo->revision );
515  }
516  else {
517  /* In general bogomips is proportional to number of CPUs */
518  if (hwinfo->totalcpus) {
519  if (mhz!=0) *cpuinfo_mhz = mhz / hwinfo->totalcpus;
520  }
521  }
522  }
523 
524  fclose( f );
525 
526  return retval;
527 }
528 
529 int
530 _linux_get_mhz( int *sys_min_mhz, int *sys_max_mhz ) {
531 
532  FILE *fff;
533  int result;
534 
535  /* Try checking for min MHz */
536  /* Assume cpu0 exists */
537  fff=fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq","r");
538  if (fff==NULL) return PAPI_EINVAL;
539  result=fscanf(fff,"%d",sys_min_mhz);
540  fclose(fff);
541  if (result!=1) return PAPI_EINVAL;
542 
543  fff=fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq","r");
544  if (fff==NULL) return PAPI_EINVAL;
545  result=fscanf(fff,"%d",sys_max_mhz);
546  fclose(fff);
547  if (result!=1) return PAPI_EINVAL;
548 
549  return PAPI_OK;
550 
551 }
552 
553 int
555 
556  int retval;
557  char maxargs[PAPI_HUGE_STR_LEN];
558  pid_t pid;
559  int cpuinfo_mhz,sys_min_khz,sys_max_khz;
560 
561  /* Software info */
562 
563  /* Path and args */
564 
565  pid = getpid( );
566  if ( pid < 0 ) {
567  PAPIERROR( "getpid() returned < 0" );
568  return PAPI_ESYS;
569  }
570  mdi->pid = pid;
571 
572  sprintf( maxargs, "/proc/%d/exe", ( int ) pid );
573  retval = readlink( maxargs, mdi->exe_info.fullname,
574  PAPI_HUGE_STR_LEN-1 );
575  if ( retval < 0 ) {
576  PAPIERROR( "readlink(%s) returned < 0", maxargs );
577  return PAPI_ESYS;
578  }
579 
580  if (retval > PAPI_HUGE_STR_LEN-1) {
582  }
583  mdi->exe_info.fullname[retval] = '\0';
584 
585  /* Careful, basename can modify its argument */
586  strcpy( maxargs, mdi->exe_info.fullname );
587 
588  strncpy( mdi->exe_info.address_info.name, basename( maxargs ),
591 
592  SUBDBG( "Executable is %s\n", mdi->exe_info.address_info.name );
593  SUBDBG( "Full Executable is %s\n", mdi->exe_info.fullname );
594 
595  /* Executable regions, may require reading /proc/pid/maps file */
596 
598  SUBDBG( "Text: Start %p, End %p, length %d\n",
601  ( int ) ( mdi->exe_info.address_info.text_end -
603  SUBDBG( "Data: Start %p, End %p, length %d\n",
606  ( int ) ( mdi->exe_info.address_info.data_end -
608  SUBDBG( "Bss: Start %p, End %p, length %d\n",
611  ( int ) ( mdi->exe_info.address_info.bss_end -
613 
614  /* PAPI_preload_option information */
615 
616  strcpy( mdi->preload_info.lib_preload_env, "LD_PRELOAD" );
617  mdi->preload_info.lib_preload_sep = ' ';
618  strcpy( mdi->preload_info.lib_dir_env, "LD_LIBRARY_PATH" );
619  mdi->preload_info.lib_dir_sep = ':';
620 
621  /* Hardware info */
622 
623  retval = _linux_get_cpu_info( &mdi->hw_info, &cpuinfo_mhz );
624  if ( retval )
625  return retval;
626 
627  /* Handle MHz */
628 
629  retval = _linux_get_mhz( &sys_min_khz, &sys_max_khz );
630  if ( retval ) {
631 
632  mdi->hw_info.cpu_max_mhz=cpuinfo_mhz;
633  mdi->hw_info.cpu_min_mhz=cpuinfo_mhz;
634 
635  /*
636  mdi->hw_info.mhz=cpuinfo_mhz;
637  mdi->hw_info.clock_mhz=cpuinfo_mhz;
638  */
639  }
640  else {
641  mdi->hw_info.cpu_max_mhz=sys_max_khz/1000;
642  mdi->hw_info.cpu_min_mhz=sys_min_khz/1000;
643 
644  /*
645  mdi->hw_info.mhz=sys_max_khz/1000;
646  mdi->hw_info.clock_mhz=sys_max_khz/1000;
647  */
648  }
649 
650  /* Set Up Memory */
651 
653  if ( retval )
654  return retval;
655 
656  SUBDBG( "Found %d %s(%d) %s(%d) CPUs at %d Mhz.\n",
657  mdi->hw_info.totalcpus,
658  mdi->hw_info.vendor_string,
659  mdi->hw_info.vendor,
660  mdi->hw_info.model_string,
661  mdi->hw_info.model,
662  mdi->hw_info.cpu_max_mhz);
663 
664  /* Get virtualization info */
666 
667  return PAPI_OK;
668 }
669 
670 int
672 
673  int major=0,minor=0,sub=0;
674  char *ptr;
675  struct utsname uname_buffer;
676 
677  /* Initialize the locks */
679 
680  /* Get the kernel info */
681  uname(&uname_buffer);
682 
683  SUBDBG("Native kernel version %s\n",uname_buffer.release);
684 
685  strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
686 
687 #ifdef ASSUME_KERNEL
688  strncpy(_papi_os_info.version,ASSUME_KERNEL,PAPI_MAX_STR_LEN);
689  SUBDBG("Assuming kernel version %s\n",_papi_os_info.name);
690 #else
691  strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
692 #endif
693 
694  ptr=strtok(_papi_os_info.version,".");
695  if (ptr!=NULL) major=atoi(ptr);
696 
697  ptr=strtok(NULL,".");
698  if (ptr!=NULL) minor=atoi(ptr);
699 
700  ptr=strtok(NULL,".");
701  if (ptr!=NULL) sub=atoi(ptr);
702 
703  _papi_os_info.os_version=LINUX_VERSION(major,minor,sub);
704 
709  _papi_os_info.clock_ticks = sysconf( _SC_CLK_TCK );
710 
711  /* Get Linux-specific system info */
713 
714  return PAPI_OK;
715 }
716 
717 
718 
720 
721  int watchdog_detected=0,watchdog_value=0;
722  FILE *fff;
723 
724  fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
725  if (fff!=NULL) {
726  if (fscanf(fff,"%d",&watchdog_value)==1) {
727  if (watchdog_value>0) watchdog_detected=1;
728  }
729  fclose(fff);
730  }
731 
732  return watchdog_detected;
733 }
734 
737  .get_dmem_info = _linux_get_dmem_info,
738  .get_real_cycles = _linux_get_real_cycles,
739  .update_shlib_info = _linux_update_shlib_info,
740  .get_system_info = _linux_get_system_info,
741 
742 
743 #if defined(HAVE_CLOCK_GETTIME)
744  .get_real_usec = _linux_get_real_usec_gettime,
745 #elif defined(HAVE_GETTIMEOFDAY)
746  .get_real_usec = _linux_get_real_usec_gettimeofday,
747 #else
748  .get_real_usec = _linux_get_real_usec_cycles,
749 #endif
750 
751 
752 #if defined(USE_PROC_PTTIMER)
753  .get_virt_usec = _linux_get_virt_usec_pttimer,
754 #elif defined(HAVE_CLOCK_GETTIME_THREAD)
755  .get_virt_usec = _linux_get_virt_usec_gettime,
756 #elif defined(HAVE_PER_THREAD_TIMES)
757  .get_virt_usec = _linux_get_virt_usec_times,
758 #elif defined(HAVE_PER_THREAD_GETRUSAGE)
759  .get_virt_usec = _linux_get_virt_usec_rusage,
760 #endif
761 
762 
763 #if defined(HAVE_CLOCK_GETTIME)
764  .get_real_nsec = _linux_get_real_nsec_gettime,
765 #endif
766 
767 #if defined(HAVE_CLOCK_GETTIME_THREAD)
768  .get_virt_nsec = _linux_get_virt_nsec_gettime,
769 #endif
770 
771 
772 };
#define PAPI_OK
Definition: fpapi.h:105
int atoi()
static void decode_vendor_string(char *s, int *vendor)
Definition: linux-common.c:104
long long _linux_get_real_cycles(void)
Definition: linux-timer.c:302
int errno
int cores
Definition: papi.h:784
double f(double a)
Definition: cpi.c:23
static int decode_cpuinfo_power(FILE *f, PAPI_hw_info_t *hwinfo)
Definition: linux-common.c:223
static char * search_cpu_info(FILE *f, char *search_str)
Definition: linux-common.c:75
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:65
long long _linux_get_virt_usec_gettime(void)
Definition: linux-timer.c:433
#define PAPI_EINVAL
Definition: fpapi.h:106
Hardware info structure.
Definition: papi.h:781
int _papi_hwi_init_os(void)
Definition: linux-common.c:671
caddr_t text_end
Definition: papi.h:699
int cpu_min_mhz
Definition: papi.h:798
int fd
Definition: iozone.c:1291
static char pathbuf[PATH_MAX]
Definition: linux-common.c:72
va_start(arg_list, fmt)
static int path_sibling(const char *path,...)
Definition: linux-common.c:143
caddr_t bss_start
Definition: papi.h:702
PAPI_preload_info_t preload_info
PAPI_exe_info_t exe_info
int retval
Definition: zero_fork.c:53
static struct timeval start
static FILE * fp
double c
Definition: multiplex.c:22
int _linux_get_mhz(int *sys_min_mhz, int *sys_max_mhz)
Definition: linux-common.c:530
double tmp
Return codes and api definitions.
FILE * fff[MAX_EVENTS]
int cpuid_stepping
Definition: papi.h:795
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
#define _PATH_SYS_SYSTEM
Definition: linux-common.c:69
char name[PAPI_MAX_STR_LEN]
long long _linux_get_real_nsec_gettime(void)
Definition: linux-timer.c:523
#define INTDBG(format, args...)
Definition: papi_debug.h:65
#define PAPI_ESYS
Definition: fpapi.h:108
int _linux_update_shlib_info(papi_mdi_t *mdi)
int threads
Definition: papi.h:783
#define _PATH_SYS_CPU0
Definition: linux-common.c:70
float revision
Definition: papi.h:792
papi_os_vector_t _papi_os_vector
Definition: linux-common.c:735
static int path_exist(const char *path,...)
Definition: linux-common.c:171
static FILE * path_vfopen(const char *mode, const char *path, va_list ap)
Definition: linux-common.c:135
int _linux_get_memory_info(PAPI_hw_info_t *hwinfo, int cpu_type)
#define PAPI_VENDOR_IBM
Definition: papi.h:351
static int pid
char lib_preload_sep
Definition: papi.h:623
caddr_t text_start
Definition: papi.h:698
static FILE * xfopen(const char *path, const char *mode)
Definition: linux-common.c:126
PAPI_address_map_t address_info
Definition: papi.h:710
long long _linux_get_real_usec_cycles(void)
Definition: linux-timer.c:367
#define PAPI_HUGE_STR_LEN
Definition: fpapi.h:42
volatile unsigned int _papi_hwd_lock_data[PAPI_MAX_LOCK]
Definition: linux-common.c:34
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:791
int cpuid_model
Definition: papi.h:794
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
#define PAPI_VENDOR_MIPS
Definition: papi.h:356
int nnodes
Definition: papi.h:786
void PAPIERROR(char *format,...)
int _linux_get_dmem_info(PAPI_dmem_info_t *d)
Definition: linux-memory.c:48
char version[PAPI_MAX_STR_LEN]
double s
Definition: byte_profile.c:36
#define PAPI_VENDOR_ARM
Definition: papi.h:355
long long _linux_get_virt_usec_times(void)
Definition: linux-timer.c:409
int cpuid_family
Definition: papi.h:793
PAPI_os_info_t _papi_os_info
Definition: linux-common.c:27
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
int _linux_get_cpu_info(PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz)
Definition: linux-common.c:344
static int decode_cpuinfo_x86(FILE *f, PAPI_hw_info_t *hwinfo)
Definition: linux-common.c:181
#define PAPI_VENDOR_CRAY
Definition: papi.h:352
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
PAPI_hw_info_t hw_info
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:789
static int _linux_init_locks(void)
Definition: linux-common.c:38
#define PAPI_VENDOR_INTEL
Definition: papi.h:349
caddr_t data_start
Definition: papi.h:700
int _x86_detect_hypervisor(char *vendor_name)
va_end(arg_list)
#define LINUX_VERSION(a, b, c)
Definition: linux-common.h:4
int vendor
Definition: papi.h:788
#define MUTEX_OPEN
Definition: perfctr-ppc64.h:75
#define PATH_MAX
Definition: fileop.c:68
int model
Definition: papi.h:790
long long _linux_get_real_usec_gettime(void)
Definition: linux-timer.c:330
int cpu_max_mhz
Definition: papi.h:797
long long _linux_get_virt_usec_pttimer(void)
Definition: linux-timer.c:452
caddr_t bss_end
Definition: papi.h:703
static int decode_cpuinfo_arm(FILE *f, PAPI_hw_info_t *hwinfo)
Definition: linux-common.c:251
caddr_t data_end
Definition: papi.h:701
char lib_dir_env[PAPI_MAX_STR_LEN]
Definition: papi.h:624
int(* get_memory_info)(PAPI_hw_info_t *, int)
Definition: papi_vector.h:69
int totalcpus
Definition: papi.h:787
int _linux_detect_nmi_watchdog()
Definition: linux-common.c:719
long long _linux_get_virt_nsec_gettime(void)
Definition: linux-timer.c:546
int _linux_detect_hypervisor(char *virtual_vendor_name)
Definition: linux-common.c:55
char virtual_vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:802
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:709
int virtualized
Definition: papi.h:801
char lib_preload_env[PAPI_MAX_STR_LEN]
Definition: papi.h:622
char lib_dir_sep
Definition: papi.h:625
long long _linux_get_virt_usec_rusage(void)
Definition: linux-timer.c:387
int _linux_get_system_info(papi_mdi_t *mdi)
Definition: linux-common.c:554
int sockets
Definition: papi.h:785
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:697
long long _linux_get_real_usec_gettimeofday(void)
Definition: linux-timer.c:352
#define PAPI_VENDOR_AMD
Definition: papi.h:350
int i
Definition: fileop.c:140
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int ncpu
Definition: papi.h:782
#define PAPI_VENDOR_UNKNOWN
Definition: papi.h:348