Lazy mpz allocation

Marco Bodrato bodrato at
Mon Nov 9 17:02:21 UTC 2015


Il Lun, 28 Settembre 2015 10:26 am, Torbjörn Granlund ha scritto:
> Some weeks ago, I made a naive testsuite-driven attempt at implementing
> lazy allocation.  I had 55 FAILures and 114 PASSes after having fixed
> these files:
> M mpz/clear.c
> M mpz/clears.c
> M mpz/init.c
> M mpz/mul.c
> M mpz/realloc.c
> M mpz/realloc2.c
> M mpz/set_si.c
> M mpz/set_ui.c
> M tests/mpz/t-limbs.c
> Curiously, there are some tests/mpn failures too.

Some tests in mpn use mpz to obtain uniformly distributed random numbers...

I did read all mpz files implementing function with an mpz_ptr argument,
and I changed all the following files: mpz/2fac_ui.c, mpz/aors_ui.h,
mpz/bin_ui.c, mpz/bin_uiui.c, mpz/cdiv_qr_ui.c, mpz/cdiv_r_ui.c,
mpz/cfdiv_q_2exp.c, mpz/clear.c, mpz/clears.c, mpz/com.c, mpz/fac_ui.c,
mpz/fdiv_qr_ui.c, mpz/fdiv_r_ui.c, mpz/fib2_ui.c, mpz/fib_ui.c, mpz/gcd.c,
mpz/gcd_ui.c, mpz/gcdext.c, mpz/init.c, mpz/inits.c, mpz/iset_d.c,
mpz/lucnum2_ui.c, mpz/lucnum_ui.c, mpz/mfac_uiui.c, mpz/mul.c,
mpz/n_pow_ui.c, mpz/oddfac_1.c, mpz/powm.c, mpz/powm_sec.c, mpz/powm_ui.c,
mpz/primorial_ui.c, mpz/realloc.c, mpz/realloc2.c, mpz/set_si.c,
mpz/set_ui.c, mpz/tdiv_qr_ui.c, mpz/tdiv_r_ui.c, mpz/ui_sub.c,
rand/randlc2x.c .

Most of the times the change was simply:

-      PTR (x)[0] = y;
+      MPZ_NEWALLOC (x, 1)[0] = y;

The test-suite passes... But I did not look into mpq yet.

If we agree with moving towards lazy allocation, I'll commit the changes.
So that we start testing early!



More information about the gmp-devel mailing list