Skip to content

Commit 5b253ab

Browse files
authored
Sorting: consistently use alg keyword for algorithm selection (#92)
1 parent 2863b8b commit 5b253ab

3 files changed

Lines changed: 5 additions & 21 deletions

File tree

docs/src/api/binarysearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using Metal
1313

1414
# Sorted array
1515
v = MtlArray(rand(Float32, 100_000))
16-
AK.merge_sort!(v)
16+
AK.sort!(v; alg=AK.MergeSort())
1717

1818
# Elements `x` to place within `v` at indices `ix`
1919
x = MtlArray(rand(Float32, 10_000))

docs/src/api/sort.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ AcceleratedKernels.sortperm!
1313
AcceleratedKernels.sortperm
1414
```
1515

16-
Specific implementations that the interfaces above forward to:
17-
- `sample_sort!` - multithreaded CPU sample sort, deferring to Base.sort! on independent slices.
18-
- `merge_sort!` (in-place), `merge_sort` (out-of-place) - sort arbitrary objects with custom comparisons.
19-
- `merge_sort_by_key!`, `merge_sort_by_key` - sort a vector of keys along with a "payload", a vector of corresponding values.
20-
- `merge_sortperm!`, `merge_sortperm`, `merge_sortperm_lowmem!`, `merge_sortperm_lowmem` - compute a sorting index permutation.
21-
2216
Algorithm choice is available on `sort!` / `sort` / `sortperm!` / `sortperm` with `alg=AK.MergeSort()`,
2317
`alg=AK.MergeSort(lowmem=true)`, `alg=AK.RadixSort()`, or `alg=AK.SampleSort()`, depending on the
2418
backend and operation.
@@ -28,16 +22,6 @@ Function signatures:
2822
AcceleratedKernels.MergeSort
2923
AcceleratedKernels.RadixSort
3024
AcceleratedKernels.SampleSort
31-
AcceleratedKernels.sample_sort!
32-
AcceleratedKernels.sample_sortperm!
33-
AcceleratedKernels.merge_sort!
34-
AcceleratedKernels.merge_sort
35-
AcceleratedKernels.merge_sort_by_key!
36-
AcceleratedKernels.merge_sort_by_key
37-
AcceleratedKernels.merge_sortperm!
38-
AcceleratedKernels.merge_sortperm
39-
AcceleratedKernels.merge_sortperm_lowmem!
40-
AcceleratedKernels.merge_sortperm_lowmem
4125
```
4226

4327
Example:

src/sort/sort.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ arguments are the same as for `Base.sort`.
7373
7474
## CPU
7575
CPU settings: use at most `max_tasks` threads to sort the array such that at least `min_elems`
76-
elements are sorted by each thread. A parallel [`sample_sort!`](@ref) is used, processing
76+
elements are sorted by each thread. A parallel sample sort is used, processing
7777
independent slices of the array and deferring to `Base.sort!` for the final local sorts.
7878
7979
Note that the Base Julia `sort!` is mainly memory-bound, so multithreaded sorting only becomes
@@ -88,7 +88,7 @@ algorithm take precedence over this keyword, then backend defaults. `items_per_t
8888
`RadixSort` and defaults to 2.
8989
9090
## Algorithm choice
91-
By default, `sort!` uses [`sample_sort!`](@ref) on CPU backends and [`merge_sort!`](@ref) on GPU
91+
By default, `sort!` uses sample sort on CPU backends and merge sort on GPU
9292
backends. Pass `alg=SampleSort()` for the CPU path, `alg=MergeSort()` for the GPU merge-sort path,
9393
or `alg=RadixSort()` to opt into GPU radix sorting. `RadixSort()` supports 32-bit and 64-bit
9494
integers and floats with default `lt`/`by`.
@@ -256,8 +256,8 @@ Save into `ix` the index permutation of `v` such that `v[ix]` is sorted. The `lt
256256
[`sort!`](@ref) with custom by-index comparators.
257257
258258
## Algorithm choice
259-
By default, `sortperm!` uses [`sample_sortperm!`](@ref) on CPU backends and [`merge_sortperm!`](@ref)
260-
on GPU backends. Pass `alg=MergeSort(lowmem=true)` to use the lower-memory GPU permutation path.
259+
By default, `sortperm!` uses sample sort on CPU backends and merge sort on GPU
260+
backends. Pass `alg=MergeSort(lowmem=true)` to use the lower-memory GPU permutation path.
261261
`RadixSort()` does not provide a permutation path.
262262
"""
263263
function sortperm!(

0 commit comments

Comments
 (0)