PAPI 7.1.0.0
Loading...
Searching...
No Matches
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

◆ ERROR_RETURN

#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.

◆ MAX_TO_ADD

#define MAX_TO_ADD   6

Definition at line 20 of file multiplex.c.

◆ NUM_ITERS

#define NUM_ITERS   10000000

Definition at line 19 of file multiplex.c.

Function Documentation

◆ do_flops()

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}
int i
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
double c
Definition: multiplex.c:22
Here is the caller graph for this function:

◆ main()

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
int multiplex(void)
Definition: multiplex.c:35
Here is the call graph for this function:

◆ multiplex()

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;
40 int events[MAX_TO_ADD], number;
41
42 /* Initialize the library */
45 {
46 printf("Library initialization error! \n");
47 exit(1);
48 }
49
50 /* initialize multiplex support */
52 if (retval != PAPI_OK)
54
56 if (retval != PAPI_OK)
58
59 /* convert the event set to a multiplex event set */
61 if (retval != PAPI_OK)
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 {
73 if (retval != PAPI_OK)
75
76 if ((pset.count) && (pset.event_code != PAPI_TOT_CYC))
77 {
78 printf("Adding %s\n", pset.symbol);
79
81 if ((retval != PAPI_OK) && (retval != PAPI_ECNFLCT))
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
107
109
111 if (retval != PAPI_OK)
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)
118
119 /* print the read result */
120 for (i = 0; i < MAX_TO_ADD; i++)
121 {
123 if (retval != PAPI_OK)
125 printf("Event name: %s value: %lld \n", pset.symbol, values[i]);
126 }
127
129 if (retval != PAPI_OK)
131
133 if (retval != PAPI_OK)
135
136 /* free the resources used by PAPI */
138
139 return (0);
140}
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Get the event's name and description info.
initialize the PAPI library.
list the events in an event set
Initialize multiplex support in the PAPI library.
Convert a standard event set to a multiplexed event set.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_ECNFLCT
Definition: f90papi.h:234
char events[MAX_EVENTS][BUFSIZ]
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
#define MAX_TO_ADD
Definition: multiplex.c:20
#define ERROR_RETURN(retval)
Definition: multiplex.c:17
#define PAPI_PRESET_MASK
#define PAPI_MAX_PRESET_EVENTS
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
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ c

double c = 0.11

Definition at line 22 of file multiplex.c.