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

Go to the source code of this file.

Functions

static int case1 (void)
 
int main (int argc, char **argv)
 

Function Documentation

◆ case1()

static int case1 ( void  )
static

Definition at line 23 of file multiplex2.c.

24{
25 int retval, i, EventSet = PAPI_NULL, j = 0, k = 0, allvalid = 1;
26 int max_mux, nev, *events;
27 long long *values;
29 char evname[PAPI_MAX_STR_LEN];
30
31 /* Initialize PAPI */
32
34 if ( retval != PAPI_VER_CURRENT ) {
35 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
36 }
37
39 if ( retval != PAPI_OK ) {
40 test_fail( __FILE__, __LINE__, "PAPI multiplex init fail\n", retval );
41 }
42
43#if 0
45 test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
46#endif
48 if ( retval != PAPI_OK ) {
49 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
50 }
51
52#if 0
54 test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
55#endif
56 /* In Component PAPI, EventSets must be assigned a component index
57 before you can fiddle with their internals.
58 0 is always the cpu component */
60 if ( retval != PAPI_OK ) {
61 test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
62 retval );
63 }
64#if 0
66 test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
67#endif
68
70 if ( retval == PAPI_ENOSUPP) {
71 test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
72 }
73 else if ( retval != PAPI_OK ) {
74 test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
75 }
76
77 max_mux = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
78 if ( max_mux > 32 ) max_mux = 32;
79
80#if 0
82 test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
83#endif
84
85 /* Fill up the event set with as many non-derived events as we can */
86 if (!TESTS_QUIET) {
87 printf( "\nFilling the event set with as many non-derived events as we can...\n" );
88 }
89
91 do {
92 if ( PAPI_get_event_info( i, &pset ) == PAPI_OK ) {
93 if ( pset.count && ( strcmp( pset.derived, "NOT_DERIVED" ) == 0 ) ) {
94 retval = PAPI_add_event( EventSet, ( int ) pset.event_code );
95 if ( retval != PAPI_OK ) {
96 printf("Failed trying to add %s\n",pset.symbol);
97 break;
98 }
99 else {
100 if (!TESTS_QUIET) printf( "Added %s\n", pset.symbol );
101 j++;
102 }
103 }
104 }
105 } while ( ( PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK ) &&
106 ( j < max_mux ) );
107
108 if (j==0) {
109 if (!TESTS_QUIET) printf("No events found\n");
110 test_skip(__FILE__,__LINE__,"No events",0);
111 }
112
113 events = ( int * ) malloc( ( size_t ) j * sizeof ( int ) );
114 if ( events == NULL )
115 test_fail( __FILE__, __LINE__, "malloc events", 0 );
116
117 values = ( long long * ) malloc( ( size_t ) j * sizeof ( long long ) );
118 if ( values == NULL )
119 test_fail( __FILE__, __LINE__, "malloc values", 0 );
120
121 do_stuff( );
122
123#if 0
125 test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
126#endif
127
128 if ( PAPI_start( EventSet ) != PAPI_OK )
129 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
130
131 do_stuff( );
132
134 if ( retval != PAPI_OK )
135 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
136
137 nev = j;
139 if ( retval != PAPI_OK )
140 test_fail( __FILE__, __LINE__, "PAPI_list_events", retval );
141
142 if (!TESTS_QUIET) printf( "\nEvent Counts:\n" );
143 for ( i = 0, allvalid = 0; i < j; i++ ) {
144 PAPI_event_code_to_name( events[i], evname );
145 if (!TESTS_QUIET) printf( TAB1, evname, values[i] );
146 if ( values[i] == 0 )
147 allvalid++;
148 }
149 if (!TESTS_QUIET) {
150 printf( "\n" );
151 if ( allvalid ) {
152 printf( "Caution: %d counters had zero values\n", allvalid );
153 }
154 }
155
156 if (allvalid==j) {
157 test_fail( __FILE__, __LINE__, "All counters returned zero", 5 );
158 }
159
160 for ( i = 0, allvalid = 0; i < j; i++ ) {
161 for ( k = i + 1; k < j; k++ ) {
162 if ( ( i != k ) && ( values[i] == values[k] ) ) {
163 allvalid++;
164 break;
165 }
166 }
167 }
168
169 if (!TESTS_QUIET) {
170 if ( allvalid ) {
171 printf( "Caution: %d counter pair(s) had identical values\n",
172 allvalid );
173 }
174 }
175
176 free( events );
177 free( values );
178
180 if ( retval != PAPI_OK )
181 test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
182
184 if ( retval != PAPI_OK )
185 test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
186
187 return ( SUCCESS );
188}
int i
add PAPI preset or native hardware event to an event set
Assign a component index to an existing but empty EventSet.
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Enumerate PAPI preset or native events.
Convert a numeric hardware event code to a name.
Get the event's name and description info.
Get PAPI library or event set options.
initialize the PAPI library.
list the events in an event set
Initialize multiplex support in the PAPI library.
Set the default counting domain for new event sets bound to the cpu component.
Convert a standard event set to a multiplexed event set.
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_MAX_MPX_CTRS
Definition: f90papi.h:172
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_ENOSUPP
Definition: f90papi.h:244
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
char events[MAX_EVENTS][BUFSIZ]
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
int TESTS_QUIET
Definition: test_utils.c:18
#define PAPI_PRESET_MASK
@ PAPI_PRESET_ENUM_AVAIL
Definition: papi.h:490
#define TAB1
Definition: papi_test.h:98
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int
Definition: sde_internal.h:89
long long int long long
Definition: sde_internal.h:85
unsigned int count
Definition: papi.h:981
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:989
int retval
Definition: zero_fork.c:53
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 191 of file multiplex2.c.

192{
193 int quiet;
194
195 /* Set TESTS_QUIET variable */
196 quiet = tests_quiet( argc, argv );
197
198 if (!quiet) {
199 printf( "%s: Does PAPI_multiplex_init() handle lots of events?\n",
200 argv[0] );
201 printf( "Using %d iterations\n", NUM_ITERS );
202 }
203
204 case1( );
205 test_pass( __FILE__ );
206
207 return 0;
208}
static int case1(void)
Definition: multiplex2.c:23
#define NUM_ITERS
Definition: multiplex.c:19
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
int quiet
Definition: rapl_overflow.c:19
Here is the call graph for this function: