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

Go to the source code of this file.

Macros

#define TOTAL_EVENTS   6
 

Functions

static void init_papi (int *out_events, int *len)
 
int case1 (void)
 
int case2 (void)
 
int case3 (void)
 
int case4 (void)
 
int case5 (void)
 
int main (int argc, char **argv)
 

Variables

int solaris_preset_PAPI_events [TOTAL_EVENTS]
 
int power6_preset_PAPI_events [TOTAL_EVENTS]
 
int preset_PAPI_events [TOTAL_EVENTS]
 
static int PAPI_events [TOTAL_EVENTS] = { 0, }
 
static int PAPI_events_len = 0
 

Macro Definition Documentation

◆ TOTAL_EVENTS

#define TOTAL_EVENTS   6

Definition at line 23 of file multiplex1.c.

Function Documentation

◆ case1()

int case1 ( void  )

Definition at line 102 of file multiplex1.c.

103{
104 int retval, i, EventSet = PAPI_NULL;
105 long long values[2];
106
107 PAPI_events_len = 2;
109
111 if ( retval != PAPI_OK )
112 test_fail(__FILE__,__LINE__, "PAPI_create_eventset", retval );
113
114 for ( i = 0; i < PAPI_events_len; i++ ) {
115 char out[PAPI_MAX_STR_LEN];
116
118 if ( retval != PAPI_OK )
119 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
121 if ( !TESTS_QUIET )
122 printf( "Added %s\n", out );
123 }
124
125 do_stuff( );
126
127 if ( PAPI_start( EventSet ) != PAPI_OK )
128 test_fail(__FILE__,__LINE__, "PAPI_start", retval );
129
130 do_stuff( );
131
133 if ( retval != PAPI_OK )
134 test_fail(__FILE__,__LINE__, "PAPI_stop", retval );
135
136 if ( !TESTS_QUIET ) {
138 printf( TAB2, "case1:", values[0], values[1] );
139 }
141 if ( retval != PAPI_OK )
142 test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
143
144 PAPI_shutdown( );
145 return ( SUCCESS );
146}
int i
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Convert a numeric hardware event code to a name.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
void do_stuff(void)
Definition: do_loops.c:256
#define SUCCESS
Definition: do_loops.h:5
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
static int PAPI_events_len
Definition: multiplex1.c:36
static int PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:35
static void init_papi(int *out_events, int *len)
Definition: multiplex1.c:39
int TESTS_QUIET
Definition: test_utils.c:18
void test_print_event_header(const char *call, int evset)
Definition: test_utils.c:605
#define TAB2
Definition: papi_test.h:99
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ case2()

int case2 ( void  )

Definition at line 151 of file multiplex1.c.

152{
153 int retval, i, EventSet = PAPI_NULL;
154 long long values[2];
155
156 PAPI_events_len = 2;
158
160 if ( retval != PAPI_OK )
161 test_fail(__FILE__,__LINE__, "PAPI_create_eventset", retval );
162
163 /* In Component PAPI, EventSets must be assigned a component index
164 before you can fiddle with their internals.
165 0 is always the cpu component */
167 if ( retval != PAPI_OK )
168 test_fail(__FILE__,__LINE__, "PAPI_assign_eventset_component", retval );
169
171 if ( retval == PAPI_ENOSUPP) {
172 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
173 }
174 else if ( retval != PAPI_OK )
175 test_fail(__FILE__,__LINE__, "PAPI_set_multiplex", retval );
176
177 for ( i = 0; i < PAPI_events_len; i++ ) {
178 char out[PAPI_MAX_STR_LEN];
179
181 if ( retval != PAPI_OK )
182 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
184 if ( !TESTS_QUIET )
185 printf( "Added %s\n", out );
186 }
187
188 do_stuff( );
189
190 if ( PAPI_start( EventSet ) != PAPI_OK )
191 test_fail(__FILE__,__LINE__, "PAPI_start", retval );
192
193 do_stuff( );
194
196 if ( retval != PAPI_OK )
197 test_fail(__FILE__,__LINE__, "PAPI_stop", retval );
198
199 if ( !TESTS_QUIET ) {
201 printf( TAB2, "case2:", values[0], values[1] );
202 }
203
205 if ( retval != PAPI_OK )
206 test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
207
208 PAPI_shutdown( );
209 return ( SUCCESS );
210}
Assign a component index to an existing but empty EventSet.
Convert a standard event set to a multiplexed event set.
#define PAPI_ENOSUPP
Definition: f90papi.h:244
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
Here is the call graph for this function:
Here is the caller graph for this function:

◆ case3()

int case3 ( void  )

Definition at line 215 of file multiplex1.c.

