PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_ipc.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * This example demonstrates the usage of the high level function PAPI_ipc *
3  * which measures the number of instructions executed per cpu cycle *
4  *****************************************************************************/
5 
6 /*****************************************************************************
7  * The first call to PAPI_ipc initializes the PAPI library, set up the *
8  * counters to monitor PAPI_TOT_INS and PAPI_TOT_CYC events, and start the *
9  * counters. Subsequent calls will read the counters and return total real *
10  * time, total process time, total instructions, and the instructions per *
11  * cycle rate since the last call to PAPI_ipc. *
12  *****************************************************************************/
13 
14 
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "papi.h"
18 
19 
21 {
22  float real_time, proc_time,ipc;
23  long long ins;
24  float real_time_i, proc_time_i, ipc_i;
25  long long ins_i;
26  int retval;
27 
28  if((retval=PAPI_ipc(&real_time_i,&proc_time_i,&ins_i,&ipc_i)) < PAPI_OK)
29  {
30  printf("Could not initialise PAPI_ipc \n");
31  printf("retval: %d\n", retval);
32  exit(1);
33  }
34 
36 
37 
38  if((retval=PAPI_ipc( &real_time, &proc_time, &ins, &ipc))<PAPI_OK)
39  {
40  printf("retval: %d\n", retval);
41  exit(1);
42  }
43 
44 
45  printf("Real_time: %f Proc_time: %f Total instructions: %lld IPC: %f\n",
46  real_time, proc_time,ins,ipc);
47 
48  /* clean up */
49  PAPI_shutdown();
50  exit(0);
51 }
52 
54 {
55  int i;
56  double tmp=1.1;
57 
58  for(i=1; i<2000; i++)
59  {
60  tmp=(tmp+100)/i;
61  }
62  return 0;
63 }
64 
int PAPI_ipc(float *rtime, float *ptime, long long *ins, float *ipc)
Definition: papi_hl.c:316
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
Return codes and api definitions.
int your_slow_code()
Definition: PAPI_flips.c:63
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4357
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
int main(int argc, char **argv)
List all appio events codes and names.
void exit()