-
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 (int event, float *rtime, float *ptime, long long *flpops, float *mflops) | PAPIF_flops_rate (c_string EventName, c_float real_time, c_float proc_time, c_long_long flpops, c_float mflops, c_int check) | Simplified call to get Mflops/s (floating point operation rate), real and processor time. |
PAPI_flips_rate (int event, float *rtime, float *ptime, long long *flpins, float *mflips) | PAPIF_flips_rate (c_string EventName, c_float real_time, c_float proc_time, c_long_long flpins, c_float mflips, c_int check) | Simplified call to get Mflips/s (floating point instruction rate), real and processor time. |
PAPI_epc (int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc) | PAPIF_epc (c_string EventName, c_float real_time, c_float proc_time, c_long_long ref, c_long_long core, c_long_long evt, c_float epc, c_int check) | Simplified call to get arbitrary events per cycle, real and processor time. |
PAPI_ipc (float *rtime, float *ptime, long long * ins, float *ipc) | PAPIF_ipc (c_float real_time, c_float proc_time, c_long_long ins, c_float ipc, c_int check) | Simplified call to get instructions per cycle, real and processor time. |
PAPI_rate_stop (void) | PAPIF_rate_stop (c_int check) | 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.