216{
217 int retval, i, EventSet = PAPI_NULL;
218 long long values[2];
219
220 PAPI_events_len = 2;
222
224 if ( retval != PAPI_OK )
225 test_fail(__FILE__,__LINE__, "PAPI_create_eventset", retval );
226
227 for ( i = 0; i < PAPI_events_len; i++ ) {
228 char out[PAPI_MAX_STR_LEN];
229
231 if ( retval != PAPI_OK )
232 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
234 if ( !TESTS_QUIET )
235 printf( "Added %s\n", out );
236 }
237
239 if ( retval == PAPI_ENOSUPP) {
240 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
241 } else if ( retval != PAPI_OK )
242 test_fail(__FILE__,__LINE__, "PAPI_set_multiplex", retval );
243
244 do_stuff( );
245
246 if ( PAPI_start( EventSet ) != PAPI_OK )
247 test_fail(__FILE__,__LINE__, "PAPI_start", retval );
248
249 do_stuff( );
250
252 if ( retval != PAPI_OK )
253 test_fail(__FILE__,__LINE__, "PAPI_stop", retval );
254
255 if ( !TESTS_QUIET ) {
257 printf( TAB2, "case3:", values[0], values[1] );
258 }
259
261 if ( retval != PAPI_OK )
262 test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
263
264 PAPI_shutdown( );
265 return ( SUCCESS );
266}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ case4()

int case4 ( void  )

Definition at line 274 of file multiplex1.c.

275{
276 int retval, i, EventSet = PAPI_NULL;
277 long long values[4];
278 char out[PAPI_MAX_STR_LEN];
279
280 PAPI_events_len = 2;
282
284 if ( retval != PAPI_OK )
285 test_fail(__FILE__,__LINE__, "PAPI_create_eventset", retval );
286
287 i = 0;
289 if ( retval != PAPI_OK )
290 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
292 if (!TESTS_QUIET) printf( "Added %s\n", out );
293
295 if ( retval == PAPI_ENOSUPP) {
296 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
297 }
298 else if ( retval != PAPI_OK )
299 test_fail(__FILE__,__LINE__, "PAPI_set_multiplex", retval );
300
301 i = 1;
303 if ( retval != PAPI_OK )
304 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
306 if (!TESTS_QUIET) printf( "Added %s\n", out );
307
308 do_stuff( );
309
310 if ( PAPI_start( EventSet ) != PAPI_OK )
311 test_fail(__FILE__,__LINE__, "PAPI_start", retval );
312
313 do_stuff( );
314
316 if ( retval != PAPI_OK )
317 test_fail(__FILE__,__LINE__, "PAPI_stop", retval );
318
319 if ( !TESTS_QUIET ) {
321 printf( TAB2, "case4:", values[0], values[1] );
322 }
323
325 if ( retval != PAPI_OK )
326 test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
327
328 PAPI_shutdown( );
329 return ( SUCCESS );
330}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ case5()

int case5 ( void  )

Definition at line 336 of file multiplex1.c.

337{
338 int retval, i, j, EventSet = PAPI_NULL;
339 long long start_values[4] = { 0,0,0,0 }, values[4] = {0,0,0,0};
340 char out[PAPI_MAX_STR_LEN];
341
342 PAPI_events_len = 2;
344
346 if ( retval != PAPI_OK )
347 test_fail(__FILE__,__LINE__, "PAPI_create_eventset", retval );
348
349 /* In Component PAPI, EventSets must be assigned a component index
350 before you can fiddle with their internals.
351 0 is always the cpu component */
352
354 if ( retval != PAPI_OK )
355 test_fail(__FILE__,__LINE__, "PAPI_assign_eventset_component", retval );
356
358 if ( retval == PAPI_ENOSUPP) {
359 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
360 }
361 else if ( retval != PAPI_OK ) {
362 test_fail(__FILE__,__LINE__, "PAPI_set_multiplex", retval );
363 }
364
365 /* Add 2 events... */
366
367 i = 0;
369 if ( retval != PAPI_OK )
370 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
372 if (!TESTS_QUIET) printf( "Added %s\n", out );
373 i++;
375 if ( retval != PAPI_OK )
376 test_fail(__FILE__,__LINE__, "PAPI_add_event", retval );
378 if (!TESTS_QUIET) printf( "Added %s\n", out );
379 i++;
380
381 do_stuff( );
382
384 if ( retval != PAPI_OK )
385 test_fail(__FILE__,__LINE__, "PAPI_start", retval );
386
387 retval = PAPI_read( EventSet, start_values );
388 if ( retval != PAPI_OK )
389 test_fail(__FILE__,__LINE__, "PAPI_read", retval );
390
391 do_stuff( );
392
394 if ( retval != PAPI_OK )
395 test_fail(__FILE__,__LINE__, "PAPI_stop", retval );
396
397 for (j=0;j<i;j++) {
398 if (!TESTS_QUIET) {
399 printf("read @start counter[%d]: %lld\n",
400 j, start_values[j]);
401 printf("read @stop counter[%d]: %lld\n",
402 j, values[j]);
403 printf("difference counter[%d]: %lld\n ",
404 j, values[j]-start_values[j]);
405 }
406 if (values[j]-start_values[j] < 0LL) {
407 test_fail(__FILE__,__LINE__, "Difference in start and stop resulted in negative value!", 0 );
408 }
409 }
410
412 if ( retval != PAPI_OK )
413 test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
414
415 PAPI_shutdown( );
416 return ( SUCCESS );
417}
Read hardware counters from an event set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_papi()

