-
Notifications
You must be signed in to change notification settings - Fork 55
PAPI Rates
PAPI provides the following rate functions in both C and Fortran:
int event;
float real_time, proc_time, mflops;
long long flpops;
int retval = PAPI_flops_rate(event, &real_time, &proc_time, &flpops, &mflops);
Arguments for PAPI_flops_rate
:
- event -- one of the three presets PAPI_FP_OPS, PAPI_SP_OPS or PAPI_DP_OPS.
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- flops -- floating point operations since the latest call.
- mflops -- incremental (Mega) floating point operations per seconds since the latest call.
int event;
float real_time, proc_time, mflips;
long long flpins;
int retval = PAPI_flips_rate(event, &real_time, &proc_time, &flpins, &mflips);
Arguments for PAPI_flips_rate
:
- event -- one of the three presets PAPI_FP_INS, PAPI_VEC_SP or PAPI_VEC_DP.
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- flpins -- floating point instructions since the latest call.
- mflips -- incremental (Mega) floating point instructions per seconds since the latest call.
int event;
float real_time, proc_time, epc;
long long ref, core, evt;
int retval = PAPI_epc(event, &real_time, &proc_time, &ref, &core, &evt, &epc);
Arguments for PAPI_epc
:
- event -- event code to be measured (0 defaults to PAPI_TOT_INS).
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- ref -- incremental reference clock cycles since the latest call.
- core -- incremental core clock cycles since the latest call.
- evt -- events since the latest call.
- epc -- incremental events per cycle since the latest call.
float real_time, proc_time, ipc;
long long ins;
int retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc);
Arguments for PAPI_ipc
:
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- ins -- instructions since the latest call.
- ipc -- incremental instructions per cycle since the latest call.
int retval = PAPI_rate_stop();
No arguments for PAPI_rate_stop
.
use iso_c_binding
integer(C_int) EventCode, check
real(c_float) real_time, proc_time, mflops
integer(c_long_long) flpops
call PAPIF_flops_rate(EventCode, real_time, proc_time,
& flpops, mflops, check)
Fortran arguments for PAPIF_flops_rate
:
- EventCode -- one of the three presets PAPI_FP_OPS, PAPI_SP_OPS or PAPI_DP_OPS.
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- flpops -- floating point operations since the latest call.
- mflops -- incremental (Mega) floating point operations per seconds since the latest call.
- check -- an error return value for Fortran.
use iso_c_binding
integer(c_int) EventCode, check
real(c_float) real_time, proc_time, mflips
integer(c_long_long) flpins
call PAPIF_flips_rate(EventCode, real_time, proc_time,
& flpins, mflips, check);
Fortran arguments for PAPIF_flips_rate
:
- EventCode -- one of the three presets PAPI_FP_INS, PAPI_VEC_SP or PAPI_VEC_DP.
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- flpins -- floating point instructions since the latest call.
- mflips -- incremental (Mega) floating point instructions per seconds since the latest call.
- check -- an error return value for Fortran.
use iso_c_binding
integer(c_int) EventCode, check
real(c_float) real_time, proc_time, epc
integer(c_long_long) ref, core, evt
call PAPIF_epc(EventCode, real_time, proc_time,
& ref, core, evt, epc, check)
Fortran arguments for PAPIF_epc
:
- EventCode -- event code to be measured (0 defaults to PAPI_TOT_INS).
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- ref -- incremental reference clock cycles since the latest call.
- core -- incremental core clock cycles since the latest call.
- evt -- events since the latest call.
- epc -- incremental events per cycle since the latest call.
- check -- an error return value for Fortran.
use iso_c_binding
real(c_float) real_time, proc_time, ipc
integer(c_long_long) ins
integer(c_int) check
call PAPIF_ipc(real_time, proc_time, ins, ipc, check)
Fortran arguments for PAPIF_ipc
:
- real_time -- real time since the latest call.
- proc_time -- process time since the latest call.
- ins -- instructions since the latest call.
- ipc -- incremental instructions per cycle since the latest call.
- check -- an error return value for Fortran.
use iso_c_binding
integer(c_int) check
call PAPIF_rate_stop(check)
Fortran arguments for PAPIF_rate_stop
:
- check -- an error return value for Fortran.
PAPI_flops_rate is a simplified call to get Mflops/s (floating point operation rate), real and processor time.
PAPI_flips_rate is a simplified call to get Mflips/s (floating point instruction rate), real and processor time.
PAPI_epc is a simplified call to get arbitrary events per cycle, real and processor time.
PAPI_ipc is a simplified call to get instructions per cycle, real, and processor time.
PAPI_rate_stop stops a running event set of a rate function.
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.