Changes between Version 11 and Version 12 of ReplacingGMPNotes


Ignore:
Timestamp:
Aug 3, 2006 4:25:04 AM (9 years ago)
Author:
ptanski
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ReplacingGMPNotes

    v11 v12  
    1414        * makefiles and configuration scripts. 
    1515 
     16Other basic recommended reading is: 
     17        * The GHC Commentary: [http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/the-beast/ncg.html The Native Code Generator]; and, 
     18        * The GHC Commentary: [http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/rts-libs/coding-style.html Style Guidelines for RTS C code]. 
     19 
    1620=== Reasons for Replacing GMP as the Bignum library === 
    1721 
     
    26302. Memory Structure; Simultaneous Access to GMP by Foreign (C) code in the Same Binary 
    2731 
    28         In the current GMP implementation, GMP is configured to use GHC's GC memory, so any single binary containing Haskell code compiled with GHC contains the RTS and GMP.  C code in the same binary as GHC-compiled Haskell code cannot access GMP separately due to duplicate-symbols from GMP in both programs.  This problem was noted in [http://hackage.haskell.org/trac/ghc/ticket/311 bug Ticket #311].  Simon Peyton-Jones suggested that a simple renaming of GHC-GMP functions would solve this problem and Bulat Ziganshin suggested simply using an automated tool to do this.  See [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-August/010679.html Replacement for GMP]. 
     32        In the current GMP implementation, GMP is configured to use GHC's GC memory, so any single binary containing Haskell code compiled with GHC contains the RTS and GMP.  C code in the same binary as GHC-compiled Haskell code cannot access GMP separately due to duplicate-symbols for GMP function names in both programs.  This problem was noted in [http://hackage.haskell.org/trac/ghc/ticket/311 bug Ticket #311].  Simon Peyton-Jones suggested that a simple renaming of GHC-GMP functions would solve this problem and Bulat Ziganshin suggested simply using an automated tool to do this.  See [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-August/010679.html Replacement for GMP]. 
    2933 
    3034        GHC does not have a custom-modified version of GMP (in fact, GHC uses the system build of GMP if that is available).  The custom-memory configuration of GMP uses GMP's [http://swox.com/gmp/manual/Custom-Allocation.html#Custom-Allocation Custom Allocation] routines.  Alternative libraries may not have this facility built in. 
     
    32363. Other Improvements to Integer 
    3337 
    34         Most of the suggestions in this section come from discussions in the glasgow-haskell-users list thread [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-July/010654.html returning to Cost of Integer].  In particular, [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-July/010660.html John Meacham's suggestion] to use a !ForeignPtr to data held by the normal GMP system library and store the value in an unboxed Int if the number of significant digits in Integer could fit into the size of an Int.  For those who are curious, a guide to GHC primitives is available (in an unformatted version) in ghc/compiler/prelude/primops.txt.pp; here is a link to [http://darcs.haskell.org/ghc/compiler/prelude/primops.txt.pp CVS version of primops.txt.pp].  You might want to search for the text "section "The word size story."", and especially the text "section "Integer#"".   The Haskell definition of Integer is in [http://darcs.haskell.org/packages/base/GHC/Num.lhs /packages/base/GHC/Num.lhs]. 
     38        Most of the suggestions in this section come from discussions in the glasgow-haskell-users list thread [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-July/010654.html returning to Cost of Integer].  In particular, [http://www.haskell.org/pipermail/glasgow-haskell-users/2006-July/010660.html John Meacham's suggestion] to use a !ForeignPtr to data held by the normal GMP system library and store the value in an unboxed Int if the number of significant digits in Integer could fit into the size of an Int.  For those who are curious, a guide to GHC primitives is available (in an unformatted version) in ghc/compiler/prelude/primops.txt.pp; here is a link to [http://darcs.haskell.org/ghc/compiler/prelude/primops.txt.pp CVS version of primops.txt.pp].  (See The GHC Commentary [http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/rts-libs/primitives.html Primitives] for a description of primops.txt.pp.)You might want to search for the text "section "The word size story."", and especially the text "section "Integer#"".   The Haskell definition of Integer is in [http://darcs.haskell.org/packages/base/GHC/Num.lhs /packages/base/GHC/Num.lhs]. 
    3539 
    3640        The current GMP implementation of Integer is: