(Repost) Replacement for GMP as Bignum: ARPREC? Haskell?; OS X and OpenSSL

(Sorry for the repost: I needed to correct a few typos--thanks Seth--and clarify a few things.) GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum library, BN. I have two questions concerning this: (1) Why not use the ARbitrary PRECision Computation Package (ARPREC) by David Bailey, Yozo Hida, Karthik Jeyabalan, Xiaoye Li and Brandon Thompson? Here is a reference web page: http://crd.lbl.gov/~dhbailey/mpdist/ ARPREC is written in C++ but supports calls from C (see include/arprec/c_mp.h in the distribution directory). ARPREC is very fast and supports more complex mathematics than BN. The Licensing for ARPREC is not a problem: essentially similar to BSD3. Note that there would be a basic configuration fix for building OpenSSL's BN library on OS 10.4: you would probably--I had to, myself--have to temporarily move the default installation of /usr/lib/libssl0.9.dylib (and variants) if you want to create a static (.a) library because Apple's ln links dynamic libraries in preference to static libraries. (2) A much more aesthetic solution would be to replace any external Bignum library with a pure Haskell library. There are many problems with building a truly efficient and fast Bignum library in Haskell but challenges like that are how languages evolve... Both GHC and nhc98 seem to use GMP, OCaml uses a custom bignum library written by Xavier Leroy and even MLton uses GMP. Robert Dockins wrote a type-based library for arbitrary that can (slowly) handle big numbers (up to 10^15), see http://www.eecs.tufts.edu/~rdocki01/typenats.html I don't know what the constraints on making such native Integer support work in GHC but my comment on the evolution of Haskell was not meant badly: native Integer support would require modifications to how Integers are handled in memory. (I would be glad to lend whatever support I could on this, but it seems like a big project.) -Peter Tanski

Hello p, Sunday, July 30, 2006, 7:21:07 AM, you wrote:
Leroy and even MLton uses GMP. Robert Dockins wrote a type-based library for arbitrary that can (slowly) handle big numbers (up to 10^15), see http://www.eecs.tufts.edu/~rdocki01/typenats.html I don't
this don't have anything common with our problem of implementing efficient runtime library
know what the constraints on making such native Integer support work in GHC but my comment on the evolution of Haskell was not meant badly: native Integer support would require modifications to how Integers are handled in memory. (I would be glad to lend whatever support I could on this, but it seems like a big project.)
imho, you are wrong. current representation allows fastest operations. but anyway Haskell code will be several times slower than C one - even for GHC, much more for Haskell interpreters -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hi On 7/30/06, p.tanski@gmail.com
(Sorry for the repost: I needed to correct a few typos--thanks Seth--and clarify a few things.)
GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum library, BN. I have two questions concerning this:
(1) Why not use the ARbitrary PRECision Computation Package (ARPREC) by David Bailey, Yozo Hida, Karthik Jeyabalan, Xiaoye Li and Brandon Thompson? Here is a reference web page: http://crd.lbl.gov/~dhbailey/mpdist/
ARPREC is written in C++ but supports calls from C (see include/arprec/c_mp.h in the distribution directory). ARPREC is very fast and supports more complex mathematics than BN. The Licensing for ARPREC is not a problem: essentially similar to BSD3.
I think the idea is to get rid of annoying dependencies (GMP), and not to create new ones (C++). There's few other big ifs with APREC as far as I see: Fiddling with FPU precision regs in x86 and possibly problems in Windows environment. It might require a bit fiddling to get memory handling right when using APREC, as well. In past, I tried to get rid of GMP by replacing it with libtommath http://math.libtomcrypt.com/ But I have given up for now - because of related and unrelated problems. But, whoever starts the work probably gets to pick their lib, so OpenSSL's BN, APREC, LibTomMath or anything else...it's open :-) Best regards, Esa
participants (3)
-
Bulat Ziganshin
-
Esa Ilari Vuokko
-
p.tanski@gmail.com