28#define ALLOWED_ERROR 5.0
32#define ITERATIONS 1000000
34int 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 );
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)
Return codes and api definitions.
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)