Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radix sort #44230

Merged
merged 103 commits into from
Apr 3, 2022
Merged

Add radix sort #44230

merged 103 commits into from
Apr 3, 2022

Commits on Feb 17, 2022

  1. Add radix sort

    LilithHafner committed Feb 17, 2022
    Configuration menu
    Copy the full SHA
    ee3964b View commit details
    Browse the repository at this point in the history

Commits on Feb 18, 2022

  1. Configuration menu
    Copy the full SHA
    569a5c1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    67b744c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b8ad40f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5fd8e42 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7cf473d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d8363a5 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    44b8411 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    a22b120 View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2022

  1. Configuration menu
    Copy the full SHA
    f0d6536 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c42ec18 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fc0e7bb View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2022

  1. Configuration menu
    Copy the full SHA
    7b665ef View commit details
    Browse the repository at this point in the history
  2. whitespace

    LilithHafner committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    0c2e202 View commit details
    Browse the repository at this point in the history
  3. add RadixSort tests

    LilithHafner committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    44e4ea0 View commit details
    Browse the repository at this point in the history
  4. more radix sort tests

    LilithHafner committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    9f83339 View commit details
    Browse the repository at this point in the history
  5. fix typo

    LilithHafner committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    39216ad View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e045255 View commit details
    Browse the repository at this point in the history
  7. fix maybereverse use

    LilithHafner committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    3747e79 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2022

  1. remove set defalg

    LilithHafner committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    2fc70fb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fa198ca View commit details
    Browse the repository at this point in the history
  3. put back set defalg

    LilithHafner committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    c692830 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2022

  1. Configuration menu
    Copy the full SHA
    7f2b076 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9d3b5d5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3e533cd View commit details
    Browse the repository at this point in the history
  4. bisection 1

    Co-Authored-By: Dilum Aluthge <dilum@aluthge.com>
    LilithHafner and DilumAluthge committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    0d40342 View commit details
    Browse the repository at this point in the history
  5. bisection 2

    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    626f8bc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    6104982 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    31aae4d View commit details
    Browse the repository at this point in the history
  8. Add specialized sorting for Bool

    Sorting used to be okay for booleans, but radix sort messed with the
    dispatch and made it up to 6 times slower in the worst edge case. Rather
    than deal with that dispatch, I added compile time dispatch to a
    specialized boolean sorting routine that works on arbitrary orderings
    and is twice as fast as what was previously in base.
    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    8a8f239 View commit details
    Browse the repository at this point in the history
  9. Immediately dispatch to sort_int_range! for long Vector{[U]Int8}

    This is mostly noticable for lengths 257-1999 because they were
    previously dispatched to comparrison sort, skipping dispatch to
    sort_int_range!
    
    Also add comments.
    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    39a51cf View commit details
    Browse the repository at this point in the history
  10. fix typo, lol

    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    10e4204 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    2dfaa2d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    045869d View commit details
    Browse the repository at this point in the history
  13. restrict fpsort! policy on perm orderings to exclude Bool

    Because a) indexing with a Bool is not valid and b) specialized Bool sorting is faster
    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    3abefaa View commit details
    Browse the repository at this point in the history
  14. fix typo

    LilithHafner committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    758c026 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    85fed57 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    9a3f1c7 View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2022

  1. also rename in tests

    LilithHafner committed Feb 24, 2022
    Configuration menu
    Copy the full SHA
    3af1412 View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2022

  1. Configuration menu
    Copy the full SHA
    98aaa97 View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2022

  1. Configuration menu
    Copy the full SHA
    0a93e4b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f4b3e3b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    59706ad View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2022

  1. bump to rerun CI

    LilithHafner committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    c471af9 View commit details
    Browse the repository at this point in the history
  2. undo bump to rerun CI

    LilithHafner committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    82e8f26 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    41490eb View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6eb4d77 View commit details
    Browse the repository at this point in the history
  5. micro optimization

    2.5% speedup on `@belapsed sort!(x) setup=(x=rand(Int, 2001))`
    LilithHafner committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    592b814 View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2022

  1. Style

    LilithHafner committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    c5f0bf1 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2022

  1. Configuration menu
    Copy the full SHA
    d88230b View commit details
    Browse the repository at this point in the history

Commits on Mar 4, 2022

  1. Configuration menu
    Copy the full SHA
    ffcc043 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5f9c0fc View commit details
    Browse the repository at this point in the history
  3. Add comments to radaix_sort! and make computationally negligable chan…

    …ges to help the code match the explanation
    
    radix_sort! is not exported and only called with Int lo and hi values, 
    so changing the eltype of counts to UInt should have no exported impact. 
    I made this change 
    a) to simplify slightly
    b) because unsigned fails for BitInt
    c) because line 715 can now overflow as of the previous commit, and if 
    we are using a custom integer type, that might error.
    
    unsigned(hi-lo) gives a false illusion of generality.
    LilithHafner committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    84cedaa View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9283d75 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    06cfaae View commit details
    Browse the repository at this point in the history
  6. minor comment style

    LilithHafner committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    291399e View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2022

  1. reorder for readability

    LilithHafner committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    1195798 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    338f3f5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a186c7f View commit details
    Browse the repository at this point in the history
  4. remove stray newline

    LilithHafner committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    8896af2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    27b1656 View commit details
    Browse the repository at this point in the history
  6. Spelling

    LilithHafner committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    5f01201 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f978728 View commit details
    Browse the repository at this point in the history
  8. Comments and such

    LilithHafner committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    f03e4c5 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2022

  1. Rename variables

    ln -> lenm1
    mn -> v_min
    mx -> v_max
    rln -> v_range
    umn -> u_min
    umx -> u_max
    urln -> u_range
    LilithHafner committed Mar 11, 2022
    Configuration menu
    Copy the full SHA
    cf04241 View commit details
    Browse the repository at this point in the history
  2. Find, test & fix bug

    LilithHafner committed Mar 11, 2022
    Configuration menu
    Copy the full SHA
    96c0b6e View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2022

  1. Update base/sort.jl

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 12, 2022
    Configuration menu
    Copy the full SHA
    67494a5 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2022

  1. Update base/sort.jl

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    c344e82 View commit details
    Browse the repository at this point in the history
  2. Update base/sort.jl

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    68fef15 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a94cfea View commit details
    Browse the repository at this point in the history
  4. add @inbounds to _extrema

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    8d844bf View commit details
    Browse the repository at this point in the history
  5. multiline -= u_min

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    222f8e3 View commit details
    Browse the repository at this point in the history
  6. add

    LilithHafner committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    a7d7f56 View commit details
    Browse the repository at this point in the history
  7. Apply suggestions from code review

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    34c700c View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    18c56a9 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    09162ae View commit details
    Browse the repository at this point in the history
  10. Comment on count sort for Bool and add @inbounds

    `@inbounds` is a 1.8x speedup for sorting trues(10_000)
    LilithHafner committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    5473b3c View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    92f69fa View commit details
    Browse the repository at this point in the history
  12. bugfix: add using @Assert

    LilithHafner committed Mar 13, 2022
    Configuration menu
    Copy the full SHA
    6275928 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2022

  1. Configuration menu
    Copy the full SHA
    5eca90a View commit details
    Browse the repository at this point in the history
  2. Remove compilation tricks and put upper limit on chunk_size

    I couldn't verify performance gains from making CHUNK_SIZE and MASK known at compile time, so I'm trying to resist the urge to abuse the compiler.
    I also noticed this was 20% slower than SortingAlgorithms.jl's RadixSort for `@belapsed sort!(x) setup=(x=rand(Int, 3000000)) evals=1` because it used a chunk size of 13 which is too high. On my computer the best chunk size for that case is 10, and I couldn't find a size where higher than 10 was better than 10. Once I set max chunk size to 10, the 20% regression turned into a 2.5% regression, well within margin of error.
    LilithHafner committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    17f45e8 View commit details
    Browse the repository at this point in the history
  3. ckeck for ordered inputs

    LilithHafner committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    32a3197 View commit details
    Browse the repository at this point in the history
  4. use view not macro view

    LilithHafner committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    4931881 View commit details
    Browse the repository at this point in the history
  5. decouple _extrema and out_of_order to eliminate overhead (and optimiz…

    …ation) in cases where the existing methods are already very fast (i.e. short int range and short vectors)
    LilithHafner committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    4d2e184 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2022

  1. Configuration menu
    Copy the full SHA
    de33146 View commit details
    Browse the repository at this point in the history
  2. Update heuristic

    notes:
    source len ratio (>1 is regression)
    S = sort R = reverse a = almost
    float  40   .87
    Int    40   .96
    1:40   40  1.07
    1:20   40  1.7
    1:3    40  2.61
    1:2    40  1.92
    1:1    40  1.72
    (1.734)
    S Int  40   .92
    R Int  40   .92
    aS Int 40   .84
    aR Int 40   .93
    (.9027)
    aR flo 40   .89
    aS flo 40   .73
    S floa 40   .77
    R floa 40   .81
    (.7979)
    LilithHafner committed Mar 15, 2022
    Configuration menu
    Copy the full SHA
    5ff3f07 View commit details
    Browse the repository at this point in the history
  3. Move second dispatch to insertion sort to after presorted detection

    to address regressions for sorting reverse sorted or almost reverse 
    sorted data. Detection cost 2-7%, only impacting sorting vectors longer 
    than 40 and shorter than 3bits (e.g. `rand(Int, 100)`).
    
    Also put in all same detection for 128 bit types under direct order 
    (free).
    LilithHafner committed Mar 15, 2022
    Configuration menu
    Copy the full SHA
    ef24550 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2022

  1. Configuration menu
    Copy the full SHA
    dad6a26 View commit details
    Browse the repository at this point in the history
  2. Move submodule Sort.Serial to Sort and rename serial to uint_map

    `Serial` -> nothing, `serialize` -> `uint_map`, `deserialize` -> 
    `uint_unmap`, `Serializable` -> `UIntMappable`?
    LilithHafner committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    0bf35ab View commit details
    Browse the repository at this point in the history
  3. Docstring

    LilithHafner committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    c80b3cd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9a626d7 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    701aa0a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    693adab View commit details
    Browse the repository at this point in the history
  7. Test Coverage

    LilithHafner committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    563a816 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    dceee48 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    29442e7 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5f7d0d9 View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2022

  1. Configuration menu
    Copy the full SHA
    070a48e View commit details
    Browse the repository at this point in the history
  2. Fix typo in tests

    LilithHafner committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    287013c View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2022

  1. Configuration menu
    Copy the full SHA
    0581855 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2022

  1. Apply suggestions from code review

    Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
    LilithHafner and nalimilan committed Mar 31, 2022
    Configuration menu
    Copy the full SHA
    c07fb05 View commit details
    Browse the repository at this point in the history
  2. adjust presorted checks

    LilithHafner committed Mar 31, 2022
    Configuration menu
    Copy the full SHA
    d6087d0 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2022

  1. proof read

    LilithHafner committed Apr 2, 2022
    Configuration menu
    Copy the full SHA
    609abee View commit details
    Browse the repository at this point in the history