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_L2_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=(l2_size/sizeof(double))*8;
87
88 if (arraysize==0) {
89 if (!
quiet) printf(
"Could not detect cache size\n");
90 test_skip(__FILE__,__LINE__,
"Could not detect cache size",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("\tPrefetch and shared nature of L2s make this hard.\n");
111 printf("\tExpected 7/8 of accesses to be miss.\n");
112 }
113
114 high=0; low=0;
total=0;
115
116 for(
i=0;
i<num_runs;
i++) {
117
120
122
124
127 "reading PAPI_L2_DCM",
retval );
128 }
129
133 }
134
135 average=(
total/num_runs);
136
138
139
140
142
145 printf("Instruction count off by more "
147 }
148 errors++;
149 }
150
151 if (!
quiet) printf(
"\n");
152
153
154
155
156
158 printf("\nRead Test: Summing %d random doubles from array "
160 printf("\tExpected 7/8 of accesses to be miss.\n");
161 }
162
163 high=0; low=0;
total=0;
164
165 for(
i=0;
i<num_runs;
i++) {
166
169
171
173
176 "reading PAPI_L2_DCM",
retval );
177 }
178
182 }
183
184 average=(
total/num_runs);
185
187
188
189
191
194 printf("Instruction count off by more "
196 }
197 errors++;
198 }
199
201 printf("\n");
202 }
203
204
205 if (errors) {
206 test_warn( __FILE__, __LINE__,
"Error too high", 1 );
207 }
208
209
210
212
213 return 0;
214}
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 test_warn(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)