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

Go to the source code of this file.

Functions

int mmtimer_setup (void)
 
long long _linux_get_real_cycles (void)
 
long long _linux_get_real_usec_gettime (void)
 
long long _linux_get_real_usec_gettimeofday (void)
 
long long _linux_get_real_usec_cycles (void)
 
long long _linux_get_virt_usec_rusage (void)
 
long long _linux_get_virt_usec_times (void)
 
long long _linux_get_virt_usec_gettime (void)
 
long long _linux_get_virt_usec_pttimer (void)
 
long long _linux_get_real_nsec_gettime (void)
 
long long _linux_get_virt_nsec_gettime (void)
 

Function Documentation

long long _linux_get_real_cycles ( void  )

Definition at line 302 of file linux-timer.c.

303 {
304  long long retval;
305 #if defined(HAVE_GETTIMEOFDAY)||defined(__arm__)||defined(__mips__)
306 
307  /* Crude estimate, not accurate in prescence of DVFS */
308 
309  retval = _papi_os_vector.get_real_usec( ) *
311 #else
312  retval = get_cycles( );
313 #endif
314  return retval;
315 }
long long(* get_real_usec)(void)
Definition: papi_vector.h:63
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
long long
Definition: iozone.c:19827
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
PAPI_hw_info_t hw_info
#define get_cycles
Definition: linux-bgq.c:48
int cpu_max_mhz
Definition: papi.h:796
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_nsec_gettime ( void  )

Definition at line 523 of file linux-timer.c.

524 {
525 
526  long long retval;
527 
528  struct timespec foo;
529 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
530  syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
531 #else
532  syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
533 #endif
534  retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
535  retval += ( long long ) ( foo.tv_nsec );
536 
537  return retval;
538 }
pthread_attr_t foo
Definition: iozone.c:18592
long long
Definition: iozone.c:19827
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_usec_cycles ( void  )

Definition at line 367 of file linux-timer.c.

368 {
369 
370  long long retval;
371 
372  /* Not accurate in the prescence of DVFS */
373 
374  retval = get_cycles( ) /
376 
377  return retval;
378 }
long long
Definition: iozone.c:19827
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
PAPI_hw_info_t hw_info
#define get_cycles
Definition: linux-bgq.c:48
int cpu_max_mhz
Definition: papi.h:796
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_usec_gettime ( void  )

Definition at line 330 of file linux-timer.c.

331 {
332 
333  long long retval;
334 
335  struct timespec foo;
336 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
337  syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
338 #else
339  syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
340 #endif
341  retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
342  retval += ( long long ) ( foo.tv_nsec / 1000 );
343 
344  return retval;
345 }
pthread_attr_t foo
Definition: iozone.c:18592
long long
Definition: iozone.c:19827
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_usec_gettimeofday ( void  )

Definition at line 352 of file linux-timer.c.

353 {
354 
355  long long retval;
356 
357  struct timeval buffer;
358  gettimeofday( &buffer, NULL );
359  retval = ( long long ) buffer.tv_sec * ( long long ) 1000000;
360  retval += ( long long ) ( buffer.tv_usec );
361 
362  return retval;
363 }
long long
Definition: iozone.c:19827
char * buffer
Definition: iozone.c:1366
int gettimeofday(void *ptr1, void *ptr2)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

long long _linux_get_virt_nsec_gettime ( void  )

Definition at line 546 of file linux-timer.c.

547 {
548 
549  long long retval;
550 
551  struct timespec foo;
552 
553  syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
554  retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
555  retval += ( long long ) foo.tv_nsec ;
556 
557  return retval;
558 }
pthread_attr_t foo
Definition: iozone.c:18592
long long
Definition: iozone.c:19827
ssize_t retval
Definition: libasync.c:338
long long _linux_get_virt_usec_gettime ( void  )

Definition at line 433 of file linux-timer.c.

434 {
435 
436  long long retval;
437 
438  struct timespec foo;
439 
440  syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
441  retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
442  retval += ( long long ) foo.tv_nsec / 1000;
443 
444  return retval;
445 }
pthread_attr_t foo
Definition: iozone.c:18592
long long
Definition: iozone.c:19827
ssize_t retval
Definition: libasync.c:338
long long _linux_get_virt_usec_pttimer ( void  )

Definition at line 452 of file linux-timer.c.

