28 #define ALLOWED_ERROR 5.0 32 #define ITERATIONS 1000000 34 int main(
int argc,
char **argv) {
43 int l1_size,l2_size,l1_linesize,l2_linesize,l2_entries;
54 printf(
"Testing the PAPI_L2_DCM event\n");
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);
86 arraysize=(l2_size/
sizeof(double))*8;
89 if (!
quiet) printf(
"Could not detect cache size\n");
90 test_skip(__FILE__,__LINE__,
"Could not detect cache size",0);
94 printf(
"\tAllocating %zu bytes of memory (%d doubles)\n",
95 arraysize*
sizeof(
double),arraysize);
98 array=calloc(arraysize,
sizeof(
double));
100 test_fail(__FILE__,__LINE__,
"Can't allocate memory",0);
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");
114 high=0; low=0;
total=0;
116 for(
i=0;
i<num_runs;
i++) {
127 "reading PAPI_L2_DCM",
retval );
135 average=(
total/num_runs);
145 printf(
"Instruction count off by more " 151 if (!
quiet) printf(
"\n");
158 printf(
"\nRead Test: Summing %d random doubles from array " 160 printf(
"\tExpected 7/8 of accesses to be miss.\n");
163 high=0; low=0;
total=0;
165 for(
i=0;
i<num_runs;
i++) {
176 "reading PAPI_L2_DCM",
retval );
184 average=(
total/num_runs);
194 printf(
"Instruction count off by more " 206 test_warn( __FILE__, __LINE__,
"Error too high", 1 );
int PAPI_stop(int EventSet, long long *values)
void test_pass(const char *filename)
static int expected[NUM_THREADS]
int PAPI_reset(int EventSet)
double display_error(long long average, long long high, long long low, long long expected, int quiet)
static double array[ARRAYSIZE]
void test_warn(const char *file, int line, const char *call, int retval)
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_add_named_event(int EventSet, const char *EventName)
int cache_random_write_test(double *array, int size, int count)
int PAPI_library_init(int version)
double cache_random_read_test(double *array, int size, int count)
long long get_linesize(int type)
int PAPI_create_eventset(int *EventSet)
long long get_cachesize(int type)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int PAPI_start(int EventSet)
long long get_entries(int type)
int main(int argc, char **argv)