Go to the source code of this file.
Function Documentation
Definition at line 464 of file linux-timer.c.
{
long long retval;
struct timespec foo;
#ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
#else
syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
#endif
retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
retval += ( long long ) ( foo.tv_nsec );
return retval;
}
Definition at line 271 of file linux-timer.c.
{
long long retval;
struct timespec foo;
#ifdef HAVE_CLOCK_GETTIME_REALTIME_HR
syscall( __NR_clock_gettime, CLOCK_REALTIME_HR, &foo );
#else
syscall( __NR_clock_gettime, CLOCK_REALTIME, &foo );
#endif
retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
retval += ( long long ) ( foo.tv_nsec / 1000 );
return retval;
}
Definition at line 487 of file linux-timer.c.
{
long long retval;
struct timespec foo;
syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
retval = ( long long ) foo.tv_sec * ( long long ) 1000000000;
retval += ( long long ) foo.tv_nsec ;
return retval;
}
Definition at line 374 of file linux-timer.c.
{
long long retval;
struct timespec foo;
syscall( __NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &foo );
retval = ( long long ) foo.tv_sec * ( long long ) 1000000;
retval += ( long long ) foo.tv_nsec / 1000;
return retval;
}
Definition at line 393 of file linux-timer.c.
{
long long retval;
char buf[LINE_MAX];
long long utime, stime;
int rv, cnt = 0, i = 0;
int stat_fd;
again:
sprintf( buf, "/proc/%d/task/%d/stat", getpid( ), mygettid( ) );
stat_fd = open( buf, O_RDONLY );
if ( stat_fd == -1 ) {
PAPIERROR( "open(%s)", buf );
return PAPI_ESYS;
}
rv = read( stat_fd, buf, LINE_MAX * sizeof ( char ) );
if ( rv == -1 ) {
if ( errno == EBADF ) {
close(stat_fd);
goto again;
}
PAPIERROR( "read()" );
close(stat_fd);
return PAPI_ESYS;
}
lseek( stat_fd, 0, SEEK_SET );
if (rv == LINE_MAX) rv--;
buf[rv] = '\0';
SUBDBG( "Thread stat file is:%s\n", buf );
while ( ( cnt != 13 ) && ( i < rv ) ) {
if ( buf[i] == ' ' ) {
cnt++;
}
i++;
}
if ( cnt != 13 ) {
PAPIERROR( "utime and stime not in thread stat file?" );
close(stat_fd);
return PAPI_ESYS;
}
if ( sscanf( buf + i, "%llu %llu", &utime, &stime ) != 2 ) {
close(stat_fd);
PAPIERROR("Unable to scan two items from thread stat file at 13th space?");
return PAPI_ESYS;
}
retval = ( utime + stime ) * ( long long ) 1000000 /_papi_os_info.clock_ticks;
close(stat_fd);
return retval;
}