-
Notifications
You must be signed in to change notification settings - Fork 59
PAPI Rates
PAPI provides the following rate functions:
C Function Names | Fortran Function Names | Description |
---|---|---|
PAPI_flops_rate | PAPIF_flops_rate | Simplified call to get Mflops/s (floating point operation rate), real and processor time. |
PAPI_flips_rate | PAPIF_flips_rate | Simplified call to get Mflips/s (floating point instruction rate), real and processor time. |
PAPI_epc | PAPIF_epc | Simplified call to get arbitrary events per cycle, real and processor time. |
PAPI_ipc | PAPIF_ipc | Simplified call to get instructions per cycle, real and processor time. |
PAPI_rate_stop | PAPIF_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.
The following code example shows how to get Mflops/s (floating point operation rate).
#include <stdio.h>
#include <stdlib.h>
#include "papi.h"
void handle_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
}
int main()
{
float real_time, proc_time, mflops;
long long flpops;
int retval;
retval = PAPI_flops_rate(PAPI_FP_OPS, &real_time, &proc_time, &flpops, &mflops);
if (retval != PAPI_OK) {
printf("Could not initialize PAPI_flops.\n");
printf("Your platform may not support floating point operation event.\n");
handle_error(retval);
}
/* Do some computation here */
retval = PAPI_flops_rate(PAPI_FP_OPS, &real_time, &proc_time, &flpops, &mflops);
if (retval != PAPI_OK)
handle_error(retval);
/* Print real time, proc time, flpops, and MFLOPS */
printf("Real_time: %f, Proc_time: %f, flpops: %lld, MFLOPS: %f\n",
real_time, proc_time, flpops, mflops);
/* Executes if all low-level PAPI
function calls returned PAPI_OK */
printf("\033[0;32m\n\nPASSED\n\033[0m");
exit(0);
}
Real_time: 0.000053 Proc_time: 0.000052 flpops: 7976 MFLOPS: 153.384613
PASSED
On success, all PAPI functions return PAPI_OK and the possible above output is returned. On error, a non-zero error code is returned.