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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file papi_dp_ops.c.

22 {
23
24 int num_runs=100,i;
25 long long high=0,low=0,average=0,expected=1500000;
26 double error,double_result;
27
28 long long count,total=0;
29 int quiet=0,retval,ins_result;
30 int eventset=PAPI_NULL;
31
32 quiet=tests_quiet(argc,argv);
33
34 if (!quiet) {
35 printf("\nTesting the PAPI_DP_OPS event.\n\n");
36 }
37
38 /* Init the PAPI library */
40 if ( retval != PAPI_VER_CURRENT ) {
41 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
42 }
43
44 /* Create the eventset */
46 if (retval!=PAPI_OK) {
47 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
48 }
49
50 /* Add FP_OPS event */
51 retval=PAPI_add_named_event(eventset,"PAPI_DP_OPS");
52 if (retval!=PAPI_OK) {
53 if (!quiet) fprintf(stderr,"PAPI_DP_OPS not available!\n");
54 test_skip( __FILE__, __LINE__, "adding PAPI_DP_OPS", retval );
55 }
56
57 /**************************************/
58 /* Test a loop with no floating point */
59 /**************************************/
60 expected=0;
61
62 if (!quiet) {
63 printf("Testing a loop with %lld floating point (%d times):\n",
64 expected,num_runs);
65 }
66
67 for(i=0;i<num_runs;i++) {
68 PAPI_reset(eventset);
69 PAPI_start(eventset);
70
71 ins_result=branches_testcode();
72
73 retval=PAPI_stop(eventset,&count);
74
75 if (ins_result==CODE_UNIMPLEMENTED) {
76 fprintf(stderr,"\tCode unimplemented\n");
77 test_skip( __FILE__, __LINE__, "unimplemented", 0);
78 }
79
80 if (retval!=PAPI_OK) {
81 test_fail( __FILE__, __LINE__,
82 "reading PAPI_TOT_INS", retval );
83 }
84
85 if (count>high) high=count;
86 if ((low==0) || (count<low)) low=count;
87 total+=count;
88 }
89
90 average=(total/num_runs);
91
92 error=display_error(average,high,low,expected,quiet);
93
94 if (average>10) {
95 if (!quiet) printf("Unexpected FP event value\n");
96 test_fail( __FILE__, __LINE__, "Unexpected FP event", 1 );
97 }
98
99 if (!quiet) printf("\n");
100
101 /*******************************************/
102 /* Test a single precision matrix multiply */
103 /*******************************************/
104 total=0; high=0; low=0;
106
108
109 num_runs=3;
110
111 if (!quiet) {
112 printf("Testing a matrix multiply with %lld single-precision FP operations (%d times)\n",
113 expected,num_runs);
114 }
115
116 for(i=0;i<num_runs;i++) {
117
118 PAPI_reset(eventset);
119 PAPI_start(eventset);
120
122
123 retval=PAPI_stop(eventset,&count);
124
125 if (retval!=PAPI_OK) {
126 test_fail( __FILE__, __LINE__,
127 "reading PAPI_TOT_INS", retval );
128 }
129
130 if (count>high) high=count;
131 if ((low==0) || (count<low)) low=count;
132 total+=count;
133 }
134
135 if (!quiet) printf("Result %lf\n",double_result);
136
137 average=(total/num_runs);
138
139 error=display_error(average,high,low,expected,quiet);
140
141 if ((error > 1.0) || (error<-1.0)) {
142 if (!quiet) printf("Instruction count off by more than 1%%\n");
143 test_fail( __FILE__, __LINE__, "Error too high", 1 );
144 }
145
146 if (!quiet) printf("\n");
147
148
149 /*******************************************/
150 /* Test a double precision matrix multiply */
151 /*******************************************/
152 total=0; high=0; low=0;
154
155 num_runs=3;
156
157 if (!quiet) {
158 printf("Testing a matrix multiply with %lld double-precision FP operations (%d times)\n",
159 expected,num_runs);
160 }
161
162 for(i=0;i<num_runs;i++) {
163
164 PAPI_reset(eventset);
165 PAPI_start(eventset);
166
168
169 retval=PAPI_stop(eventset,&count);
170
171 if (retval!=PAPI_OK) {
172 test_fail( __FILE__, __LINE__,
173 "reading PAPI_TOT_INS", retval );
174 }
175
176 if (count>high) high=count;
177 if ((low==0) || (count<low)) low=count;
178 total+=count;
179 }
180
181 if (!quiet) printf("Result %lf\n",double_result);
182
183 average=(total/num_runs);
184
185 error=display_error(average,high,low,expected,quiet);
186
187 if ((error > 1.0) || (error<-1.0)) {
188 if (!quiet) printf("Instruction count off by more than 1%%\n");
189 test_fail( __FILE__, __LINE__, "Error too high", 1 );
190 }
191
192 if (!quiet) printf("\n");
193
194
195 test_pass( __FILE__ );
196
198
199 return 0;
200}
int i
int branches_testcode(void)
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.
Finish using PAPI and free all related resources.
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
double flops_double_matrix_matrix_multiply(void)
int flops_double_init_matrix(void)
float flops_float_matrix_matrix_multiply(void)
int flops_float_init_matrix(void)
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
FILE * stderr
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
#define CODE_UNIMPLEMENTED
Definition: testcode.h:2
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: