21{
27 double diff;
28
33 long long average=0;
34 int same=0;
35
36
38
42 }
43
45 if ( hwinfo==NULL) {
47 }
48
50
52 if (!
quiet) printf(
"Need at least 1 CPU\n");
53 test_skip( __FILE__, __LINE__,
"num_cpus", 0 );
54 }
55
58 }
59
61
63
67 }
68
69
70
73 test_fail( __FILE__, __LINE__,
"PAPI_assign_eventset_component",
retval );
74 }
75
76
81 printf( "Setting Eventset[%d] granularity to: "
84 }
85
86
89
92 if (!
quiet) printf(
"Can't PAPI_CPU_ATTACH: %s\n",
95 }
96
101 }
102 }
103
108 }
109 }
110
111
113
118 }
119 }
120
123 printf ("Event: %s: %10lld on Cpu: %d\n",
125 }
126 }
127
130 }
133 printf("Average: %10lld\n",average);
134 }
135
136
138 diff=((double)
values[
i]-(
double)average)/(
double)average;
139 if ((diff<0.01) && (diff>-0.01)) same++;
140 }
141
142 if (same) {
144 printf("Error! %d events were the same\n",same);
145 }
146 test_fail( __FILE__, __LINE__,
"Too similar", 0 );
147 }
148
150
152
153 return 0;
154
155}
add PAPI preset or native hardware event by name to an EventSet
Assign a component index to an existing but empty EventSet.
Create a new empty PAPI EventSet.
get information about the system hardware
initialize the PAPI library.
Set PAPI library or event set options.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Returns a string describing the PAPI error code.
char event_name[2][PAPI_MAX_STR_LEN]
static long long values[NUM_EVENTS]
int tests_quiet(int argc, char **argv)
char * stringify_granularity(int granularity)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
A pointer to the following is passed to PAPI_set/get_opt()
PAPI_granularity_option_t granularity