static void init_papi ( int out_events,
int len 
)
static

Definition at line 39 of file multiplex1.c.

40{
41 int retval;
42 int i, real_len = 0;
43 int *in_events = preset_PAPI_events;
45
46 /* Initialize the library */
48 if ( retval != PAPI_VER_CURRENT ) {
49 test_fail(__FILE__,__LINE__, "PAPI_library_init", retval );
50 }
51
53 if ( hw_info == NULL ) {
54 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
55 }
56
57 if ( strstr( hw_info->model_string, "UltraSPARC" ) ) {
59 }
60
61 if ( strcmp( hw_info->model_string, "POWER6" ) == 0 ) {
62 in_events = power6_preset_PAPI_events;
64 if ( retval != PAPI_OK )
65 test_fail(__FILE__,__LINE__, "PAPI_set_domain", retval );
66 }
67
69 if ( retval == PAPI_ENOSUPP) {
70 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
71 }
72 else if ( retval != PAPI_OK ) {
73 test_fail(__FILE__,__LINE__, "PAPI_multiplex_init", retval );
74 }
75
76 for ( i = 0; in_events[i] != 0; i++ ) {
77 char out[PAPI_MAX_STR_LEN];
78 /* query and set up the right instruction to monitor */
79 retval = PAPI_query_event( in_events[i] );
80 if ( retval == PAPI_OK ) {
81 out_events[real_len++] = in_events[i];
82 PAPI_event_code_to_name( in_events[i], out );
83 if ( real_len == *len )
84 break;
85 } else {
86 PAPI_event_code_to_name( in_events[i], out );
87 if ( !TESTS_QUIET )
88 printf( "%s does not exist\n", out );
89 }
90 }
91
92 if ( real_len < 1 ) {
93 if (!TESTS_QUIET) printf("Trouble adding events\n");
94 test_skip(__FILE__,__LINE__, "No counters available", 0 );
95 }
96 *len = real_len;
97}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
get information about the system hardware
initialize the PAPI library.
Initialize multiplex support in the PAPI library.
Query if PAPI event exists.
Set the default counting domain for new event sets bound to the cpu component.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_DOM_ALL
Definition: f90papi.h:261
int preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:31
int power6_preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:28
int solaris_preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:25
Hardware info structure.
Definition: papi.h:774
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 420 of file multiplex1.c.

421{
422
423 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
424
425 if (!TESTS_QUIET) {
426 printf( "case1: Does PAPI_multiplex_init() not break regular operation?\n" );
427 }
428 case1( );
429
430 if (!TESTS_QUIET) {
431 printf( "\ncase2: Does setmpx/add work?\n" );
432 }
433 case2( );
434
435 if (!TESTS_QUIET) {
436 printf( "\ncase3: Does add/setmpx work?\n" );
437 }
438 case3( );
439
440 if (!TESTS_QUIET) {
441 printf( "\ncase4: Does add/setmpx/add work?\n" );
442 }
443 case4( );
444
445 if (!TESTS_QUIET) {
446 printf( "\ncase5: Does setmpx/add/add/start/read work?\n" );
447 }
448 case5( );
449
450 test_pass( __FILE__ );
451
452 return 0;
453}
int case1(void)
Definition: multiplex1.c:102
int case2(void)
Definition: multiplex1.c:151
int case3(void)
Definition: multiplex1.c:215
int case5(void)
Definition: multiplex1.c:336
int case4(void)
Definition: multiplex1.c:274
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
Here is the call graph for this function:

Variable Documentation

◆ PAPI_events

int PAPI_events[TOTAL_EVENTS] = { 0, }
static

Definition at line 35 of file multiplex1.c.

◆ PAPI_events_len

int PAPI_events_len = 0
static

Definition at line 36 of file multiplex1.c.

◆ power6_preset_PAPI_events

int power6_preset_PAPI_events[TOTAL_EVENTS]
Initial value:
= {
}
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_L1_DCM
Definition: f90papi.h:364
#define PAPI_FP_INS
Definition: f90papi.h:366
#define PAPI_L1_ICM
Definition: f90papi.h:392

Definition at line 28 of file multiplex1.c.

◆ preset_PAPI_events

int preset_PAPI_events[TOTAL_EVENTS]
Initial value:

Definition at line 31 of file multiplex1.c.

◆ solaris_preset_PAPI_events

int solaris_preset_PAPI_events[TOTAL_EVENTS]
Initial value:
= {
}
#define PAPI_BR_MSP
Definition: f90papi.h:337
#define PAPI_L2_TCM
Definition: f90papi.h:320

Definition at line 25 of file multiplex1.c.