PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_flips.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * This example demonstrates the usage of the high level function PAPI_flips *
3  * which measures the number of floating point instructions executed and the *
4  * MegaFlop rate(defined as the number of floating point instructions per *
5  * microsecond). To use PAPI_flips you need to have floating point *
6  * instructions event supported by the platform. *
7  *****************************************************************************/
8 
9 /*****************************************************************************
10  * The first call to PAPI_flips initializes the PAPI library, set up the *
11  * counters to monitor PAPI_FP_INS and PAPI_TOT_CYC events, and start the *
12  * counters. Subsequent calls will read the counters and return total real *
13  * time, total process time, total floating point instructions, and the *
14  * Mflins/s rate since the last call to PAPI_flips. *
15  *****************************************************************************/
16 
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include "papi.h"
21 
22 
24 {
25  float real_time, proc_time,mflips;
26  long long flpins;
27  float ireal_time, iproc_time, imflips;
28  long long iflpins;
29  int retval;
30 
31  /***********************************************************************
32  * if PAPI_FP_INS is a derived event in your platform, then your *
33  * platform must have at least three counters to support PAPI_flips, *
34  * because PAPI needs one counter to cycles. So in UltraSparcIII, even *
35  * the platform supports PAPI_FP_INS, but UltraSparcIII only have two *
36  * available hardware counters and PAPI_FP_INS is a derived event in *
37  * this platform, so PAPI_flops returns an error. *
38  ***********************************************************************/
39 
40  if((retval=PAPI_flips(&ireal_time,&iproc_time,&iflpins,&imflips)) < PAPI_OK)
41  {
42  printf("Could not initialise PAPI_flips \n");
43  printf("Your platform may not support floating point instruction event.\n"); printf("retval: %d\n", retval);
44  exit(1);
45  }
46 
48 
49 
50  if((retval=PAPI_flips( &real_time, &proc_time, &flpins, &mflips))<PAPI_OK)
51  {
52  printf("retval: %d\n", retval);
53  exit(1);
54  }
55 
56 
57  printf("Real_time: %f Proc_time: %f Total flpins: %lld MFLIPS: %f\n",
58  real_time, proc_time,flpins,mflips);
59 
60  exit(0);
61 }
62 
64 {
65  int i;
66  double tmp=1.1;
67 
68  for(i=1; i<2000; i++)
69  {
70  tmp=(tmp+100)/i;
71  }
72  return 0;
73 }
74 
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 PAPI_flips(float *rtime, float *ptime, long long *flpins, float *mflips)
Definition: papi_hl.c:204
int i
Definition: fileop.c:140
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()