PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_set_domain.c File Reference
Include dependency graph for PAPI_set_domain.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); }
 

Functions

int poorly_tuned_function ()
 
int main ()
 

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 13 of file PAPI_set_domain.c.

Function Documentation

◆ main()

int main ( )

Definition at line 27 of file PAPI_set_domain.c.

28{
29
30 int num, retval, EventSet = PAPI_NULL;
31 long long values[2];
33 int fd;
34
35
36 /****************************************************************************
37 * This part initializes the library and compares the version number of the *
38 * header file, to the version of the library, if these don't match then it *
39 * is likely that PAPI won't work correctly.If there is an error, retval *
40 * keeps track of the version number. *
41 ****************************************************************************/
42
44 {
45 printf("Library initialization error! \n");
46 exit(1);
47 }
48
49 /* Set the domain of this EventSet to counter user mode. The domain
50 will be valid for all the eventset created after this function call
51 unless you call PAPI_set_domain again */
54
57
58 /* Add Total Instructions Executed event to the EventSet */
61
62 /* Add Total Cycles Executed event to the EventSet */
65
66 /* Start counting */
69
71 /* add some system calls */
72 fd = open("/dev/zero", O_RDONLY);
73 if (fd == -1)
74 {
75 perror("open(/dev/zero)");
76 exit(1);
77 }
78 close(fd);
79
80
81 /* Stop counting */
84
85 printf(" Total instructions: %lld Total Cycles: %lld \n", values[0],
86 values[1]);
87
88 /* Set the domain of this EventSet to counter user and kernel modes */
91
95
96 /* Add Total Instructions Executed to our EventSet */
99
100 /* Add Total Instructions Executed to our EventSet */
103 /* Start counting */
106
108 /* add some system calls */
109 fd = open("/dev/zero", O_RDONLY);
110 if (fd == -1)
111 {
112 perror("open(/dev/zero)");
113 exit(1);
114 }
115 close(fd);
116
117 /* Stop counting */
120
121 printf(" Total instructions: %lld Total Cycles: %lld \n", values[0],
122 values[1]);
123
124 /* clean up */
126
127 exit(0);
128}
int poorly_tuned_function()
#define ERROR_RETURN(retval)
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:188
int close(int fd)
Definition: appio.c:179
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
initialize the PAPI library.
Set the default counting domain for new event sets bound to the cpu component.
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_DOM_USER
Definition: f90papi.h:174
#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_TOT_INS
Definition: f90papi.h:317
#define PAPI_DOM_ALL
Definition: f90papi.h:261
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
static options_t options
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:843
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ poorly_tuned_function()

int poorly_tuned_function ( )

Definition at line 15 of file PAPI_set_domain.c.

16{
17 float tmp;
18 int i;
19
20 for(i=1; i<2000; i++)
21 {
22 tmp=(tmp+100)/i;
23 }
24 return 0;
25}
double tmp
int i
Here is the caller graph for this function: