PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-common.c File Reference
Include dependency graph for linux-common.c:

Go to the source code of this file.

Macros

#define _PATH_SYS_SYSTEM   "/sys/devices/system"
 
#define _PATH_SYS_CPU0   _PATH_SYS_SYSTEM "/cpu/cpu0"
 

Functions

static int _linux_init_locks (void)
 
int _linux_detect_hypervisor (char *virtual_vendor_name)
 
static char * search_cpu_info (FILE *f, char *search_str, char *line)
 
static void decode_vendor_string (char *s, int *vendor)
 
static FILE * xfopen (const char *path, const char *mode)
 
static FILE * path_vfopen (const char *mode, const char *path, va_list ap)
 
static int path_sibling (const char *path,...)
 
static int path_exist (const char *path,...)
 
int _linux_get_cpu_info (PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz)
 
int _linux_get_mhz (int *sys_min_mhz, int *sys_max_mhz)
 
int _linux_get_system_info (papi_mdi_t *mdi)
 
int _papi_hwi_init_os (void)
 
int _linux_detect_nmi_watchdog ()
 

Variables

PAPI_os_info_t _papi_os_info
 
volatile unsigned int _papi_hwd_lock_data [PAPI_MAX_LOCK]
 
static char pathbuf [PATH_MAX] = "/"
 
papi_os_vector_t _papi_os_vector
 

Macro Definition Documentation

#define _PATH_SYS_CPU0   _PATH_SYS_SYSTEM "/cpu/cpu0"

Definition at line 70 of file linux-common.c.

#define _PATH_SYS_SYSTEM   "/sys/devices/system"

Definition at line 69 of file linux-common.c.

Function Documentation

int _linux_detect_hypervisor ( char *  virtual_vendor_name)

Definition at line 55 of file linux-common.c.

55  {
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 }
void
Definition: iozone.c:18627
int _x86_detect_hypervisor(char *vendor_name)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int _linux_detect_nmi_watchdog ( )

Definition at line 598 of file linux-common.c.

598  {
599 
600  int watchdog_detected=0,watchdog_value=0;
601  FILE *fff;
602 
603  fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
604  if (fff!=NULL) {
605  if (fscanf(fff,"%d",&watchdog_value)==1) {
606  if (watchdog_value>0) watchdog_detected=1;
607  }
608  fclose(fff);
609  }
610 
611  return watchdog_detected;
612 }
fclose(thread_wqfd)
FILE * fff[MAX_EVENTS]

Here is the call graph for this function:

Here is the caller graph for this function:

int _linux_get_cpu_info ( PAPI_hw_info_t hwinfo,
int cpuinfo_mhz 
)

Definition at line 171 of file linux-common.c.

