Happy Pi Day!
I ran the piG3
program from Unbounded Spigot Algorithms for the Digits of Pi, by Jeremy Gibbons, conjectured to emit digits of pi, for 65 hours, generating 2679770 digits of pi, and confirmed them all to be correct.
I did checkpointing, but unfortunately read::Integer
is very inefficient (GHC version 7.0.3), and upon restart, it ran out of memory (32-bit mode) while trying to read a tuple of three 35 million digit numbers. Other experimentation found that read
ing takes quadratic time in the number of digits, so it may have taxed my patience even if the computer had enough memory.
I think I want Integer->ByteString
and ByteString->Integer
functions to quickly dump and read Integer
s in base 256.
All the multiplications are of the form SHORT * LONG, so this could be a nice target for vectorized optimization.
1 comment :
It's only base-10, but there are some extremely optimized lexers and renderers in bytestring-lexing. There are also base-8 and base-16, though they're not as severely tweaked. I could always add a base-256 if there's really any need. Or you could look at the source and provide a patch that does so :)
Post a Comment