I face a little problem I don't understand. If I read the PAPI doc about the high level interface I get:
The values of rtime and ptime are derived from the cycle counter on the Pentium chip, and multiplied by a computed clock speed for the given processor as determined by measuring against a system real-time clock. You can stop the counters used by PAPI_flops with a call to PAPI_stop_counters. The next call to PAPI_flops will start over with fresh values for all returned parameters.
Good, now I go for a small test:
- Code: Select all
#include <stdio.h>
#include <papi.h>
void do_some_work(){
int i, maxiter;
double p;
maxiter=1000000000;
for (i=0;i<maxiter;i++){
p+=(double)i;
}
}
int main()
{
float real_time, proc_time,mflops;
long long flpops;
float ireal_time, iproc_time, imflops;
long long iflpops;
int retval;
if((retval=PAPI_flops( &real_time, &proc_time, &flpops, &mflops))<PAPI_OK){
printf("retval: %d\n", retval);
exit(1);
}
do_some_work();
if((retval=PAPI_flops( &real_time, &proc_time, &flpops, &mflops))<PAPI_OK){
printf("retval: %d\n", retval);
exit(1);
}
printf("Real_time: %f Proc_time: %f Total flpops: %lld MFLOPS: %f\n", real_time, proc_time,flpops,mflops);
if((retval=PAPI_flops( &real_time, &proc_time, &flpops, &mflops))<PAPI_OK){
printf("retval: %d\n", retval);
exit(1);
}
do_some_work();
if((retval=PAPI_flops( &real_time, &proc_time, &flpops, &mflops))<PAPI_OK){
printf("retval: %d\n", retval);
exit(1);
}
printf("Real_time: %f Proc_time: %f Total flpops: %lld MFLOPS: %f\n", real_time, proc_time,flpops,mflops);
return 0;
}
compiled through
- Code: Select all
icc test.c -o test -I/path/to/PAPI/include -L/path/to/PAPI/lib -lpapi
Execution result:
- Code: Select all
Real_time: 0.000017 Proc_time: 0.000002 Total flpops: 12 MFLOPS: 4.907976
Real_time: 0.000065 Proc_time: 0.000016 Total flpops: 35 MFLOPS: 0.000000
on my intel workstation. My question is the following: it seems that the counters are set to zero the second time, why ? Do I wrote something wrong ?
Thanks in advance for those who will help.
Cheers
Vince
