PAPI 7.1.0.0
Loading...
Searching...
No Matches
virttime.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4
5#include "papi.h"
6#include "papi_test.h"
7
8int
9main( int argc, char **argv )
10{
11 int retval;
12 long long elapsed_us, elapsed_cyc;
14
15 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
16
18 if ( retval != PAPI_VER_CURRENT )
19 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
20
22 if ( hw_info == NULL )
23 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
24
27
28 if (!TESTS_QUIET) {
29 printf( "Testing virt time clock. (CPU Max %d MHz, CPU Min %d MHz)\n",
31 printf( "Sleeping for 10 seconds.\n" );
32 }
33
34 sleep( 10 );
35
38
39 if (!TESTS_QUIET) {
40 printf( "%lld us. %lld cyc.\n", elapsed_us, elapsed_cyc );
41 }
42
43/* Elapsed microseconds and elapsed cycles are not as unambiguous as they appear.
44 On Pentium III and 4, for example, cycles is a measured value, while useconds
45 is computed from cycles and mhz. MHz is read from /proc/cpuinfo (on linux).
46 Thus, any error in MHz is propagated to useconds.
47 Conversely, on ultrasparc useconds are extracted from a system call (gethrtime())
48 and cycles are computed from useconds. Also, MHz comes from a scan of system info,
49 Thus any error in gethrtime() propagates to both cycles and useconds, and cycles
50 can be further impacted by errors in reported MHz.
51 Without knowing the error bars on these system values, we can't really specify
52 error ranges for our reported values, but we *DO* know that errors for at least
53 one instance of Pentium 4 (torc17@utk) are on the order of one part per thousand.
54*/
55
56 /* We'll accept 1.5 part per thousand error here (to allow Pentium 4
57 and Alpha to pass) */
58 if ( elapsed_us > 100000 )
59 test_fail( __FILE__, __LINE__, "Virt time greater than .1 seconds!",
60 PAPI_EMISC );
61
62 test_pass( __FILE__ );
63
64 return 0;
65
66}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
get information about the system hardware
get virtual time counter value in clock cycles
get virtual time counter values in microseconds
initialize the PAPI library.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_EMISC
Definition: f90papi.h:122
int TESTS_QUIET
Definition: test_utils.c:18
Return codes and api definitions.
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
int main()
Definition: pernode.c:20
Hardware info structure.
Definition: papi.h:774
int cpu_min_mhz
Definition: papi.h:791
int cpu_max_mhz
Definition: papi.h:790
long long elapsed_cyc
Definition: zero_fork.c:50
long long elapsed_us
Definition: zero_fork.c:50
int retval
Definition: zero_fork.c:53