Why the result I got is negative number sometimes?

Open discussion of PAPI.

Why the result I got is negative number sometimes?

Postby klzhan » Sun Apr 24, 2011 8:51 pm

Hello all,
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}

      …………… 
klzhan
 
Posts: 4
Joined: Sun Apr 24, 2011 8:44 pm

Re: Why the result I got is negative number sometimes?

Postby vweaver1 » Mon Apr 25, 2011 1:30 pm

Do you see these same problems if you use a newer version of PAPI (4.1.2.1 if possible)? Also what are the values you get back, how negative are they. What size values are you expecting?
vweaver1
 
Posts: 50
Joined: Wed Feb 17, 2010 4:02 pm

Re: Why the result I got is negative number sometimes?

Postby klzhan » Tue Apr 26, 2011 1:44 am

vweaver1 wrote:Do you see these same problems if you use a newer version of PAPI (4.1.2.1 if possible)? Also what are the values you get back, how negative are they. What size values are you expecting?


Hello vweaver1, thank you for your reply. In PAPI 4.1.1, I got the values such as :

<L1dm>344058</L1dm>
<L2dm>12531</L2dm>
<L1da>-2582269</L1da> L1 data access is less than 0
<L2da>735376</L2da>
<TLBdm>2313</TLBdm>
<ins>-5560784</ins> Instructions is less than 0
<cycle>420900</cycle>
<TLBim>5151</TLBim>
<BRins>-94397</BRins> Conditional branch instructions mispredicted
<BRmsp>19036</BRmsp>
<FPins>-1341526</FPins> Floating point instructions
<FMLins>-593800</FMLins> Floating point multiply instructions
<FDVins>1239</FDVins>
<L1im>17736</L1im>
<L2im>51221</L2im>
<L1ia>8284678</L1ia>
<L2ia>55122</L2ia>

here, some value is less than 0.

but sometimes, i can get the normal value, all the values is lager than 0.

I don't know what is the reason, I think my codes about the multiplexing of PAPI maybe not right.
I used the multiplexing in PAPI 3.6.0 last year, it could get the normal value, but the API of multiplexing had been changed in PAPI 4.1.1, and I didn't find the newest introductions about the API. So I think my codes maybe not right.

In PAPI 3.6.0, I wrote the code like these:

Code: Select all
          Eventset=PAPI_NULL;
          PAPI_option_t options;
               
         /* set the interval time */
        memset(&options,0x0,sizeof(options));
         options.multiplex.eventset=Eventset;
         options.multiplex.us=1000;//microsecond (μs)
         if(PAPI_set_opt(PAPI_DEF_MPX_USEC,&options)!=PAPI_OK)//PAPI_DEF_MPX_USEC
               printf("set opt wrong \n");
         if (PAPI_set_multiplex(Eventset) != PAPI_OK)
                printf("convert eventset to multi wrong \n");



In PAPI 4.1.1, I wrote the code like these,It didn't set the PAPI_option_t, I guess the problem may come from here.

Code: Select all
               if( PAPI_assign_eventset_component( Eventset, 0 ) != PAPI_OK )
                        printf("PAPI_assign_eventset_component error\n");
               if (PAPI_set_multiplex(Eventset) != PAPI_OK)
                        printf("convert eventset to multi wrong \n");




How Can I solve the problem,thanks!
klzhan
 
Posts: 4
Joined: Sun Apr 24, 2011 8:44 pm

Re: Why the result I got is negative number sometimes?

Postby vweaver1 » Fri May 13, 2011 11:15 am

Are you reading/printing the results as a 64-bit value? I notice that the values that are negative are the ones that would be large, and none of the "good" results are over 2billion which is approximately where a 32-bit overflow would happen.

If you're sure it's not a 32/64-bit problem, can you try running with only 4 events with multiplexing turned off and see if you see the same errors? This will help narrow down whether it's a problem with multiplexing or something else.
vweaver1
 
Posts: 50
Joined: Wed Feb 17, 2010 4:02 pm


Return to General discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests

cron