Wiki

Clone wiki

papi / PAPI-Rates

Simplified Rate Functions

PAPI provides the following rate functions:

Function Name Description
PAPI_flops_rate Simplified call to get Mflops/s (floating point operation rate), real and processor time.
PAPI_flips_rate Simplified call to get Mflips/s (floating point instruction rate), real and processor time.
PAPI_epc Simplified call to get arbitrary events per cycle, real and processor time.
PAPI_ipc Simplified call to get instructions per cycle, real and processor time.
PAPI_rate_stop Stop a running event set of a rate function

Hint: Click on a specific function to get a more detailed description.

The first call of a rate function will initialize the PAPI interface (if not already done), set up the counters to monitor and start the counters. Subsequent calls will read the counters and return values since the latest matching call. Nesting between different rate functions is not allowed as this will destroy the event set from the previous rate function.

Note that all rate functions are thread-safe and can therefore be called by multiple threads. If the programmer wants to mix rate and low-level API calls, he must call PAPI_rate_stop() if low-level calls are used after a rate call.

Example

The following code example shows how to get Mflops/s (floating point operation rate).

#include <stdio.h>
#include <stdlib.h>
#include "papi.h"

int main()
{ 
  float real_time, proc_time, mflops;
  long long flpops;
  int retval;

  if ( (retval = PAPI_flops_rate(PAPI_FP_OPS, &real_time, &proc_time, &flpops, &mflops)) < PAPI_OK )
  { 
    printf("Could not initialise PAPI_flops \n");
    printf("Your platform may not support floating point operation event.\n"); 
    printf("retval: %d\n", retval);
    exit(1);
  }

  your_slow_code();


  if ( (retval = PAPI_flops_rate(PAPI_FP_OPS, &real_time, &proc_time, &flpops, &mflops)) < PAPI_OK )
  {    
    printf("retval: %d\n", retval);
    exit(1);
  }


  printf("Real_time: %f Proc_time: %f flpops: %lld MFLOPS: %f\n", 
         real_time, proc_time, flpops, mflops);

  exit(0);
}

Possible output

Real_time: 0.000053 Proc_time: 0.000052 flpops: 7976 MFLOPS: 153.384613

Updated