PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_ipc.c
Go to the documentation of this file.
1/*****************************************************************************
2 * This example demonstrates the usage of the function PAPI_ipc which *
3 * 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 real time, *
10 * process time, instructions, and the instructions per cycle rate since the *
11 * latest call to PAPI_ipc. *
12 *****************************************************************************/
13
14
15#include <stdio.h>
16#include <stdlib.h>
17#include "papi.h"
18
19int your_slow_code();
20
21int main()
22{
23 float real_time, proc_time,ipc;
24 long long ins;
25 float real_time_i, proc_time_i, ipc_i;
26 long long ins_i;
27 int retval;
28
29 if((retval=PAPI_ipc(&real_time_i,&proc_time_i,&ins_i,&ipc_i)) < PAPI_OK)
30 {
31 printf("Could not initialise PAPI_ipc \n");
32 printf("retval: %d\n", retval);
33 exit(1);
34 }
35
37
38
39 if((retval=PAPI_ipc( &real_time, &proc_time, &ins, &ipc))<PAPI_OK)
40 {
41 printf("retval: %d\n", retval);
42 exit(1);
43 }
44
45
46 printf("Real_time: %f Proc_time: %f Instructions: %lld IPC: %f\n",
47 real_time, proc_time,ins,ipc);
48
49 /* clean up */
51 exit(0);
52}
53
55{
56 int i;
57 double tmp=1.1;
58
59 for(i=1; i<2000; i++)
60 {
61 tmp=(tmp+100)/i;
62 }
63 return 0;
64}
65
double tmp
int i
int your_slow_code()
Definition: PAPI_ipc.c:54
int main()
Definition: PAPI_ipc.c:21
Simplified call to get instructions per cycle, real and processor time.
Finish using PAPI and free all related resources.
#define PAPI_OK
Definition: f90papi.h:73
Return codes and api definitions.
int retval
Definition: zero_fork.c:53