PAPI  5.7.0.0
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 */
125  PAPI_shutdown();
126 
127  exit(0);
128 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int close(int fd)
Definition: appio.c:175
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
int fd
Definition: iozone.c:1291
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int EventSet
int retval
Definition: zero_fork.c:53
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:849
#define ERROR_RETURN(retval)
int poorly_tuned_function()
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
int PAPI_library_init(int version)
Definition: papi.c:500
#define PAPI_TOT_INS
Definition: fpapi.h:186
void PAPI_shutdown(void)
Definition: papi.c:4461
#define PAPI_DOM_USER
Definition: fpapi.h:21
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
static options_t options
int PAPI_set_domain(int domain)
Definition: papi.c:5688
int PAPI_start(int EventSet)
Definition: papi.c:2096
#define PAPI_TOT_CYC
Definition: fpapi.h:195
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void exit()
#define PAPI_DOM_ALL
Definition: fpapi.h:25
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
Definition: fileop.c:140
Here is the caller graph for this function: