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

Go to the source code of this file.

Macros

#define SLEEP_RUNS   3
 
#define REPITITIONS   2
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ REPITITIONS

#define REPITITIONS   2

◆ SLEEP_RUNS

#define SLEEP_RUNS   3

Definition at line 27 of file papi_ld_ins.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file papi_ld_ins.c.

30 {
31
32 int quiet;
33
34 double error;
35
36 int i;
37 long long count,high=0,low=0,total=0,average=0;
38 long long mmm_count;
39 long long expected;
40 int retval;
41 int eventset=PAPI_NULL;
42
43 quiet=tests_quiet(argc,argv);
44
45 /* Init the PAPI library */
47 if ( retval != PAPI_VER_CURRENT ) {
48 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
49 }
50
51 if (!quiet) {
52 printf("\nTesting PAPI_LD_INS\n\n");
53 }
54
56 if (retval!=PAPI_OK) {
57 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
58 }
59
60 retval=PAPI_add_named_event(eventset,"PAPI_LD_INS");
61 if (retval!=PAPI_OK) {
62 if (!quiet) printf("Could not add PAPI_LD_INS\n");
63 test_skip( __FILE__, __LINE__, "adding PAPI_LD_INS", retval );
64 }
65
66
67 /****************/
68 /* Sleep test */
69 /****************/
70
71 if (!quiet) {
72 printf("Testing a sleep of 1 second (%d times):\n",SLEEP_RUNS);
73 }
74
75 for(i=0;i<SLEEP_RUNS;i++) {
76
77 PAPI_reset(eventset);
78 PAPI_start(eventset);
79
80 sleep(1);
81
82 retval=PAPI_stop(eventset,&count);
83 if (retval!=PAPI_OK) {
84 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
85 }
86
87 if (count>high) high=count;
88 if ((low==0) || (count<low)) low=count;
89 total+=count;
90 }
91
92 average=total/SLEEP_RUNS;
93
94 if (!quiet) {
95 printf("\tAverage should be low, as no loads when sleeping\n");
96 printf("\tMeasured average: %lld\n",average);
97 }
98
99 if (average>100000) {
100 if (!quiet) printf("Average cycle count too high!\n");
101 test_fail( __FILE__, __LINE__, "idle average", retval );
102 }
103
104 /*****************************/
105 /* testing Matrix Matrix GHz */
106 /*****************************/
107
108 if (!quiet) {
109 printf("\nTesting with matrix matrix multiply\n");
110 }
111
112 PAPI_reset(eventset);
113 PAPI_start(eventset);
114
116
117 retval=PAPI_stop(eventset,&count);
118
119 if (retval!=PAPI_OK) {
120 test_fail( __FILE__, __LINE__, "Problem stopping!", retval );
121 }
122
124
125 if (!quiet) {
126 printf("\tActual measured loads = %lld\n",count);
127 }
128
129 error= 100.0 * (double)(count-expected) / (double)expected;
130
131 if (!quiet) {
132 printf("\tExpected %lld, got %lld\n",expected,count);
133 printf("\tError=%.2f%%\n",error);
134 }
135
136 if ((error>10.0) || (error<-10.0)) {
137
138 if (!quiet) printf("Error too high!\n");
139 test_fail( __FILE__, __LINE__, "Error too high", retval );
140 }
141
142
143 mmm_count=count;
144
145 /************************************/
146 /* Check for Linear Speedup */
147 /************************************/
148
149 if (!quiet) printf("\nTesting for a linear cycle increase\n");
150
151#define REPITITIONS 2
152
153 PAPI_reset(eventset);
154 PAPI_start(eventset);
155
156 for(i=0;i<REPITITIONS;i++) {
158 }
159
160 retval=PAPI_stop(eventset,&count);
161
162 if (retval!=PAPI_OK) {
163 test_fail( __FILE__, __LINE__, "Problem stopping!", retval );
164 }
165
166 expected=mmm_count*REPITITIONS;
167
168 error= 100.0 * (double)(count-expected) / (double)expected;
169
170 if (!quiet) {
171 printf("\tExpected %lld, got %lld\n",expected,count);
172 printf("\tError=%.2f%%\n",error);
173 }
174
175 if ((error>10.0) || (error<-10.0)) {
176
177 if (!quiet) printf("Error too high!\n");
178 test_fail( __FILE__, __LINE__, "Error too high", retval );
179 }
180
181 if (!quiet) printf("\n");
182
183 test_pass( __FILE__ );
184
185 return 0;
186}
int i
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]
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
long long naive_matrix_multiply_estimated_loads(int quiet)
double naive_matrix_multiply(int quiet)
#define SLEEP_RUNS
Definition: papi_ld_ins.c:27
#define REPITITIONS
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: