Changes between Version 37 and Version 38 of ReplacingGMPNotes


Ignore:
Timestamp:
Nov 17, 2006 2:18:25 AM (7 years ago)
Author:
p_tanski
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ReplacingGMPNotes

    v37 v38  
    1313If you want to help with replacing GMP or do it yourself, you will have to work with the GC and RTS system.  The parts you will have to modify are written in C and C--, with configuration and assembly done through the Makefiles.  You should have an understanding of: 
    1414        * how the GC works and how memory from GMP is integrated with it; 
    15         * some C-- (this is fairly basic if you know C well, though the same adage for knowing C well holds for C--: if you know enough Assembler to  understand and debug C in Assembler you will be much better off), the only real documentation on C-- itself is in the [http://cminusminus.org/extern/man2.pdf C-- manual (PDF)], from cminusminus.org; the implementation of C-- for GHC is performed by several Haskell modules in the directory [[GhcFile(compiler/cmm/)]] of the HEAD branch, see [http://darcs.haskell.org/ghc http://darcs.haskell.org/ghc]); and, 
     15        * some C--/Cmm (this is fairly basic if you know C well, though the same adage for knowing C well holds for C--: if you know Assembler well enough to  understand and debug C in it you will be much better off), the only real documentation on C-- itself is in the [http://cminusminus.org/extern/man2.pdf C-- manual (PDF)], from cminusminus.org; the implementation of C-- for GHC is performed by several Haskell modules in the directory [[GhcFile(compiler/cmm/)]] of the HEAD branch, see [http://darcs.haskell.org/ghc http://darcs.haskell.org/ghc]), and see [wiki:Commentary/Compiler/CmmType the new Commentary Cmm page]; and, 
    1616        * makefiles and configuration scripts. 
    1717 
     
    38382. Memory Structure; Simultaneous Access to GMP by Foreign (C) code in the Same Binary 
    3939 
    40         In the current GMP implementation, GMP is configured to use GHC's GC memory and GMP can only have one allocator for memory.  Since any single binary containing Haskell code compiled with GHC contains the RTS and GMP, C code in the same binary cannot use GMP.  This problem was noted in [http://hackage.haskell.org/trac/ghc/ticket/311 bug Ticket #311].  The 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].  Different function names would make GMP into a separate, custom GHC library leaving the C part of the program free to use GMP. 
     40        In the current GMP implementation, GMP is configured to use GHC's GC memory and GMP can only have one allocator for memory.  Since any single binary containing Haskell code compiled with GHC contains the RTS and GMP, C code--including foreign calls to GMP from Haskell code (say you need a GMP function that is not a primitive)--in the same binary cannot use GMP.  This problem was noted in [http://hackage.haskell.org/trac/ghc/ticket/311 bug Ticket #311].  The 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].  Different function names would make GMP into a separate, custom GHC library leaving the C part of the program free to use GMP. 
    4141 
    4242        GHC does not have a custom-modified version of GMP (in fact, GHC uses the system build of GMP if that is available).  The 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.