453 {
454 
455  long long retval;
456  char buf[LINE_MAX];
457  long long utime, stime;
458  int rv, cnt = 0, i = 0;
459  int stat_fd;
460 
461 
462 again:
463  sprintf( buf, "/proc/%d/task/%d/stat", getpid( ), mygettid( ) );
464  stat_fd = open( buf, O_RDONLY );
465  if ( stat_fd == -1 ) {
466  PAPIERROR( "open(%s)", buf );
467  return PAPI_ESYS;
468  }
469 
470  rv = read( stat_fd, buf, LINE_MAX * sizeof ( char ) );
471  if ( rv == -1 ) {
472  if ( errno == EBADF ) {
473  close(stat_fd);
474  goto again;
475  }
476  PAPIERROR( "read()" );
477  close(stat_fd);
478  return PAPI_ESYS;
479  }
480  lseek( stat_fd, 0, SEEK_SET );
481 
482  if (rv == LINE_MAX) rv--;
483  buf[rv] = '\0';
484  SUBDBG( "Thread stat file is:%s\n", buf );
485  while ( ( cnt != 13 ) && ( i < rv ) ) {
486  if ( buf[i] == ' ' ) {
487  cnt++;
488  }
489  i++;
490  }
491 
492  if ( cnt != 13 ) {
493  PAPIERROR( "utime and stime not in thread stat file?" );
494  close(stat_fd);
495  return PAPI_ESYS;
496  }
497 
498  if ( sscanf( buf + i, "%llu %llu", &utime, &stime ) != 2 ) {
499  close(stat_fd);
500  PAPIERROR("Unable to scan two items from thread stat file at 13th space?");
501  return PAPI_ESYS;
502  }
503 
504  retval = ( utime + stime ) * ( long long ) 1000000 /_papi_os_info.clock_ticks;
505 
506  close(stat_fd);
507 
508  return retval;
509 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
int errno
int close(int fd)
Definition: appio.c:175
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:210
static pid_t mygettid(void)
Definition: darwin-common.h:11
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_ESYS
Definition: papi.h:255
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
sscanf(mnc->m_child_port,"%d",&mc.m_child_port)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

long long _linux_get_virt_usec_rusage ( void  )

Definition at line 387 of file linux-timer.c.

388 {
389 
390  long long retval;
391 
392  struct rusage buffer;
393 
394  getrusage( RUSAGE_SELF, &buffer );
395  SUBDBG( "user %d system %d\n", ( int ) buffer.ru_utime.tv_sec,
396  ( int ) buffer.ru_stime.tv_sec );
397  retval = ( long long ) ( buffer.ru_utime.tv_sec + buffer.ru_stime.tv_sec )
398  * ( long long ) 1000000;
399  retval += (long long) ( buffer.ru_utime.tv_usec + buffer.ru_stime.tv_usec );
400 
401  return retval;
402 }
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
long long
Definition: iozone.c:19827
char * buffer
Definition: iozone.c:1366
ssize_t retval
Definition: libasync.c:338
long long _linux_get_virt_usec_times ( void  )

Definition at line 409 of file linux-timer.c.

410 {
411 
412  long long retval;
413 
414  struct tms buffer;
415 
416  times( &buffer );
417 
418  SUBDBG( "user %d system %d\n", ( int ) buffer.tms_utime,
419  ( int ) buffer.tms_stime );
420  retval = ( long long ) ( ( buffer.tms_utime + buffer.tms_stime ) *
421  1000000 / sysconf( _SC_CLK_TCK ));
422 
423  /* NOT CLOCKS_PER_SEC as in the headers! */
424 
425  return retval;
426 }
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
long long
Definition: iozone.c:19827
char * buffer
Definition: iozone.c:1366
ssize_t retval
Definition: libasync.c:338
int mmtimer_setup ( void  )

Definition at line 130 of file linux-timer.c.

130  {
131 
132 #if defined(__powerpc__)
133 multiplier = ((uint64_t)_papi_hwi_system_info.hw_info.cpu_max_mhz * 1000000ULL) / (__ppc_get_timebase_freq()/(uint64_t)1000);
134 #endif
135 return PAPI_OK; }
int multiplier
Definition: iozone.c:1539
return PAPI_OK
Definition: linux-nvml.c:497
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
PAPI_hw_info_t hw_info
int cpu_max_mhz
Definition: papi.h:796

Here is the caller graph for this function: