PAPI  5.7.0.0
PAPI_get_opt.c File Reference
Include dependency graph for PAPI_get_opt.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 12 of file PAPI_get_opt.c.

Function Documentation

◆ main()

int main ( )

Definition at line 26 of file PAPI_get_opt.c.

27 {
28 
29  int num, retval, EventSet = PAPI_NULL;
31  long long values[2];
32 
33  /****************************************************************************
34  * This part initializes the library and compares the version number of the *
35  * header file, to the version of the library, if these don't match then it *
36  * is likely that PAPI won't work correctly.If there is an error, retval *
37  * keeps track of the version number. *
38  ****************************************************************************/
39 
41  {
42  printf("Library initialization error! \n");
43  exit(1);
44  }
45 
46  /*PAPI_get_opt returns a negative number if there is an error */
47 
48  /* This call returns the maximum available hardware counters */
49  if((num = PAPI_get_opt(PAPI_MAX_HWCTRS,NULL)) <= 0)
50  ERROR_RETURN(num);
51 
52 
53  printf("This machine has %d counters.\n",num);
54 
57 
58  /* Set the domain of this EventSet to counter user and
59  kernel modes for this process. */
60 
61  memset(&options,0x0,sizeof(options));
62 
63  options.domain.eventset = EventSet;
64  /* Default domain is PAPI_DOM_USER */
65  options.domain.domain = PAPI_DOM_ALL;
66  /* this sets the options for the domain */
69  /* Add Total Instructions Executed event to the EventSet */
72 
73  /* Add Total Cycles Executed event to the EventSet */
76 
77  /* Start counting */
80 
82 
83  /* Stop counting */
86 
87  printf(" Total instructions: %lld Total Cycles: %lld \n", values[0],
88  values[1]);
89 
90  /* clean up */
91  PAPI_shutdown();
92 
93  exit(0);
94 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#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
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3465
int poorly_tuned_function()
Definition: PAPI_get_opt.c:14
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
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
#define PAPI_MAX_HWCTRS
Definition: fpapi.h:58
static options_t options
#define PAPI_DOMAIN
Definition: fpapi.h:50
#define ERROR_RETURN(retval)
Definition: PAPI_get_opt.c:12
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 14 of file PAPI_get_opt.c.

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