172 {
173  int tmp, retval = PAPI_OK;
174  unsigned int strSize;
175  char maxargs[PAPI_HUGE_STR_LEN], *t, *s;
176  float mhz = 0.0;
177  FILE *f;
178 
179  if ( ( f = fopen( "/proc/cpuinfo", "r" ) ) == NULL ) {
180  PAPIERROR( "fopen(/proc/cpuinfo) errno %d", errno );
181  return PAPI_ESYS;
182  }
183 
184  /* All of this information maybe overwritten by the component */
185 
186  /* MHZ */
187  rewind( f );
188  s = search_cpu_info( f, "clock", maxargs );
189  if ( !s ) {
190  rewind( f );
191  s = search_cpu_info( f, "cpu MHz", maxargs );
192  }
193  if ( s ) {
194  sscanf( s + 1, "%f", &mhz );
195  }
196  *cpuinfo_mhz = mhz;
197 
198  /* Vendor Name and Vendor Code */
199  rewind( f );
200  s = search_cpu_info( f, "vendor_id", maxargs );
201  strSize = sizeof(hwinfo->vendor_string);
202  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
203  *t = '\0';
204  if (strlen(s+2) >= strSize-1) s[strSize+1] = '\0';
205  strcpy( hwinfo->vendor_string, s + 2 );
206  } else {
207  rewind( f );
208  s = search_cpu_info( f, "vendor", maxargs );
209  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
210  *t = '\0';
211  if (strlen(s+2) >= strSize-1) s[strSize+1] = '\0';
212  strcpy( hwinfo->vendor_string, s + 2 );
213  } else {
214  rewind( f );
215  s = search_cpu_info( f, "system type", maxargs );
216  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
217  *t = '\0';
218  s = strtok( s + 2, " " );
219  if (strlen(s) >= strSize-1) s[strSize-1] = '\0';
220  strcpy( hwinfo->vendor_string, s );
221  } else {
222  rewind( f );
223  s = search_cpu_info( f, "platform", maxargs );
224  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
225  *t = '\0';
226  s = strtok( s + 2, " " );
227  if ( ( strcasecmp( s, "pSeries" ) == 0 ) ||
228  ( strcasecmp( s, "PowerNV" ) == 0 ) ||
229  ( strcasecmp( s, "PowerMac" ) == 0 ) ) {
230  strcpy( hwinfo->vendor_string, "IBM" );
231  }
232  } else {
233  rewind( f );
234  s = search_cpu_info( f, "CPU implementer", maxargs );
235  if ( s ) {
236  strcpy( hwinfo->vendor_string, "ARM" );
237  }
238  }
239  }
240  }
241  }
242 
243  if ( strlen( hwinfo->vendor_string ) ) {
244  decode_vendor_string( hwinfo->vendor_string, &hwinfo->vendor );
245  }
246 
247  /* Revision */
248  rewind( f );
249  s = search_cpu_info( f, "stepping", maxargs );
250  if ( s ) {
251  sscanf( s + 1, "%d", &tmp );
252  hwinfo->revision = ( float ) tmp;
253  hwinfo->cpuid_stepping = tmp;
254  } else {
255  rewind( f );
256  s = search_cpu_info( f, "revision", maxargs );
257  if ( s ) {
258  sscanf( s + 1, "%d", &tmp );
259  hwinfo->revision = ( float ) tmp;
260  hwinfo->cpuid_stepping = tmp;
261  }
262  }
263 
264  /* Model Name */
265  rewind( f );
266  s = search_cpu_info( f, "model name", maxargs );
267  strSize = sizeof(hwinfo->model_string);
268  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
269  *t = '\0';
270  if (strlen(s+2) >= strSize-1) s[strSize+1] = '\0';
271  strcpy( hwinfo->model_string, s + 2 );
272  } else {
273  rewind( f );
274  s = search_cpu_info( f, "family", maxargs );
275  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
276  *t = '\0';
277  if (strlen(s+2) >= strSize-1) s[strSize+1] = '\0';
278  strcpy( hwinfo->model_string, s + 2 );
279  } else {
280  rewind( f );
281  s = search_cpu_info( f, "cpu model", maxargs );
282  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
283  *t = '\0';
284  strtok( s + 2, " " );
285  s = strtok( NULL, " " );
286  if (strlen(s) >= strSize-1) s[strSize-1] = '\0';
287  strcpy( hwinfo->model_string, s );
288  } else {
289  rewind( f );
290  s = search_cpu_info( f, "cpu", maxargs );
291  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
292  *t = '\0';
293  /* get just the first token */
294  s = strtok( s + 2, " " );
295  if (strlen(s) >= strSize-1) s[strSize-1] = '\0';
296  strcpy( hwinfo->model_string, s );
297  }
298  }
299  }
300  }
301 
302  /* Family */
303  rewind( f );
304  s = search_cpu_info( f, "family", maxargs );
305  if ( s ) {
306  sscanf( s + 1, "%d", &tmp );
307  hwinfo->cpuid_family = tmp;
308  } else {
309  rewind( f );
310  s = search_cpu_info( f, "cpu family", maxargs );
311  if ( s ) {
312  sscanf( s + 1, "%d", &tmp );
313  hwinfo->cpuid_family = tmp;
314  }
315  }
316 
317  /* CPU Model */
318  rewind( f );
319  s = search_cpu_info( f, "model", maxargs );
320  if ( s ) {
321  sscanf( s + 1, "%d", &tmp );
322  hwinfo->model = tmp;
323  hwinfo->cpuid_model = tmp;
324  }
325 
326 
327  /* The following members are set using the same methodology */
328  /* used in lscpu. */
329 
330  /* Total number of CPUs */
331  /* The following line assumes totalcpus was initialized to zero! */
332  while ( path_exist( _PATH_SYS_SYSTEM "/cpu/cpu%d", hwinfo->totalcpus ) )
333  hwinfo->totalcpus++;
334 
335  /* Number of threads per core */
336  if ( path_exist( _PATH_SYS_CPU0 "/topology/thread_siblings" ) )
337  hwinfo->threads =
338  path_sibling( _PATH_SYS_CPU0 "/topology/thread_siblings" );
339 
340  /* Number of cores per socket */
341  if ( path_exist( _PATH_SYS_CPU0 "/topology/core_siblings" ) &&
342  hwinfo->threads > 0 )
343  hwinfo->cores =
344  path_sibling( _PATH_SYS_CPU0 "/topology/core_siblings" ) /
345  hwinfo->threads;
346 
347  /* Number of NUMA nodes */
348  /* The following line assumes nnodes was initialized to zero! */
349  while ( path_exist( _PATH_SYS_SYSTEM "/node/node%d", hwinfo->nnodes ) )
350  hwinfo->nnodes++;
351 
352  /* Number of CPUs per node */
353  hwinfo->ncpu =
354  hwinfo->nnodes >
355  1 ? hwinfo->totalcpus / hwinfo->nnodes : hwinfo->totalcpus;
356 
357  /* Number of sockets */
358  if ( hwinfo->threads > 0 && hwinfo->cores > 0 )
359  hwinfo->sockets = hwinfo->totalcpus / hwinfo->cores / hwinfo->threads;
360 
361 #if 0
362  int *nodecpu;
363  /* cpumap data is not currently part of the _papi_hw_info struct */
364  nodecpu = malloc( (unsigned int) hwinfo->nnodes * sizeof(int) );
365  if ( nodecpu ) {
366  int i;
367  for ( i = 0; i < hwinfo->nnodes; ++i ) {
368  nodecpu[i] = path_sibling(
369  _PATH_SYS_SYSTEM "/node/node%d/cpumap", i );
370  }
371  } else {
372  PAPIERROR( "malloc failed for variable not currently used" );
373  }
374 #endif
375 
376 
377  /* Fixup missing Megahertz Value */
378  /* This is missing from cpuinfo on ARM and MIPS */
379  if (*cpuinfo_mhz < 1.0) {
380  rewind( f );
381 
382  s = search_cpu_info( f, "BogoMIPS", maxargs );
383  if ((!s) || (sscanf( s + 1, "%f", &mhz ) != 1)) {
384  INTDBG("Mhz detection failed. Please edit file %s at line %d.\n",
385  __FILE__,__LINE__);
386  }
387 
388  if (hwinfo->vendor == PAPI_VENDOR_MIPS) {
389  /* MIPS has 2x clock multiplier */
390  *cpuinfo_mhz = 2*(((int)mhz)+1);
391 
392  /* Also update version info on MIPS */
393  rewind( f );
394  s = search_cpu_info( f, "cpu model", maxargs );
395  s = strstr(s+1," V")+2;
396  strtok(s," ");
397  sscanf(s, "%f ", &hwinfo->revision );
398  }
399  else {
400  /* In general bogomips is proportional to number of CPUs */
401  if (hwinfo->totalcpus) {
402  if (mhz!=0) *cpuinfo_mhz = mhz / hwinfo->totalcpus;
403  }
404  }
405  }
406 
407  fclose( f );
408 
409  return retval;
410 }
static void decode_vendor_string(char *s, int *vendor)
Definition: linux-common.c:94
int errno
int cores
Definition: papi.h:780
double f(double a)
Definition: cpi.c:23
return PAPI_OK
Definition: linux-nvml.c:458
static int path_sibling(const char *path,...)
Definition: linux-common.c:133
fclose(thread_wqfd)
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
int cpuid_stepping
Definition: papi.h:791
#define _PATH_SYS_SYSTEM
Definition: linux-common.c:69
#define INTDBG(format, args...)
Definition: papi_debug.h:65
t
Definition: iozone.c:23562
int threads
Definition: papi.h:779
#define _PATH_SYS_CPU0
Definition: linux-common.c:70
float revision
Definition: papi.h:788
int i
Definition: fileop.c:140
static int path_exist(const char *path,...)
Definition: linux-common.c:161
#define PAPI_ESYS
Definition: papi.h:253
int cpuid_model
Definition: papi.h:790
#define PAPI_VENDOR_MIPS
Definition: papi.h:353
s
Definition: iozone.c:20289
int nnodes
Definition: papi.h:782
void PAPIERROR(char *format,...)
int cpuid_family
Definition: papi.h:789
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
strcpy(filename, default_filename)
int vendor
Definition: papi.h:784
sscanf(mnc->m_child_port,"%d",&mc.m_child_port)
int model
Definition: papi.h:786
int
Definition: iozone.c:18528
int totalcpus
Definition: papi.h:783
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
static char * search_cpu_info(FILE *f, char *search_str, char *line)
Definition: linux-common.c:76
int sockets
Definition: papi.h:781
rewind(w_traj_fd)
int ncpu
Definition: papi.h:778

