34 {
35
41
43 int l1_size,l2_size,l1_linesize,l2_linesize,l2_entries;
44 int arraysize;
46
47 double error;
49 double aSumm = 0.0;
50
52
54 printf("Testing the PAPI_L1_DCM event\n");
55 }
56
57
61 }
62
66 }
67
71 }
72
78
80 printf("\tDetected %dk L1 DCache, %dB linesize\n",
81 l1_size/1024,l1_linesize);
82 printf("\tDetected %dk L2 DCache, %dB linesize, %d entries\n",
83 l2_size/1024,l2_linesize,l2_entries);
84 }
85
86 arraysize=(l1_size/sizeof(double))*8;
87
88 if (arraysize==0) {
89 if (!
quiet) printf(
"Could not detect cache size\n");
90 test_skip(__FILE__,__LINE__,
"No cache info",0);
91 }
92
94 printf("\tAllocating %zu bytes of memory (%d doubles)\n",
95 arraysize*sizeof(double),arraysize);
96 }
97
98 array=calloc(arraysize,
sizeof(
double));
100 test_fail(__FILE__,__LINE__,
"Can't allocate memory",0);
101 }
102
103
104
105
106
108 printf("\nWrite Test: Writing an array of %d doubles %d random times:\n",
110 printf("It's expected that 7/8 of the accesses should be hits\n");
111 }
112
113 high=0; low=0;
total=0;
114
115 for(
i=0;
i<num_runs;
i++) {
116
119
121
123
126 "reading PAPI_L1_DCM",
retval );
127 }
128
132 }
133
134 average=(
total/num_runs);
135
137
138
139
141
144 printf("Instruction count off by more than "
146 }
147 errors++;
148 }
149
150 if (!
quiet) printf(
"\n");
151
152
153
154
155
157 printf("\nRead Test: Summing %d random doubles from array "
159 printf("It's expected that 7/8 of the accesses should be hits\n");
160 }
161
162 high=0; low=0;
total=0;
163
164 for(
i=0;
i<num_runs;
i++) {
165
168
170
172
175 "reading PAPI_L1_DCM",
retval );
176 }
177
181 }
182
183 average=(
total/num_runs);
184
186
187
188
190
193 printf("Instruction count off by more than "
195 }
196 errors++;
197 }
198
200 printf("\n");
201 }
202
203 if (errors) {
204 test_fail( __FILE__, __LINE__,
"Error too high", 1 );
205 }
206
207
208
210
211 return 0;
212}
long long get_cachesize(int type)
long long get_linesize(int type)
long long get_entries(int type)
double cache_random_read_test(double *array, int size, int count)
int cache_random_write_test(double *array, int size, int 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.
static int expected[NUM_THREADS]
double display_error(long long average, long long high, long long low, long long expected, int quiet)
static double array[ARRAYSIZE]
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)