[Haskell-cafe] ANN: hmpfr-0.3.2 (requires integer-simple, supports mpfr 3.0.0)
Michal Konečný
mik at konecny.aow.cz
Fri Mar 4 23:42:35 CET 2011
Hi Dan,
On Friday 04 Mar 2011 21:59:12 Daniel Peebles wrote:
> I'm adding Ed to the conversation as he's very interested in this topic,
> too.
I do apologise - I was meant to post the previous email back to haskell-cafe
but by mistake it went only to you. I hope you do not mind that I am taking
the discussion back to the cafe. I attach my email so that other readers of
the cafe can see it.
> The experts were right about it being impossible to work with GHC's
> GMP – until recently. "foreign import c" calls are indeed going to call GC
> when you don't want it, but when they split integer-gmp out of GHC's own
> RTS, Duncan Coutts (one of those experts) added the "foreign import prim"
> construct so that he could do exactly what you want, and operate on GMP
> integers with GHC-allocated memory without worrying about temporary
> storage blowing up while you aren't looking.
>
> So in general, I'd lean more towards replacing all your ccall bindings to
> MPFR with cmm bindings. It does require some GHC internals knowledge but
> is fairly mechanical, and would solve all the problems, without requiring
> a rewrite of GMP (that would be slower anyway).
>
> Ed is actually going to get started on a fairly simple binding to a subset
> of MPFR for one of his projects, using the CMM approach based on the
> structure of my natural-gmp package
> (https://github.com/pumpkin/natural-gmp, which is itself based heavily on
> integer-gmp, but reworked to work fine from cabal rather than depending on
> GHC's build process). Once he is done with that, you might want to refer
> to his implementation to make your more complete MPFR binding work with
> integer-gmp (and thus make no speed sacrifices).
If this is the best approach, I would welcome help with this as I will not
have much time to work on it until the summer due to teaching commitments and
the need to publish work done earlier.
> I would also like a gmp-compatible replacement, but it's going to
> necessarily be slower and would prefer to be able to have fast
> computations over floating-point numbers AND integers/naturals.
Eek, I made a mistake, I apologise again - the proposal I was quoting in the
announcement is not what I had in mind. I was meant to refer to a mention by
igloo at the very end of
http://hackage.haskell.org/trac/ghc/ticket/311
which is a very different proposal from the one I linked to and the one you
seem to refer to here.
I was not at all thinking of writing a gmp compatible replacement. I was
thinking of taking gmp sources and mechanically modify the exported names and
modify integer-gmp to use those modified names. Thus there would be no
difference in the speed of Integer as it would still use an exact clone of the
original gmp in exactly the same way as now but not interfere with what the
usual gmp code does via other libraries.
Please correct me if I this approach is not feasible or if there is some
advantage in using cmm over this proposal that I am missing.
Michal
--
|o| Michal Konecny <mikkonecny at gmail.com>
|o| http://www-users.aston.ac.uk/~konecnym/
|o| office: (+42) (0)121 204 3462
|o| PGP key http://www-users.aston.ac.uk/~konecnym/ki.aston
-------------- next part --------------
An embedded message was scrubbed...
From: Michal =?utf-8?q?Kone=C4=8Dn=C3=BD?= <mik at konecny.aow.cz>
Subject: Re: [Haskell-cafe] ANN: hmpfr-0.3.2 (requires integer-simple, supports mpfr 3.0.0)
Date: Fri, 4 Mar 2011 21:49:13 +0000
Size: 5564
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110304/a301b094/attachment.eml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110304/a301b094/attachment.pgp>
More information about the Haskell-Cafe
mailing list