Home | History | Annotate | Line # | Download | only in doc
      1 How to compile GNU MPFR with mini-gmp
      2 =====================================
      3 
      4 To build and test MPFR against mini-gmp:
      5 
      6   ./configure --with-mini-gmp=DIR [other configure options]
      7   make
      8   make check
      9 
     10 where DIR is the directory that contains mini-gmp
     11 (for example .../gmp-6.2.0/mini-gmp).
     12 
     13 "make" will build mini-gmp with the same compiler as for MPFR.
     14 
     15 For "make check", tests that use features not supported by mini-gmp
     16 (mpq_t, mpf_t, and the gmp_*printf functions) are skipped.
     17 
     18 Note: To use this version of the MPFR library, you need to define
     19 the MPFR_USE_MINI_GMP macro before including mpfr.h (alternatively,
     20 you can modify mpfr.h to define this macro at the beginning, though
     21 this is discouraged). And since mini-gmp currently does not provide
     22 random functions, you also need to define the gmp_randstate_t type
     23 with
     24 
     25   typedef long int gmp_randstate_t[1];
     26 
     27 before including mpfr.h (or you may want to modify mini-gmp.h).
     28 
     29 Remark: The random functions provided by MPFR configured with mini-gmp
     30 use the standard rand() function, thus one should avoid mini-gmp if one
     31 needs some really serious random functions. Another consequence is that
     32 these functions may not be thread-safe.
     33 
     34 The build with mini-gmp may require ISO C99+ features, such as "long long".
     35 
     36 This was tested with revision 39ac9e4 and GMP 6.2.0 on x86_64 GNU/Linux:
     37 ============================================================================
     38 Testsuite summary for MPFR 4.1.0-dev
     39 ============================================================================
     40 # TOTAL: 183
     41 # PASS:  172
     42 # SKIP:  11
     43 # XFAIL: 0
     44 # FAIL:  0
     45 # XPASS: 0
     46 # ERROR: 0
     47 ============================================================================
     48 
     49 How to use mini-gmp with reduced limb size
     50 ==========================================
     51 
     52 Following the idea of Micro-GMP [1], the GMP developers have adapted mini-gmp
     53 so that it can be used with a reduced limb size. For that, you need GMP 6.2.0
     54 (or later) and define the MINI_GMP_LIMB_TYPE macro with the associated base
     55 type, e.g.
     56 
     57   -DMINI_GMP_LIMB_TYPE=char   (in practice, 8 bits)
     58   -DMINI_GMP_LIMB_TYPE=short  (in practice, 16 bits)
     59   -DMINI_GMP_LIMB_TYPE=int    (in practice, 32 bits)
     60 
     61 For example:
     62 
     63   ./configure --with-mini-gmp=DIR CFLAGS="-DMINI_GMP_LIMB_TYPE=int"
     64 
     65 This was tested with revision 39ac9e4 and GMP 6.2.0 on x86_64 GNU/Linux:
     66 ============================================================================
     67 Testsuite summary for MPFR 4.1.0-dev
     68 ============================================================================
     69 # TOTAL: 183
     70 # PASS:  172
     71 # SKIP:  11
     72 # XFAIL: 0
     73 # FAIL:  0
     74 # XPASS: 0
     75 # ERROR: 0
     76 ============================================================================
     77 
     78 [1] https://members.loria.fr/PZimmermann/talks/microgmp.pdf
     79