This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: effectiveness of gnu.math


Thanks! I took a look at things, and now I get the same results you do.
I.e. gnu.math.IntNum multiplication is more efficient than BigInteger
multiplication.  I think one reason for that is that IntNum is more
efficient when the numbers fits in a single 'int'.

The different results I got was when printing the result.  Clearly,
number formatting of IntNum was much slower than BigInteger.  I
tweaked a few things, and took a look at what OpenJDK does.  This
allowed me to substantially optimize IntNum formatting, which I
just checked in.  Now IntNum formatting is still slightly slower,
but not enough that I'm too concerned.  (I guessing the reason is
that BigInteger "chunks" the formatting into "words" that can fit
in a long, while IntNum chunks to words that fit in an unsigned int.)

All threads - 25342 ms
 main - 25337 ms
  factorial.$ExIl (gnu.math.IntNum) - 24178 ms (95,4%)
   gnu.kawa.functions.MultiplyOp.applyN (Object[]) - 21903 ms (86,4%)
    gnu.math.IntNum.times (gnu.math.IntNum, gnu.math.IntNum) - 21504 ms (84,9%)
     gnu.math.IntNum.alloc (int) - 10748 ms (42,4%)
     gnu.math.MPL.mul_1 (int[], int[], int, int) - 10168 ms (40,1%)
   gnu.kawa.functions.AddOp.applyN (Object[]) - 1221 ms (4,8%)

Surprising the IntNum.alloc takes as much time, but it does need to allocate and zero out memory. And because that memory isn't in the cache yet, it takes longer to access it. -- --Per Bothner per@bothner.com http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]