Here is the call graph for this function:

Here is the caller graph for this function:

int _linux_get_mhz ( int sys_min_mhz,
int sys_max_mhz 
)

Definition at line 413 of file linux-common.c.

413  {
414 
415  FILE *fff;
416  int result;
417 
418  /* Try checking for min MHz */
419  /* Assume cpu0 exists */
420  fff=fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq","r");
421  if (fff==NULL) return PAPI_EINVAL;
422  result=fscanf(fff,"%d",sys_min_mhz);
423  fclose(fff);
424  if (result!=1) return PAPI_EINVAL;
425 
426  fff=fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq","r");
427  if (fff==NULL) return PAPI_EINVAL;
428  result=fscanf(fff,"%d",sys_max_mhz);
429  fclose(fff);
430  if (result!=1) return PAPI_EINVAL;
431 
432  return PAPI_OK;
433 
434 }
return PAPI_OK
Definition: linux-nvml.c:458
fclose(thread_wqfd)
return PAPI_EINVAL
Definition: linux-nvml.c:408
FILE * fff[MAX_EVENTS]

Here is the call graph for this function:

Here is the caller graph for this function:

int _linux_get_system_info ( papi_mdi_t mdi)

Definition at line 437 of file linux-common.c.

437  {
438 
439  int retval;
440 
441  char maxargs[PAPI_HUGE_STR_LEN];
442  pid_t pid;
443 
444  int cpuinfo_mhz,sys_min_khz,sys_max_khz;
445 
446  /* Software info */
447 
448  /* Path and args */
449 
450  pid = getpid( );
451  if ( pid < 0 ) {
452  PAPIERROR( "getpid() returned < 0" );
453  return PAPI_ESYS;
454  }
455  mdi->pid = pid;
456 
457  sprintf( maxargs, "/proc/%d/exe", ( int ) pid );
458  if ( (retval = readlink( maxargs, mdi->exe_info.fullname, PAPI_HUGE_STR_LEN-1 )) < 0 ) {
459  PAPIERROR( "readlink(%s) returned < 0", maxargs );
460  return PAPI_ESYS;
461  }
462  if (retval > PAPI_HUGE_STR_LEN-1) retval=PAPI_HUGE_STR_LEN-1;
463  mdi->exe_info.fullname[retval] = '\0';
464 
465  /* Careful, basename can modify it's argument */
466 
467  strcpy( maxargs, mdi->exe_info.fullname );
468  strncpy( mdi->exe_info.address_info.name, basename( maxargs ), PAPI_HUGE_STR_LEN-1);
470 
471  SUBDBG( "Executable is %s\n", mdi->exe_info.address_info.name );
472  SUBDBG( "Full Executable is %s\n", mdi->exe_info.fullname );
473 
474  /* Executable regions, may require reading /proc/pid/maps file */
475 
476  retval = _linux_update_shlib_info( mdi );
477  SUBDBG( "Text: Start %p, End %p, length %d\n",
480  ( int ) ( mdi->exe_info.address_info.text_end -
482  SUBDBG( "Data: Start %p, End %p, length %d\n",
485  ( int ) ( mdi->exe_info.address_info.data_end -
487  SUBDBG( "Bss: Start %p, End %p, length %d\n",
490  ( int ) ( mdi->exe_info.address_info.bss_end -
492 
493  /* PAPI_preload_option information */
494 
495  strcpy( mdi->preload_info.lib_preload_env, "LD_PRELOAD" );
496  mdi->preload_info.lib_preload_sep = ' ';
497  strcpy( mdi->preload_info.lib_dir_env, "LD_LIBRARY_PATH" );
498  mdi->preload_info.lib_dir_sep = ':';
499 
500  /* Hardware info */
501 
502  retval = _linux_get_cpu_info( &mdi->hw_info, &cpuinfo_mhz );
503  if ( retval )
504  return retval;
505 
506  /* Handle MHz */
507 
508  retval = _linux_get_mhz( &sys_min_khz, &sys_max_khz );
509  if ( retval ) {
510 
511  mdi->hw_info.cpu_max_mhz=cpuinfo_mhz;
512  mdi->hw_info.cpu_min_mhz=cpuinfo_mhz;
513 
514  /*
515  mdi->hw_info.mhz=cpuinfo_mhz;
516  mdi->hw_info.clock_mhz=cpuinfo_mhz;
517  */
518  }
519  else {
520  mdi->hw_info.cpu_max_mhz=sys_max_khz/1000;
521  mdi->hw_info.cpu_min_mhz=sys_min_khz/1000;
522 
523  /*
524  mdi->hw_info.mhz=sys_max_khz/1000;
525  mdi->hw_info.clock_mhz=sys_max_khz/1000;
526  */
527  }
528 
529  /* Set Up Memory */
530 
531  retval = _linux_get_memory_info( &mdi->hw_info, mdi->hw_info.model );
532  if ( retval )
533  return retval;
534 
535  SUBDBG( "Found %d %s(%d) %s(%d) CPUs at %d Mhz.\n",
536  mdi->hw_info.totalcpus,
537  mdi->hw_info.vendor_string,
538  mdi->hw_info.vendor,
539  mdi->hw_info.model_string,
540  mdi->hw_info.model,
541  mdi->hw_info.cpu_max_mhz);
542 
543  /* Get virtualization info */
545 
546  return PAPI_OK;
547 }
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:693
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
caddr_t text_end
Definition: papi.h:695
int cpu_min_mhz
Definition: papi.h:794
return PAPI_OK
Definition: linux-nvml.c:458
caddr_t bss_start
Definition: papi.h:698
PAPI_preload_info_t preload_info
PAPI_exe_info_t exe_info
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
int _linux_get_mhz(int *sys_min_mhz, int *sys_max_mhz)
Definition: linux-common.c:413
char lib_preload_env[PAPI_MAX_STR_LEN]
Definition: papi.h:618
int _linux_update_shlib_info(papi_mdi_t *mdi)
Definition: linux-memory.c:936
int _linux_get_memory_info(PAPI_hw_info_t *hwinfo, int cpu_type)
Definition: linux-memory.c:912
static int pid
char virtual_vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:798
char lib_preload_sep
Definition: papi.h:619
caddr_t text_start
Definition: papi.h:694
PAPI_address_map_t address_info
Definition: papi.h:706
#define PAPI_ESYS
Definition: papi.h:253
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
int _linux_get_cpu_info(PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz)
Definition: linux-common.c:171
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
strcpy(filename, default_filename)
PAPI_hw_info_t hw_info
caddr_t data_start
Definition: papi.h:696
int vendor
Definition: papi.h:784
int model
Definition: papi.h:786
int cpu_max_mhz
Definition: papi.h:793
caddr_t bss_end
Definition: papi.h:699
caddr_t data_end
Definition: papi.h:697
int totalcpus
Definition: papi.h:783
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:705
int _linux_detect_hypervisor(char *virtual_vendor_name)
Definition: linux-common.c:55
int virtualized
Definition: papi.h:797
ssize_t retval
Definition: libasync.c:338
char lib_dir_sep
Definition: papi.h:621
char lib_dir_env[PAPI_MAX_STR_LEN]
Definition: papi.h:620

Here is the call graph for this function:

Here is the caller graph for this function:

static int _linux_init_locks ( void  )
static

Definition at line 38 of file linux-common.c.

38  {
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 }
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
int i
Definition: fileop.c:140
volatile unsigned int _papi_hwd_lock_data[PAPI_MAX_LOCK]
Definition: darwin-common.c:32
#define MUTEX_OPEN
Definition: perfctr-ppc64.h:75

Here is the caller graph for this function:

int _papi_hwi_init_os ( void  )

Definition at line 550 of file linux-common.c.

550  {
551 
552  int major=0,minor=0,sub=0;
553  char *ptr;
554  struct utsname uname_buffer;
555 
556  /* Initialize the locks */
558 
559  /* Get the kernel info */
560  uname(&uname_buffer);
561 
562  SUBDBG("Native kernel version %s\n",uname_buffer.release);
563 
564  strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
565 
566 #ifdef ASSUME_KERNEL
567  strncpy(_papi_os_info.version,ASSUME_KERNEL,PAPI_MAX_STR_LEN);
568  SUBDBG("Assuming kernel version %s\n",_papi_os_info.name);
569 #else
570  strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
571 #endif
572 
573  ptr=strtok(_papi_os_info.version,".");
574  if (ptr!=NULL) major=atoi(ptr);
575 
576  ptr=strtok(NULL,".");
577  if (ptr!=NULL) minor=atoi(ptr);
578 
579  ptr=strtok(NULL,".");
580  if (ptr!=NULL) sub=atoi(ptr);
581 
582  _papi_os_info.os_version=LINUX_VERSION(major,minor,sub);
583 
588  _papi_os_info.clock_ticks = sysconf( _SC_CLK_TCK );
589 
590  /* Get Linux-specific system info */
592 
593  return PAPI_OK;
594 }
int atoi()
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:65
return PAPI_OK
Definition: linux-nvml.c:458
char name[PAPI_MAX_STR_LEN]
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
char version[PAPI_MAX_STR_LEN]
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
static int _linux_init_locks(void)
Definition: linux-common.c:38
#define LINUX_VERSION(a, b, c)
Definition: linux-common.h:4
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int _linux_get_system_info(papi_mdi_t *mdi)
Definition: linux-common.c:437
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

static void decode_vendor_string ( char *  s,
int vendor 
)
static

Definition at line 94 of file linux-common.c.

95 {
96  if ( strcasecmp( s, "GenuineIntel" ) == 0 )
97  *vendor = PAPI_VENDOR_INTEL;
98  else if ( ( strcasecmp( s, "AMD" ) == 0 ) ||
99  ( strcasecmp( s, "AuthenticAMD" ) == 0 ) )
100  *vendor = PAPI_VENDOR_AMD;
101  else if ( strcasecmp( s, "IBM" ) == 0 )
102  *vendor = PAPI_VENDOR_IBM;
103  else if ( strcasecmp( s, "Cray" ) == 0 )
104  *vendor = PAPI_VENDOR_CRAY;
105  else if ( strcasecmp( s, "ARM" ) == 0 )
106  *vendor = PAPI_VENDOR_ARM;
107  else if ( strcasecmp( s, "MIPS" ) == 0 )
108  *vendor = PAPI_VENDOR_MIPS;
109  else if ( strcasecmp( s, "SiCortex" ) == 0 )
110  *vendor = PAPI_VENDOR_MIPS;
111  else
112  *vendor = PAPI_VENDOR_UNKNOWN;
113 }
#define PAPI_VENDOR_IBM
Definition: papi.h:348
#define PAPI_VENDOR_MIPS
Definition: papi.h:353
s
Definition: iozone.c:20289
#define PAPI_VENDOR_ARM
Definition: papi.h:352
#define PAPI_VENDOR_CRAY
Definition: papi.h:349
#define PAPI_VENDOR_INTEL
Definition: papi.h:346
#define PAPI_VENDOR_AMD
Definition: papi.h:347
#define PAPI_VENDOR_UNKNOWN
Definition: papi.h:345

Here is the caller graph for this function:

static int path_exist ( const char *  path,
  ... 
)
static

Definition at line 161 of file linux-common.c.

162 {
163  va_list ap;
164  va_start( ap, path );
165  vsnprintf( pathbuf, sizeof ( pathbuf ), path, ap );
166  va_end( ap );
167  return access( pathbuf, F_OK ) == 0;
168 }
static char pathbuf[PATH_MAX]
Definition: linux-common.c:72
va_start(arg_list, fmt)
va_end(arg_list)

Here is the call graph for this function:

Here is the caller graph for this function:

static int path_sibling ( const char *  path,
  ... 
)
static

Definition at line 133 of file linux-common.c.

134 {
135  int c;
136  long n;
137  int result = 0;
138  char s[2];
139  FILE *fp;
140  va_list ap;
141  va_start( ap, path );
142  fp = path_vfopen( "r", path, ap );
143  va_end( ap );
144 
145  while ( ( c = fgetc( fp ) ) != EOF ) {
146  if ( isxdigit( c ) ) {
147  s[0] = ( char ) c;
148  s[1] = '\0';
149  for ( n = strtol( s, NULL, 16 ); n > 0; n /= 2 ) {
150  if ( n % 2 )
151  result++;
152  }
153  }
154  }
155 
156  fclose( fp );
157  return result;
158 }
va_start(arg_list, fmt)
fclose(thread_wqfd)
double c
Definition: multiplex.c:22
static FILE * path_vfopen(const char *mode, const char *path, va_list ap)
Definition: linux-common.c:125
s
Definition: iozone.c:20289
static FILE * fp
va_end(arg_list)
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

static FILE* path_vfopen ( const char *  mode,
const char *  path,
va_list  ap 
)
static

Definition at line 125 of file linux-common.c.

126 {
127  vsnprintf( pathbuf, sizeof ( pathbuf ), path, ap );
128  return xfopen( pathbuf, mode );
129 }
static char pathbuf[PATH_MAX]
Definition: linux-common.c:72
static FILE * xfopen(const char *path, const char *mode)
Definition: linux-common.c:116

Here is the call graph for this function:

Here is the caller graph for this function:

static char* search_cpu_info ( FILE *  f,
char *  search_str,
char *  line 
)
static

Definition at line 76 of file linux-common.c.

77 {
78  /* This function courtesy of Rudolph Berrendorf! */
79  /* See the home page for the German version of PAPI. */
80  char *s;
81 
82  while ( fgets( line, 256, f ) != NULL ) {
83  if ( strstr( line, search_str ) != NULL ) {
84  /* ignore all characters in line up to : */
85  for ( s = line; *s && ( *s != ':' ); ++s );
86  if ( *s )
87  return s;
88  }
89  }
90  return NULL;
91 }
double f(double a)
Definition: cpi.c:23
s
Definition: iozone.c:20289

Here is the caller graph for this function:

static FILE* xfopen ( const char *  path,
const char *  mode 
)
static

Definition at line 116 of file linux-common.c.

117 {
118  FILE *fd = fopen( path, mode );
119  if ( !fd )
120  err( EXIT_FAILURE, "error: %s", path );
121  return fd;
122 }
int fd
Definition: iozone.c:1291
err
Definition: linux-cuda.c:323

Here is the caller graph for this function:

Variable Documentation

volatile unsigned int _papi_hwd_lock_data[PAPI_MAX_LOCK]

Definition at line 34 of file linux-common.c.

PAPI_os_info_t _papi_os_info

Definition at line 27 of file linux-common.c.

papi_os_vector_t _papi_os_vector

Definition at line 614 of file linux-common.c.

char pathbuf[PATH_MAX] = "/"
static

Definition at line 72 of file linux-common.c.