mpz reuse test takes too much time
Torbjörn Granlund
tg at gmplib.org
Sun Nov 27 16:18:11 UTC 2016
tg at gmplib.org (Torbjörn Granlund) writes:
I write "fixed garbage" because I think that's good enough. Probably
zeroing out the entire allocted are will do?
MPN_ZERO(PTR(res1),ALLOC(res1));
SIZ(res1) = 0xDEFACE;
This is a possible patch for doing that for non-gcdext:
*** /tmp/extdiff.6EyPG_/gmp-main.fd5eb90386a9/tests/mpz/reuse.c Sun Nov 27 17:16:48 2016
--- /home/tege/prec/gmp-main/tests/mpz/reuse.c Sun Nov 27 17:16:20 2016
***************
*** 197,200 ****
--- 197,207 ----
} while (0)
+ #define OVERWRITE(res) \
+ do { \
+ MPN_ZERO(PTR(res), ALLOC(res)); \
+ PTR(res)[0] = 0xDEADBEEF; \
+ SIZ(res) = 0xDEFACE; \
+ } while (0)
+
int
main (int argc, char **argv)
***************
*** 231,234 ****
--- 238,245 ----
mpz_init (t);
+ mpz_set_ui(res1, 1); /* force allocation */
+ mpz_set_ui(res2, 1); /* force allocation */
+ mpz_set_ui(res3, 1); /* force allocation */
+
for (pass = 1; pass <= reps; pass++)
{
***************
*** 315,318 ****
--- 326,330 ----
mpz_set (res1, in1);
+ OVERWRITE(res2);
INVOKE_RRSS (ddss_div[i], res1, res2, res1, in2);
MPZ_CHECK_FORMAT (res1);
***************
*** 321,324 ****
--- 333,337 ----
FAIL (ddss_div, i, in1, in2, NULL);
+ OVERWRITE(res1);
mpz_set (res2, in1);
INVOKE_RRSS (ddss_div[i], res1, res2, res2, in2);
***************
*** 329,332 ****
--- 342,346 ----
mpz_set (res1, in2);
+ OVERWRITE(res2);
INVOKE_RRSS (ddss_div[i], res1, res2, in1, res1);
MPZ_CHECK_FORMAT (res1);
***************
*** 335,338 ****
--- 349,353 ----
FAIL (ddss_div, i, in1, in2, NULL);
+ OVERWRITE(res1);
mpz_set (res2, in2);
INVOKE_RRSS (ddss_div[i], res1, res2, in1, res2);
***************
*** 395,398 ****
--- 410,414 ----
mpz_set (res1, in1);
+ OVERWRITE(res2);
r2 = (ddsi_div[i].fptr) (res1, res2, res1, in2i);
MPZ_CHECK_FORMAT (res1);
***************
*** 400,403 ****
--- 416,420 ----
FAIL (ddsi_div, i, in1, in2, NULL);
+ OVERWRITE(res1);
mpz_set (res2, in1);
(ddsi_div[i].fptr) (res1, res2, res2, in2i);
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-devel
mailing list