31 {
32
38
40 int l1_size,l2_size,l1_linesize,l2_linesize,l2_entries;
41 int arraysize;
43
44 double error;
46 double aSumm = 0.0;
47
49
51 printf("Testing the PAPI_L2_DCA event\n");
52 }
53
54
58 }
59
63 }
64
68 }
69
75
76 if ((l2_size==0) || (l2_linesize==0)) {
78 printf("Unable to determine size of L2 cache!\n");
79 }
81 }
82
84 printf("\tDetected %dk L1 DCache, %dB linesize\n",
85 l1_size/1024,l1_linesize);
86 printf("\tDetected %dk L2 DCache, %dB linesize, %d entries\n",
87 l2_size/1024,l2_linesize,l2_entries);
88 }
89
90 arraysize=l2_size/sizeof(double);
91
93 printf("\tAllocating %zu bytes of memory (%d doubles)\n",
94 arraysize*sizeof(double),arraysize);
95 }
96
97 array=calloc(arraysize,
sizeof(
double));
99 test_fail(__FILE__,__LINE__,
"Can't allocate memory",0);
100 }
101
102
103
104
105
107 printf("\nWrite Test: Initializing an array of %d doubles:\n",
108 arraysize);
109 }
110
111 high=0; low=0;
total=0;
112
113 for(
i=0;
i<num_runs;
i++) {
114
117
119
121
124 "reading PAPI_L2_DCA",
retval );
125 }
126
130 }
131
132 average=(
total/num_runs);
133
134 expected=arraysize/(l2_linesize/
sizeof(double));
135
137 printf("\tShould be roughly "
138 "arraysize/L2_linesize/double_size (%d/%d/%zu): "
139 "%lld\n\n",
140 arraysize,l2_linesize,sizeof(double),
142 }
143
145
146 if ((error > 1.0) || (error<-1.0)) {
147 if (!
quiet) printf(
"Instruction count off by more than 1%%\n");
148 errors++;
149 }
150
151 if (!
quiet) printf(
"\n");
152
153
154
155
156
158 printf("\nRead Test: Summing an array of %d doubles:\n",
159 arraysize);
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_L2_DCA",
retval );
176 }
177
181 }
182
183 average=(
total/num_runs);
184
185 expected=arraysize/(l2_linesize/
sizeof(double));
186
188 printf("\tShould be roughly "
189 "arraysize/L2_linesize/double_size (%d/%d/%zu): "
190 "%lld\n\n",
191 arraysize,l2_linesize,sizeof(double),
193 }
194
196
197 if ((error > 1.0) || (error<-1.0)) {
198 if (!
quiet) printf(
"Instruction count off by more than 1%%\n");
199 errors++;
200 }
201
203 printf("\n");
204 }
205
206
207
208 if (errors) {
209 test_warn( __FILE__, __LINE__,
"Error too high", 1 );
210 }
211
213
214 return 0;
215}
long long get_cachesize(int type)
long long get_linesize(int type)
long long get_entries(int type)
int cache_write_test(double *array, int size)
double cache_read_test(double *array, int size)
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)