Ciao Niels,

Il Gio, 20 Dicembre 2012 11:47 am, Niels Möller ha scritto:
> bodr...@mail.dm.unipi.it writes:
>
>> I tested some changes and I suggest the attached patch: unconditionally
>> reduce modulo b.
>
> I'm not sure. In this case, the macro expands to a function call which
> basicallly does a % b. Since division usually is expensive, I think that
> can be faster only if a is many bits larger than b, so we reduce the

You are right.

Perhaps refining the condition is a better strategy.
I propose to change (asize>1) into (asize>(alow<(blow>>16))).

The small patch is attached. It heals the regression pointed by Paul, on
my atom, and it should not slow down if a and b are close.

Regards,
m

PS: the constant 16, is the same used for a similar purpose in
mpn/generic/gcd_1.c .

-- 
http://bodrato.it/software/strassen.html
diff -r 5fcbd6d0956f mpz/jacobi.c
--- a/mpz/jacobi.c	Thu Dec 20 10:04:35 2012 +0100
+++ b/mpz/jacobi.c	Thu Dec 20 12:34:28 2012 +0100
@@ -155,7 +155,9 @@
       if (blow == 1)
 	return JACOBI_BIT1_TO_PN (result_bit1);
 
-      if (asize > 1)
+      /* asize > 0 here. Reduce a if
+	 (asize > 1) || ((asize == 1) && (alow >= (blow >> 16)))	*/
+      if (asize > (alow < (blow >> 16)))
 	JACOBI_MOD_OR_MODEXACT_1_ODD (result_bit1, alow, asrcp, asize, blow);
 
       return mpn_jacobi_base (alow, blow, result_bit1);
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to