40 {
41
43 double mmm_ghz;
44
45 double error;
46
48 long long count,high=0,low=0,
total=0,average=0;
49 long long nsecs;
50 long long mmm_count;
54
56
58
59
63 }
64
66 printf("\nTesting PAPI_TOT_CYC\n\n");
67 }
68
70 printf(
"Testing a sleep of 1 second (%d times):\n",
SLEEP_RUNS);
71 }
72
76 }
77
80 if (!
quiet) printf(
"Could not add PAPI_TOT_CYC\n");
82 }
83
84
86
89
90 sleep(1);
91
95 }
96
100 }
101
103
105 printf("\tAverage should be low, as no user cycles when sleeping\n");
106 printf("\tMeasured average: %lld\n",average);
107 }
108
109 if (average>100000) {
110 if (!
quiet) printf(
"Average cycle count too high!\n");
112 }
113
114
115
116
117
119 printf("\nEstimating GHz with matrix matrix multiply\n");
120 }
121
122
123
124
125
127
128 clock_gettime(CLOCK_REALTIME,&before);
129
132
134
136
139 }
140
141 clock_gettime(CLOCK_REALTIME,&after);
142
144
145 mmm_ghz=(double)
count/(
double)nsecs;
146
148 printf(
"\tActual measured cycles = %lld\n",
count);
149 printf("\tEstimated actual GHz = %.2lfGHz\n",mmm_ghz);
150 }
151
153
154
155
156
157
158 if (!
quiet) printf(
"\nTesting for a linear cycle increase\n");
159
160#define REPITITIONS 2
161
162 clock_gettime(CLOCK_REALTIME,&before);
163
166
169 }
170
172
175 }
176
177 clock_gettime(CLOCK_REALTIME,&after);
178
180
182
184
187 printf("\tError=%.2f%%\n",error);
188 }
189
190 if ((error>10.0) || (error<-10.0)) {
191
192 if (!
quiet) printf(
"Error too high!\n");
194 }
195
196 if (!
quiet) printf(
"\n");
197
199
200 return 0;
201}
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.
static int expected[NUM_THREADS]
double naive_matrix_multiply(int quiet)
int tests_quiet(int argc, char **argv)
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)
static long long convert_to_ns(struct timespec *before, struct timespec *after)