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

Go to the source code of this file.

Macros

#define ERROR_RETURN(retval)   { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
 
#define NUM_ITERS   10000000
 
#define MAX_TO_ADD   6
 

Functions

void do_flops (int n)
 
int multiplex (void)
 
int main (int argc, char **argv)
 

Variables

double c = 0.11
 

Macro Definition Documentation

#define ERROR_RETURN (   retval)    { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Definition at line 17 of file multiplex.c.

#define MAX_TO_ADD   6

Definition at line 20 of file multiplex.c.

#define NUM_ITERS   10000000

Definition at line 19 of file multiplex.c.

Function Documentation

void do_flops ( int  n)

Definition at line 23 of file multiplex.c.

24 {
25  int i;
26  double a = 0.5;
27  double b = 6.2;
28 
29  for (i=0; i < n; i++)
30  c += a * b;
31  return;
32 }
double c
Definition: multiplex.c:22
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int i
Definition: fileop.c:140
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
int n
Definition: mendes-alt.c:164

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 142 of file multiplex.c.

143 {
144 
145  printf("Using %d iterations\n\n", NUM_ITERS);
146  printf("Does PAPI_multiplex_init() handle lots of events?\n");
147  multiplex();
148  exit(0);
149 }
#define NUM_ITERS
Definition: multiplex.c:19
#define printf
Definition: papi_test.h:125
int multiplex(void)
Definition: multiplex.c:35
void exit()

Here is the call graph for this function:

int multiplex ( void  )

Definition at line 35 of file multiplex.c.

36 {
37  int retval, i, EventSet = PAPI_NULL, j = 0;
38  long long *values;
39  PAPI_event_info_t pset;
40  int events[MAX_TO_ADD], number;
41 
42  /* Initialize the library */
44  if (retval != PAPI_VER_CURRENT)
45  {
46  printf("Library initialization error! \n");
47  exit(1);
48  }
49 
50  /* initialize multiplex support */
51  retval = PAPI_multiplex_init();
52  if (retval != PAPI_OK)
53  ERROR_RETURN(retval);
54 
55  retval = PAPI_create_eventset(&EventSet);
56  if (retval != PAPI_OK)
57  ERROR_RETURN(retval);
58 
59  /* convert the event set to a multiplex event set */
60  retval = PAPI_set_multiplex(EventSet);
61  if (retval != PAPI_OK)
62  ERROR_RETURN(retval);
63 /*
64  retval = PAPI_add_event(EventSet, PAPI_TOT_INS);
65  if ((retval != PAPI_OK) && (retval != PAPI_ECNFLCT))
66  ERROR_RETURN(retval);
67  printf("Adding %s\n", "PAPI_TOT_INS");
68 */
69 
70  for (i = 0; i < PAPI_MAX_PRESET_EVENTS; i++)
71  {
72  retval = PAPI_get_event_info(i | PAPI_PRESET_MASK, &pset);
73  if (retval != PAPI_OK)
74  ERROR_RETURN(retval);
75 
76  if ((pset.count) && (pset.event_code != PAPI_TOT_CYC))
77  {
78  printf("Adding %s\n", pset.symbol);
79 
80  retval = PAPI_add_event(EventSet, pset.event_code);
81  if ((retval != PAPI_OK) && (retval != PAPI_ECNFLCT))
82  ERROR_RETURN(retval);
83 
84  if (retval == PAPI_OK)
85  printf("Added %s\n", pset.symbol);
86  else
87  printf("Could not add %s due to resource limitation.\n",
88  pset.symbol);
89 
90  if (retval == PAPI_OK)
91  {
92  if (++j >= MAX_TO_ADD)
93  break;
94  }
95  }
96  }
97 
98  values = (long long *) malloc(MAX_TO_ADD * sizeof(long long));
99  if (values == NULL)
100  {
101  printf("Not enough memory available. \n");
102  exit(1);
103  }
104 
105  if ((retval=PAPI_start(EventSet)) != PAPI_OK)
106  ERROR_RETURN(retval);
107 
109 
110  retval = PAPI_stop(EventSet, values);
111  if (retval != PAPI_OK)
112  ERROR_RETURN(retval);
113 
114  /* get the number of events in the event set */
115  number=MAX_TO_ADD;
116  if ( (retval = PAPI_list_events(EventSet, events, &number)) != PAPI_OK)
117  ERROR_RETURN(retval);
118 
119  /* print the read result */
120  for (i = 0; i < MAX_TO_ADD; i++)
121  {
122  retval = PAPI_get_event_info(events[i], &pset);
123  if (retval != PAPI_OK)
124  ERROR_RETURN(retval);
125  printf("Event name: %s value: %lld \n", pset.symbol, values[i]);
126  }
127 
128  retval = PAPI_cleanup_eventset(EventSet);
129  if (retval != PAPI_OK)
130  ERROR_RETURN(retval);
131 
132  retval = PAPI_destroy_eventset(&EventSet);
133  if (retval != PAPI_OK)
134  ERROR_RETURN(retval);
135 
136  /* free the resources used by PAPI */
137  PAPI_shutdown();
138 
139  return (0);
140 }
unsigned int count
Definition: papi.h:982
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define NUM_ITERS
Definition: multiplex.c:19
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:961
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_PRESET_MASK
#define printf
Definition: papi_test.h:125
#define PAPI_ECNFLCT
Definition: fpapi.h:113
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
#define MAX_TO_ADD
Definition: multiplex.c:20
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
#define PAPI_TOT_CYC
Definition: fpapi.h:194
void PAPI_shutdown(void)
Definition: papi.c:4357
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char events[MAX_EVENTS][BUFSIZ]
#define ERROR_RETURN(retval)
Definition: multiplex.c:17
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
void do_flops(int n)
Definition: multiplex.c:23
int EventSet
int PAPI_multiplex_init(void)
Definition: papi.c:2897
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
long j
Definition: iozone.c:19135
unsigned int event_code
Definition: papi.h:959
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
void exit()
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:5876

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

double c = 0.11

Definition at line 22 of file multiplex.c.