|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <unistd.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int retval;
|
|
Packit |
577717 |
long long elapsed_us, elapsed_cyc;
|
|
Packit |
577717 |
const PAPI_hw_info_t *hw_info;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
hw_info = PAPI_get_hardware_info( );
|
|
Packit |
577717 |
if ( hw_info == NULL )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
elapsed_us = PAPI_get_virt_usec( );
|
|
Packit |
577717 |
elapsed_cyc = PAPI_get_virt_cyc( );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!TESTS_QUIET) {
|
|
Packit |
577717 |
printf( "Testing virt time clock. (CPU Max %d MHz, CPU Min %d MHz)\n",
|
|
Packit |
577717 |
hw_info->cpu_max_mhz, hw_info->cpu_min_mhz );
|
|
Packit |
577717 |
printf( "Sleeping for 10 seconds.\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
sleep( 10 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
elapsed_us = PAPI_get_virt_usec( ) - elapsed_us;
|
|
Packit |
577717 |
elapsed_cyc = PAPI_get_virt_cyc( ) - elapsed_cyc;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!TESTS_QUIET) {
|
|
Packit |
577717 |
printf( "%lld us. %lld cyc.\n", elapsed_us, elapsed_cyc );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Elapsed microseconds and elapsed cycles are not as unambiguous as they appear.
|
|
Packit |
577717 |
On Pentium III and 4, for example, cycles is a measured value, while useconds
|
|
Packit |
577717 |
is computed from cycles and mhz. MHz is read from /proc/cpuinfo (on linux).
|
|
Packit |
577717 |
Thus, any error in MHz is propagated to useconds.
|
|
Packit |
577717 |
Conversely, on ultrasparc useconds are extracted from a system call (gethrtime())
|
|
Packit |
577717 |
and cycles are computed from useconds. Also, MHz comes from a scan of system info,
|
|
Packit |
577717 |
Thus any error in gethrtime() propagates to both cycles and useconds, and cycles
|
|
Packit |
577717 |
can be further impacted by errors in reported MHz.
|
|
Packit |
577717 |
Without knowing the error bars on these system values, we can't really specify
|
|
Packit |
577717 |
error ranges for our reported values, but we *DO* know that errors for at least
|
|
Packit |
577717 |
one instance of Pentium 4 (torc17@utk) are on the order of one part per thousand.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* We'll accept 1.5 part per thousand error here (to allow Pentium 4
|
|
Packit |
577717 |
and Alpha to pass) */
|
|
Packit |
577717 |
if ( elapsed_us > 100000 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "Virt time greater than .1 seconds!",
|
|
Packit |
577717 |
PAPI_EMISC );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
}
|