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.

00261 {
00262     long long retval;
00263 #if defined(HAVE_GETTIMEOFDAY)||defined(__powerpc__)||defined(__arm__)||defined(__mips__)
00264 
00265     /* Crude estimate, not accurate in prescence of DVFS */
00266 
00267     retval = _papi_os_vector.get_real_usec(  ) *
00268         ( long long ) _papi_hwi_system_info.hw_info.cpu_max_mhz;
00269 #else
00270     retval = get_cycles(  );
00271 #endif
00272     return retval;
00273 }

long long _linux_get_real_nsec_gettime ( void   ) 

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

00482 {
00483     
00484    long long retval;
00485 
00486    struct timespec foo;
00487 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
00488    syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
00489 #else
00490    syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
00491 #endif
00492    retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
00493    retval += ( long long ) ( foo.tv_nsec );
00494 
00495    return retval;
00496 }

long long _linux_get_real_usec_cycles ( void   ) 

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

00326 {
00327     
00328    long long retval;
00329 
00330    /* Not accurate in the prescence of DVFS */
00331 
00332    retval = get_cycles(  ) / 
00333             ( long long ) _papi_hwi_system_info.hw_info.cpu_max_mhz;
00334 
00335    return retval;
00336 }

long long _linux_get_real_usec_gettime ( void   ) 

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

00289 {
00290     
00291    long long retval;
00292 
00293    struct timespec foo;
00294 #ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
00295    syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
00296 #else
00297    syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
00298 #endif
00299    retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
00300    retval += ( long long ) ( foo.tv_nsec / 1000 );
00301 
00302    return retval;
00303 }

long long _linux_get_real_usec_gettimeofday ( void   ) 

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

00311 {
00312     
00313    long long retval;
00314 
00315    struct timeval buffer;
00316    gettimeofday( &buffer, NULL );
00317    retval = ( long long ) buffer.tv_sec * ( long long ) 1000000;
00318    retval += ( long long ) ( buffer.tv_usec );
00319     
00320    return retval;
00321 }

Here is the call graph for this function:

long long _linux_get_virt_nsec_gettime ( void   ) 

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

00505 {
00506 
00507     long long retval;
00508 
00509     struct timespec foo;
00510 
00511     syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
00512     retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
00513     retval += ( long long ) foo.tv_nsec ;
00514     
00515     return retval;
00516 }

long long _linux_get_virt_usec_gettime ( void   ) 

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

00392 {
00393 
00394     long long retval;
00395 
00396     struct timespec foo;
00397 
00398     syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
00399     retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
00400     retval += ( long long ) foo.tv_nsec / 1000;
00401     
00402     return retval;
00403 }

long long _linux_get_virt_usec_pttimer ( void   ) 

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

00411 {
00412 
00413    long long retval;
00414    char buf[LINE_MAX];
00415    long long utime, stime;
00416    int rv, cnt = 0, i = 0;
00417    int stat_fd;
00418 
00419 
00420 again:
00421    sprintf( buf, "/proc/%d/task/%d/stat", getpid(  ), mygettid(  ) );
00422    stat_fd = open( buf, O_RDONLY );
00423    if ( stat_fd == -1 ) {
00424       PAPIERROR( "open(%s)", buf );
00425       return PAPI_ESYS;
00426    }
00427 
00428    rv = read( stat_fd, buf, LINE_MAX * sizeof ( char ) );
00429    if ( rv == -1 ) {
00430       if ( errno == EBADF ) {
00431      close(stat_fd);     
00432      goto again;
00433       }
00434       PAPIERROR( "read()" );
00435       close(stat_fd);
00436       return PAPI_ESYS;
00437    }
00438    lseek( stat_fd, 0, SEEK_SET );
00439 
00440    if (rv == LINE_MAX) rv--;
00441    buf[rv] = '\0';
00442    SUBDBG( "Thread stat file is:%s\n", buf );
00443    while ( ( cnt != 13 ) && ( i < rv ) ) {
00444       if ( buf[i] == ' ' ) {
00445      cnt++;
00446       }
00447       i++;
00448    }
00449 
00450    if ( cnt != 13 ) {
00451       PAPIERROR( "utime and stime not in thread stat file?" );
00452       close(stat_fd);
00453       return PAPI_ESYS;
00454    }
00455 
00456    if ( sscanf( buf + i, "%llu %llu", &utime, &stime ) != 2 ) {
00457       close(stat_fd);
00458       PAPIERROR("Unable to scan two items from thread stat file at 13th space?");
00459       return PAPI_ESYS;
00460    }
00461 
00462    retval = ( utime + stime ) * ( long long ) 1000000 /_papi_os_info.clock_ticks;
00463 
00464    close(stat_fd);
00465 
00466    return retval;
00467 }

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.

00368 {
00369 
00370    long long retval;
00371 
00372    struct tms buffer;
00373 
00374    times( &buffer );
00375 
00376    SUBDBG( "user %d system %d\n", ( int ) buffer.tms_utime,
00377                 ( int ) buffer.tms_stime );
00378    retval = ( long long ) ( ( buffer.tms_utime + buffer.tms_stime ) * 
00379                 1000000 / sysconf( _SC_CLK_TCK ));
00380 
00381    /* NOT CLOCKS_PER_SEC as in the headers! */
00382     
00383    return retval;
00384 }

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.

00116 { return PAPI_OK; }

Here is the caller graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1