PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
max_multiplex.c File Reference
Include dependency graph for max_multiplex.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 11 of file max_multiplex.c.

11  {
12 
13  int retval,max_multiplex,i,EventSet=PAPI_NULL;
14  PAPI_event_info_t info;
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 
27  retval = PAPI_multiplex_init( );
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 
42  retval = PAPI_create_eventset( &EventSet );
43  if ( retval != PAPI_OK ) {
44  test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
45  }
46 
47  retval = PAPI_assign_eventset_component( EventSet, 0 );
48  if ( retval != PAPI_OK ) {
49  test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component",
50  retval );
51  }
52 
53  retval = PAPI_set_multiplex( EventSet );
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 
67  retval = PAPI_add_event( EventSet, info.event_code );
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 
77  } while (PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK );
78 
79  PAPI_shutdown( );
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 }
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
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 PAPI_PRESET_MASK
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4461
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:439
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_multiplex_init(void)
Definition: papi.c:2982
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3333
unsigned int event_code
Definition: papi.h:964
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225

Here is the call graph for this function: