#13352: Running time improvement of the bitset_len method
---------------------------+------------------------------------------------
Reporter: dcoudert | Owner: jason
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.3
Component: misc | Keywords:
Work issues: | Report Upstream: N/A
Reviewers: | Authors: David Coudert
Merged in: | Dependencies:
Stopgaps: |
---------------------------+------------------------------------------------
This patch improves the running time of the {{{bitset_len}}} method by
using fast methods for counting bits in 32 and 64 bits integers
(popcount). It
- adds file {{{bitcount.pxi}}} to {{{sage/misc/}}}. This file contains the
functions for counting bits in 32 or 64 bits integers
- adds corresponding tests to file {{{misc_c.pyx}}}
- modifies the {{{bitset_len}}} function accordingly
Before:
{{{
sage: x = FrozenBitset('10'*1003002); len(x)
1003002
sage: %timeit len(x)
125 loops, best of 3: 5.27 ms per loop
sage: x = FrozenBitset('10'*10705); len(x)
10705
sage: %timeit len(x)
625 loops, best of 3: 56.3 µs per loop
}}}
After:
{{{
sage: x = FrozenBitset('10'*1003002); len(x)
1003002
sage: %timeit len(x)
625 loops, best of 3: 865 µs per loop
sage: x = FrozenBitset('10'*10705); len(x)
10705
sage: %timeit len(x)
625 loops, best of 3: 9.39 µs per loop
}}}
The ``popcount_32`` method is the same than the function used in patch
#12371.
The alternative would be to use functions {{{__builtin_popcount()}}} and
{{{__builtin_popcountll()}}}. They are extremely fast but they required to
add flag ``-mpopcnt`` or ``-msse4.2`` to the gcc compiler. Can we do that?
how?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13352>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.