PAPI 7.1.0.0
Loading...
Searching...
No Matches
papi_hw_int.c File Reference
Include dependency graph for papi_hw_int.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file papi_hw_int.c.

25 {
26
27 int quiet;
28
29 long long count;
30 int retval;
31 int eventset=PAPI_NULL;
32
33 struct timespec before,after;
34 unsigned long long seconds;
35 unsigned long long ns;
36
37 quiet=tests_quiet(argc,argv);
38
39 /* Init the PAPI library */
41 if ( retval != PAPI_VER_CURRENT ) {
42 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
43 }
44
45 if (!quiet) {
46 printf("\nTesting PAPI_HW_INT\n");
47 }
48
50 if (retval!=PAPI_OK) {
51 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
52 }
53
54 retval=PAPI_add_named_event(eventset,"PAPI_HW_INT");
55 if (retval!=PAPI_OK) {
56 if (!quiet) printf("Could not add PAPI_HW_INT\n");
57 test_skip( __FILE__, __LINE__, "adding PAPI_HW_INT", retval );
58 }
59
60 /********************************/
61 /* testing 3 seconds of runtime */
62 /********************************/
63
64 if (!quiet) {
65 printf("\nRunning for 3 seconds\n");
66 }
67
68 clock_gettime(CLOCK_REALTIME,&before);
69
70 PAPI_reset(eventset);
71 PAPI_start(eventset);
72
73 while(1) {
74 clock_gettime(CLOCK_REALTIME,&after);
75
76 seconds=after.tv_sec - before.tv_sec;
77 ns = after.tv_nsec - before.tv_nsec;
78 ns = (seconds*1000000000ULL)+ns;
79
80 /* be done if 3 billion nanoseconds has passed */
81 if (ns>3000000000ULL) break;
82 }
83
84 retval=PAPI_stop(eventset,&count);
85
86 if (retval!=PAPI_OK) {
87 test_fail( __FILE__, __LINE__, "Problem stopping!", retval );
88 }
89
90 if (!quiet) {
91 printf("\tMeasured interrupts = %lld\n",count);
92 /* FIXME: find actua Hz on system */
93 /* Or even, read /proc/interrupts */
94 printf("\tAssuming HZ=250, expect roughly 750\n");
95 }
96
97 if (!quiet) printf("\n");
98
99 if (count<10) {
100 if (!quiet) printf("Too few interrupts!\n");
101 test_fail( __FILE__, __LINE__, "Too few interrupts!", 1 );
102 }
103
104 test_pass( __FILE__ );
105
106 return 0;
107}
static long count
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
initialize the PAPI library.
Reset the hardware event counts in an event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
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
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: