Why the result I got is negative number sometimes?
I use PAPI-4.1.1 to collect the performance data in CentOS 5.5, the kernel is 2.6.34, the CPU is Intel(R) Xeon(R) CPU E5335. There are five hardware counters in this CPU, I use multiplexing to collect 17 performance data: L1/L2 instruction/data cache miss/access; TLB data miss; TLB instruction miss; Instruction; Cycle and so on. The platform support these events. Sometimes, I can get the normal result, but sometimes I get the negative number.
These are my codes, I called the similar codes at many places in one program. And the program is MPI parallel program, each core will run one process. Why can I get the negative number? Is the couter is overflowd? How can I resolve the problem? Thanks!
- Code: Select all
Int Eventset=PAPI_NULL;
/* init papi */
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
printf ("version wrong\n");
if (PAPI_multiplex_init() != PAPI_OK)
printf ("multiplex int wrong\n");
if (PAPI_create_eventset(&Eventset) != PAPI_OK)
printf ("create event set wrong\n");
if (PAPI_set_multiplex(Eventset) != PAPI_OK)
printf ("convert eventset to multiplex wrong\n");
/* add events */
if (PAPI_add_event(Eventset,PAPI_L1_DCM)!=PAPI_OK)
printf ("wrong\n");
……
/* start */
if (PAPI_start(Eventset) != PAPI_OK)
printf("PAPI start wrong \n");
/* read */
if (PAPI_read(Eventset, values) != PAPI_OK)
Parapi_error("papi read wrong \n");
{ Some Code regions} the code region may run very long time, such as some minutes or some hours.
/* read */
if (PAPI_read(Eventset, values) != PAPI_OK)
Parapi_error("papi read wrong \n");
{latter result subtracts previous result}
……………
