PAPI  5.4.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 9 of file max_multiplex.c.

9  {
10 
11  int retval,max_multiplex,i,EventSet=PAPI_NULL;
12  PAPI_event_info_t info;
13  int added=0;
14  int events_tried=0;
15 
16  /* Set TESTS_QUIET variable */
17  tests_quiet( argc, argv );
18 
19  /* Initialize the library */
21  if ( retval != PAPI_VER_CURRENT ) {
22  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
23  }
24 
25  retval = PAPI_multiplex_init( );
26  if ( retval != PAPI_OK) {
27  test_fail(__FILE__, __LINE__, "Multiplex not supported", 1);
28  }
29 
30  max_multiplex=PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
31 
32  if (!TESTS_QUIET) {
33  printf("Maximum multiplexed counters=%d\n",max_multiplex);
34  }
35 
36  if (!TESTS_QUIET) {
37  printf("Trying to multiplex as many as possible:\n");
38  }
39 
40  retval = PAPI_create_eventset( &EventSet );
41  if ( retval != PAPI_OK ) {
42  test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
43  }
44 
45  retval = PAPI_assign_eventset_component( EventSet, 0 );
46  if ( retval != PAPI_OK ) {
47  test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component",
48  retval );
49  }
50 
51  retval = PAPI_set_multiplex( EventSet );
52  if ( retval != PAPI_OK ) {
53  test_fail(__FILE__, __LINE__, "PAPI_create_multiplex", retval );
54  }
55 
56 
57  i = 0 | PAPI_PRESET_MASK;
59  do {
60  retval = PAPI_get_event_info( i, &info );
61  if (retval==PAPI_OK) {
62  if (!TESTS_QUIET) printf("Adding %s: ",info.symbol);
63  }
64 
65  retval = PAPI_add_event( EventSet, info.event_code );
66  if (retval!=PAPI_OK) {
67  if (!TESTS_QUIET) printf("Fail!\n");
68  }
69  else {
70  if (!TESTS_QUIET) printf("Success!\n");
71  added++;
72  }
73  events_tried++;
74 
75  } while (PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK );
76 
77  PAPI_shutdown( );
78 
79  if (!TESTS_QUIET) {
80  printf("Added %d of theoretical max %d\n",added,max_multiplex);
81  }
82 
83  if (events_tried<max_multiplex) {
84  if (!TESTS_QUIET) {
85  printf("Ran out of events before we ran out of room\n");
86  }
87  }
88  else if (added!=max_multiplex) {
89  test_fail(__FILE__, __LINE__,
90  "Couldn't max out multiplexed events", 1);
91  }
92 
93  test_pass( __FILE__, NULL, 0 );
94  exit( 0 );
95 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1150
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define PAPI_PRESET_MASK
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4400
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4082
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:437
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1485
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_multiplex_init(void)
Definition: papi.c:2926
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3277
unsigned int event_code
Definition: papi.h:961
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
void exit()

Here is the call graph for this function: