PAPI 7.1.0.0
Loading...
Searching...
No Matches
papi_l1_dca.c File Reference
Include dependency graph for papi_l1_dca.c:

Go to the source code of this file.

Macros

#define NUM_RUNS   100
 
#define ARRAYSIZE   65536
 

Functions

int main (int argc, char **argv)
 

Variables

static double array [ARRAYSIZE]
 

Macro Definition Documentation

◆ ARRAYSIZE

#define ARRAYSIZE   65536

Definition at line 21 of file papi_l1_dca.c.

◆ NUM_RUNS

#define NUM_RUNS   100

Definition at line 19 of file papi_l1_dca.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file papi_l1_dca.c.

25 {
26
27 int i;
28 int quiet;
29 int eventset=PAPI_NULL;
30
31 int errors=0;
32 int retval;
33 int num_runs=NUM_RUNS;
34 long long high,low,average,expected=ARRAYSIZE;
35 long long count,total;
36 double aSumm = 0.0;
37 double error;
38
39 quiet=tests_quiet(argc,argv);
40
41 if (!quiet) {
42 printf("Testing the PAPI_L1_DCA event\n");
43 }
44
45 /* Init the PAPI library */
47 if (retval != PAPI_VER_CURRENT) {
48 test_fail(__FILE__,__LINE__,"PAPI_library_init",retval);
49 }
50
52 if (retval!=PAPI_OK) {
53 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
54 }
55
56 retval=PAPI_add_named_event(eventset,"PAPI_L1_DCA");
57 if (retval!=PAPI_OK) {
58 test_skip( __FILE__, __LINE__, "adding PAPI_L1_DCA", retval );
59 }
60
61
62 /*******************************************************************/
63 /* Test if the C compiler uses a sane number of data cache acceess */
64 /* This tests writes to memory. */
65 /*******************************************************************/
66
67 if (!quiet) {
68 printf("Write Test: Initializing an array of %d doubles:\n",
69 ARRAYSIZE);
70 }
71
72 high=0; low=0; total=0;
73
74 for(i=0;i<num_runs;i++) {
75
76 PAPI_reset(eventset);
77 PAPI_start(eventset);
78
80
81 retval=PAPI_stop(eventset,&count);
82
83 if (retval!=PAPI_OK) {
84 test_fail( __FILE__, __LINE__,
85 "reading PAPI_L1_DCA", retval );
86 }
87
88 if (count>high) high=count;
89 if ((low==0) || (count<low)) low=count;
90 total+=count;
91 }
92
93 average=(total/num_runs);
94
95 error=display_error(average,high,low,expected,quiet);
96
97 if ((error > 1.0) || (error<-1.0)) {
98 if (!quiet) printf("Instruction count off by more than 1%%\n");
99 errors++;
100 }
101
102 if (!quiet) printf("\n");
103
104
105 /*******************************************************************/
106 /* Test if the C compiler uses a sane number of data cache acceess */
107 /* This tests writes to memory. */
108 /*******************************************************************/
109
110 if (!quiet) {
111 printf("Read Test: Summing an array of %d doubles:\n",
112 ARRAYSIZE);
113 }
114
115 high=0; low=0; total=0;
116
117 for(i=0;i<num_runs;i++) {
118
119 PAPI_reset(eventset);
120 PAPI_start(eventset);
121
122
124
125 retval=PAPI_stop(eventset,&count);
126
127 if (retval!=PAPI_OK) {
128 test_fail( __FILE__, __LINE__,
129 "reading PAPI_L1_DCA", retval );
130 }
131
132 if (count>high) high=count;
133 if ((low==0) || (count<low)) low=count;
134 total+=count;
135 }
136
137 if (!quiet) {
138 printf("\tRead test sim= %lf\n",aSumm);
139 }
140
141 average=(total/num_runs);
142
143 error=display_error(average,high,low,expected,quiet);
144
145 if ((error > 1.0) || (error<-1.0)) {
146 if (!quiet) printf("Instruction count off by more than 1%%\n");
147 errors++;
148 }
149
150 if (!quiet) {
151 printf("\n");
152 }
153
154 if (errors) {
155 test_fail( __FILE__, __LINE__, "Error too high", 1 );
156 }
157
158 test_pass(__FILE__);
159
160 return 0;
161}
int i
int cache_write_test(double *array, int size)
Definition: cache_testcode.c:6
double cache_read_test(double *array, int size)
static long 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)
Definition: display_error.c:7
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
static double array[ARRAYSIZE]
Definition: papi_l1_dca.c:23
#define ARRAYSIZE
Definition: papi_l1_dca.c:21
#define NUM_RUNS
Definition: papi_l1_dca.c:19
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
static int total
Definition: rapl_overflow.c:9
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ array

double array[ARRAYSIZE]
static

Definition at line 23 of file papi_l1_dca.c.