#14627: Make mod_int signed and speed up matrix_modn_dense_float
----------------------------------+--------------------------------
       Reporter:  vbraun          |         Owner:  jason, was
           Type:  enhancement     |        Status:  positive_review
       Priority:  major           |     Milestone:  sage-5.11
      Component:  linear algebra  |    Resolution:
       Keywords:                  |     Merged in:
        Authors:  Volker Braun    |     Reviewers:  Martin Albrecht
Report Upstream:  N/A             |   Work issues:
         Branch:                  |  Dependencies:  #12728
       Stopgaps:                  |
----------------------------------+--------------------------------

Old description:

> As discussed on https://groups.google.com/d/msg/sage-
> devel/hnO8gT8VON4/YyZ5UCM5wUEJ, unsigned longs are much slower than
> signed longs when converted to a Python object.
>
> Without patch about 20x slower than naive list-of-list implementation:
> {{{
> $ sage test_matrix_modn_float.py
> setA:
> 5 loops, best of 50: 179 ms per loop
> setB:
> 25 loops, best of 50: 10.3 ms per loop
> }}}
> With patch no performance difference:
> {{{
> $ sage test_matrix_modn_float.py
> setA:
> 25 loops, best of 50: 11.5 ms per loop
> setB:
> 25 loops, best of 50: 12.8 ms per loop
> }}}
>
> Also, I collected some common extern cdef statements in pxd headers and
> cleaned up the `MAX_MODULUS` declarations.
>
> Apply
>   * [attachment:trac_14627_signed_mod_int.patch]
>   * [attachment:trac_14627_32bit.patch]

New description:

 As discussed on https://groups.google.com/d/msg/sage-
 devel/hnO8gT8VON4/YyZ5UCM5wUEJ, unsigned longs are much slower than signed
 longs when converted to a Python object.

 Without patch about 20x slower than naive list-of-list implementation:
 {{{
 $ sage test_matrix_modn_float.py
 setA:
 5 loops, best of 50: 179 ms per loop
 setB:
 25 loops, best of 50: 10.3 ms per loop
 }}}
 With patch no performance difference:
 {{{
 $ sage test_matrix_modn_float.py
 setA:
 25 loops, best of 50: 11.5 ms per loop
 setB:
 25 loops, best of 50: 12.8 ms per loop
 }}}

 Also, I collected some common extern cdef statements in pxd headers and
 cleaned up the `MAX_MODULUS` declarations.

 Apply
   * [attachment:trac_14627_signed_mod_int.patch]
   * [attachment:trac_14627_32bit.patch]
   * [attachment:trac_14627_more_primes.patch]

--

Comment (by vbraun):

 I noticed that #10281 intentionally uses 64-bit integers on all platforms
 for `mod_int`, since otherwise you can run out of primes. This is checked
 in one #long doctest that I missed. So the `trac_14627_more_primes.patch`
 switches to signed `int_fast64_t` for `mod_int`, this is fast on 64-bit
 Linux/OSX and sub-optimal (but with enough primes) on 64-bit Windows and
 all 32-bit platforms.

--
Ticket URL: <http://trac.sagemath.org/ticket/14627#comment:21>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to