|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* File: timer_overflow.c
|
|
Packit |
577717 |
* Author: Kevin London
|
|
Packit |
577717 |
* london@cs.utk.edu
|
|
Packit |
577717 |
* Mods: <your name here>
|
|
Packit |
577717 |
* <your email address>
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This file looks for possible timer overflows. */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <unistd.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define TIMER_THRESHOLD 100
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int sleep_time = TIMER_THRESHOLD;
|
|
Packit |
577717 |
int retval, i;
|
|
Packit |
577717 |
long long timer;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( argc > 1 ) {
|
|
Packit |
577717 |
if ( !strcmp( argv[1], "TESTS_QUIET" ) )
|
|
Packit |
577717 |
tests_quiet( argc, argv );
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
sleep_time = atoi( argv[1] );
|
|
Packit |
577717 |
if ( sleep_time <= 0 )
|
|
Packit |
577717 |
sleep_time = TIMER_THRESHOLD;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( TESTS_QUIET ) {
|
|
Packit |
577717 |
/* Skip the test in TESTS_QUIET so that the main script doesn't
|
|
Packit |
577717 |
* run this as it takes a long time to check for overflow
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
printf( "%-40s SKIPPED\nLine # %d\n", __FILE__, __LINE__ );
|
|
Packit |
577717 |
printf( "timer_overflow takes a long time to run, run separately.\n" );
|
|
Packit |
577717 |
exit( 0 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf( "This test will take about: %f minutes.\n",
|
|
Packit |
577717 |
( float ) ( 20 * ( sleep_time / 60.0 ) ) );
|
|
Packit |
577717 |
if ( ( retval =
|
|
Packit |
577717 |
PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
timer = PAPI_get_real_usec( );
|
|
Packit |
577717 |
for ( i = 0; i <= 20; i++ ) {
|
|
Packit |
577717 |
if ( timer < 0 )
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
sleep( ( unsigned int ) sleep_time );
|
|
Packit |
577717 |
timer = PAPI_get_real_usec( );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( timer < 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_real_usec: overflow", 1 );
|
|
Packit |
577717 |
else
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|