PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

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;
28  PAPI_event_info_t pset;
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 
38  retval = PAPI_multiplex_init( );
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
47  retval = PAPI_create_eventset( &EventSet );
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 */
59  retval = PAPI_assign_eventset_component( EventSet, 0 );
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 
69  retval = PAPI_set_multiplex( EventSet );
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 
90  i = PAPI_PRESET_MASK;
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 
133  retval = PAPI_stop( EventSet, values );
134  if ( retval != PAPI_OK )
135  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
136 
137  nev = j;
138  retval = PAPI_list_events( EventSet, events, &nev );
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 
179  retval = PAPI_cleanup_eventset( EventSet );
180  if ( retval != PAPI_OK )
181  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
182 
183  retval = PAPI_destroy_eventset( &EventSet );
184  if ( retval != PAPI_OK )
185  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
186 
187  return ( SUCCESS );
188 }
unsigned int count
Definition: papi.h:987
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_ENOSUPP
Definition: papi.h:271
#define PAPI_NULL
Definition: papi.h:292
void do_stuff(void)
Definition: do_loops.c:256
#define PAPI_DOM_KERNEL
Definition: papi.h:300
#define TAB1
Definition: papi_test.h:88
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1152
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define SUCCESS
Definition: do_loops.h:5
#define PAPI_PRESET_MASK
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char events[MAX_EVENTS][BUFSIZ]
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
free(dummyfile[xx])
int k
Definition: iozone.c:19136
long long
Definition: iozone.c:19827
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:439
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1526
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
int PAPI_multiplex_init(void)
Definition: papi.c:2982
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int
Definition: iozone.c:18528
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3333
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int PAPI_set_domain(int domain)
Definition: papi.c:5688
int PAPI_start(int EventSet)
Definition: papi.c:2096
long j
Definition: iozone.c:19135
unsigned int event_code
Definition: papi.h:964
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:995
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:6001

Here is the call graph for this function:

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 }
void test_pass(const char *filename)
Definition: test_utils.c:432
#define NUM_ITERS
Definition: multiplex.c:19
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
int quiet
Definition: rapl_overflow.c:18
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
int case1(void)
Definition: multiplex1.c:102

Here is the call graph for this function: