The problem is that LONG_BITS is 31, ie std::numeric_limits<long>::digits returns 31 and not 32 which is what the writer expected.

--
Nilay


From: koreylsew...@gmail.com [mailto:koreylsew...@gmail.com] On Behalf Of Korey Sewell
Sent: Tuesday, April 05, 2011 7:14 AM
To: Beckmann, Brad
Subject: Re: [m5-dev] Running Ruby w/32 Cores

Hi again Brad, I looked this over again and although my 32-bit patch "fixes" things, now that I look at it again, I'm not convinced that I actually fixed the symptom of the bug but rather the cause of the bug.

Do you happen to know what are the problems with the 32-bit Set counts?

Sorry for prolonging the issue, but I thought I had put this to bed but maybe not. Finally, it may not matter that this works on 32-bit machines but it'd be nice if it did. (Let me know if I should move this convo to the m5-dev list)

I end up checking the last bit in the count function manually (the code as follows): int Set::count() const {
   int counter = 0;
   long mask;

   for (int i = 0; i < m_nArrayLen; i++) {
       mask = (long)0x01;

       for (int j = 0; j < LONG_BITS; j++) {
           // FIXME - significant performance loss when array
           // population << LONG_BITS
           if ((m_p_nArray[i] & mask) != 0) {
               counter++;
           }
           mask = mask << 1;
       }

#ifndef _LP64
       long msb_mask = 0x80000000;
       if ((m_p_nArray[i] & msb_mask) != 0) {
           counter++;
       }
#endif
   }

   return counter;
}
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to