Changes between Version 37 and Version 38 of ReplacingGMPNotes
- Nov 17, 2006 2:18:25 AM (7 years ago)
v37 v38 13 13 If 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: 14 14 * 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--; and, 16 16 * makefiles and configuration scripts. 17 17 … … 38 38 2. Memory Structure; Simultaneous Access to GMP by Foreign (C) code in the Same Binary 39 39 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 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 codein 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. 41 41 42 42 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.