PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-timer.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

long long _linux_get_real_cycles (void)
 
long long _linux_get_virt_usec_pttimer (void)
 
long long _linux_get_virt_usec_gettime (void)
 
long long _linux_get_virt_usec_times (void)
 
long long _linux_get_virt_usec_rusages (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_real_nsec_gettime (void)
 
long long _linux_get_virt_nsec_gettime (void)
 
int mmtimer_setup (void)
 
int init_proc_thread_timer (hwd_context_t *thr_ctx)
 

Function Documentation

long long _linux_get_real_cycles ( void  )

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

261 {
262  long long retval;
263 #if defined(HAVE_GETTIMEOFDAY)||defined(__powerpc__)||defined(__arm__)||defined(__mips__)
264 
265  /* Crude estimate, not accurate in prescence of DVFS */
266 
267  retval = _papi_os_vector.get_real_usec( ) *
269 #else
270  retval = get_cycles( );
271 #endif
272  return retval;
273 }
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:57
PAPI_hw_info_t hw_info
#define get_cycles
Definition: linux-bgq.c:48
int cpu_max_mhz
Definition: papi.h:793
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_nsec_gettime ( void  )

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

482 {
483 
484  long long retval;
485 
486  struct timespec foo;
487 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
488  syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
489 #else
490  syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
491 #endif
492  retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
493  retval += ( long long ) ( foo.tv_nsec );
494 
495  return retval;
496 }
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 325 of file linux-timer.c.

326 {
327 
328  long long retval;
329 
330  /* Not accurate in the prescence of DVFS */
331 
332  retval = get_cycles( ) /
334 
335  return retval;
336 }
long long
Definition: iozone.c:19827
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
#define get_cycles
Definition: linux-bgq.c:48
int cpu_max_mhz
Definition: papi.h:793
ssize_t retval
Definition: libasync.c:338
long long _linux_get_real_usec_gettime ( void  )

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

289 {
290 
291  long long retval;
292 
293  struct timespec foo;
294 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
295  syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
296 #else
297  syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
298 #endif
299  retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
300  retval += ( long long ) ( foo.tv_nsec / 1000 );
301 
302  return retval;
303 }
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 310 of file linux-timer.c.

311 {
312 
313  long long retval;
314 
315  struct timeval buffer;
316  gettimeofday( &buffer, NULL );
317  retval = ( long long ) buffer.tv_sec * ( long long ) 1000000;
318  retval += ( long long ) ( buffer.tv_usec );
319 
320  return retval;
321 }
long long
Definition: iozone.c:19827
char * buffer
Definition: iozone.c:1366
ssize_t retval
Definition: libasync.c:338
long long _linux_get_virt_nsec_gettime ( void  )

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

505 {
506 
507  long long retval;
508 
509  struct timespec foo;
510 
511  syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
512  retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
513  retval += ( long long ) foo.tv_nsec ;
514 
515  return retval;
516 }
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 391 of file linux-timer.c.

392 {
393 
394  long long retval;
395 
396  struct timespec foo;
397 
398  syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
399  retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
400  retval += ( long long ) foo.tv_nsec / 1000;
401 
402  return retval;
403 }
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 410 of file linux-timer.c.

411 {
412 
413  long long retval;
414  char buf[LINE_MAX];
415  long long utime, stime;
416  int rv, cnt = 0, i = 0;
417  int stat_fd;
418 
419 
420 again:
421  sprintf( buf, "/proc/%d/task/%d/stat", getpid( ), mygettid( ) );
422  stat_fd = open( buf, O_RDONLY );
423  if ( stat_fd == -1 ) {
424  PAPIERROR( "open(%s)", buf );
425  return PAPI_ESYS;
426  }
427 
428  rv = read( stat_fd, buf, LINE_MAX * sizeof ( char ) );
429  if ( rv == -1 ) {
430  if ( errno == EBADF ) {
431  close(stat_fd);
432  goto again;
433  }
434  PAPIERROR( "read()" );
435  close(stat_fd);
436  return PAPI_ESYS;
437  }
438  lseek( stat_fd, 0, SEEK_SET );
439 
440  if (rv == LINE_MAX) rv--;
441  buf[rv] = '\0';
442  SUBDBG( "Thread stat file is:%s\n", buf );
443  while ( ( cnt != 13 ) && ( i < rv ) ) {
444  if ( buf[i] == ' ' ) {
445  cnt++;
446  }
447  i++;
448  }
449 
450  if ( cnt != 13 ) {
451  PAPIERROR( "utime and stime not in thread stat file?" );
452  close(stat_fd);
453  return PAPI_ESYS;
454  }
455 
456  if ( sscanf( buf + i, "%llu %llu", &utime, &stime ) != 2 ) {
457  close(stat_fd);
458  PAPIERROR("Unable to scan two items from thread stat file at 13th space?");
459  return PAPI_ESYS;
460  }
461 
462  retval = ( utime + stime ) * ( long long ) 1000000 /_papi_os_info.clock_ticks;
463 
464  close(stat_fd);
465 
466  return retval;
467 }
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:253
#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_rusages ( void  )
long long _linux_get_virt_usec_times ( void  )

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

368 {
369 
370  long long retval;
371 
372  struct tms buffer;
373 
374  times( &buffer );
375 
376  SUBDBG( "user %d system %d\n", ( int ) buffer.tms_utime,
377  ( int ) buffer.tms_stime );
378  retval = ( long long ) ( ( buffer.tms_utime + buffer.tms_stime ) *
379  1000000 / sysconf( _SC_CLK_TCK ));
380 
381  /* NOT CLOCKS_PER_SEC as in the headers! */
382 
383  return retval;
384 }
#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 init_proc_thread_timer ( hwd_context_t thr_ctx)

Here is the caller graph for this function:

int mmtimer_setup ( void  )

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

116 { return PAPI_OK; }
return PAPI_OK
Definition: linux-nvml.c:458

Here is the caller graph for this function: