PAPI 7.1.0.0
Loading...
Searching...
No Matches
max_multiplex.c
Go to the documentation of this file.
1/* this tests attempts to add the maximum number of pre-defined events */
2/* to a multiplexed event set. This tests that we properly set the */
3/* maximum events value. */
4
5#include <stdio.h>
6#include <stdlib.h>
7
8#include "papi.h"
9#include "papi_test.h"
10
11int main(int argc, char **argv) {
12
13 int retval,max_multiplex,i,EventSet=PAPI_NULL;
15 int added=0;
16 int events_tried=0;
17
18 /* Set TESTS_QUIET variable */
19 tests_quiet( argc, argv );
20
21 /* Initialize the library */
23 if ( retval != PAPI_VER_CURRENT ) {
24 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
25 }
26
28 if ( retval != PAPI_OK) {
29 test_fail(__FILE__, __LINE__, "Multiplex not supported", 1);
30 }
31
32 max_multiplex=PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
33
34 if (!TESTS_QUIET) {
35 printf("Maximum multiplexed counters=%d\n",max_multiplex);
36 }
37
38 if (!TESTS_QUIET) {
39 printf("Trying to multiplex as many as possible:\n");
40 }
41
43 if ( retval != PAPI_OK ) {
44 test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
45 }
46
48 if ( retval != PAPI_OK ) {
49 test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component",
50 retval );
51 }
52
54 if ( retval != PAPI_OK ) {
55 test_fail(__FILE__, __LINE__, "PAPI_create_multiplex", retval );
56 }
57
58
59 i = 0 | PAPI_PRESET_MASK;
61 do {
62 retval = PAPI_get_event_info( i, &info );
63 if (retval==PAPI_OK) {
64 if (!TESTS_QUIET) printf("Adding %s: ",info.symbol);
65 }
66
68 if (retval!=PAPI_OK) {
69 if (!TESTS_QUIET) printf("Fail!\n");
70 }
71 else {
72 if (!TESTS_QUIET) printf("Success!\n");
73 added++;
74 }
75 events_tried++;
76
78
80
81 if (!TESTS_QUIET) {
82 printf("Added %d of theoretical max %d\n",added,max_multiplex);
83 }
84
85 if (events_tried<max_multiplex) {
86 if (!TESTS_QUIET) {
87 printf("Ran out of events before we ran out of room\n");
88 }
89 }
90 else if (added!=max_multiplex) {
91 test_fail(__FILE__, __LINE__,
92 "Couldn't max out multiplexed events", 1);
93 }
94
95 test_pass( __FILE__ );
96
97 return 0;
98
99}
100
int i
add PAPI preset or native hardware event to an event set
Assign a component index to an existing but empty EventSet.
Create a new empty PAPI EventSet.
Enumerate PAPI preset or native events.
Get the event's name and description info.
Get PAPI library or event set options.
initialize the PAPI library.
Initialize multiplex support in the PAPI library.
Convert a standard event set to a multiplexed event set.
Finish using PAPI and free all related resources.
#define PAPI_MAX_MPX_CTRS
Definition: f90papi.h:172
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_NULL
Definition: f90papi.h:78
static int EventSet
Definition: init_fini.c:8
int TESTS_QUIET
Definition: test_utils.c:18
#define PAPI_PRESET_MASK
Return codes and api definitions.
@ PAPI_PRESET_ENUM_AVAIL
Definition: papi.h:490
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
int main()
Definition: pernode.c:20
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
int retval
Definition: zero_fork.c:53