29 int l1_size,l2_size,l1_linesize,l2_linesize,l2_entries;
31 int quiet,errors=0,warnings=0;
40 printf(
"Testing the PAPI_L2_DCW event\n");
66 printf(
"\tDetected %dk L1 DCache, %dB linesize\n",
67 l1_size/1024,l1_linesize);
68 printf(
"\tDetected %dk L2 DCache, %dB linesize, %d entries\n",
69 l2_size/1024,l2_linesize,l2_entries);
72 arraysize=l2_size/
sizeof(double);
75 printf(
"\tAllocating %zu bytes of memory (%d doubles)\n",
76 arraysize*
sizeof(
double),arraysize);
79 array=calloc(arraysize,
sizeof(
double));
81 test_fail(__FILE__,__LINE__,
"Can't allocate memory",0);
89 printf(
"\nWrite Test: Initializing an array of %d doubles:\n",
93 high=0; low=0;
total=0;
95 for(
i=0;
i<num_runs;
i++) {
106 "reading PAPI_L2_DCW",
retval );
114 average=(
total/num_runs);
116 expected=arraysize/(l1_linesize/
sizeof(double));
119 printf(
"\tShould be roughly " 120 "arraysize/L1_linesize/double_size (%d/%d/%zu): " 122 arraysize,l1_linesize,
sizeof(
double),
128 if ((error > 10.0) || (error<-10.0)) {
129 if (!
quiet) printf(
"Instruction count off by more than 1%%\n");
134 if (!
quiet) printf(
"WARNING: Average OK but low value seems suspicious\n");
138 if (!
quiet) printf(
"\n");
145 printf(
"\nRead Test: Summing an array of %d doubles:\n",
149 high=0; low=0;
total=0;
151 for(
i=0;
i<num_runs;
i++) {
162 "reading PAPI_L2_DCW",
retval );
170 average=(
total/num_runs);
172 expected=(arraysize/(l1_linesize/
sizeof(double)))/10;
175 printf(
"\tShould be very low as we are measuring writes\n");
179 printf(
"Average writes: %lld\n",average);
185 if (!
quiet) printf(
"ERROR: Write count unexpectedly high\n");
195 test_warn( __FILE__, __LINE__,
"Error too high", 1 );
199 test_warn(__FILE__, __LINE__,
"Average results OK but some measurements low",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)
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_add_named_event(int EventSet, const char *EventName)
int PAPI_library_init(int version)
int cache_write_test(double *array, int size)
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)
double cache_read_test(double *array, int size)