diff --git a/docs/src/index.md b/docs/src/index.md index ef4b2b2..b93e05d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -4,6 +4,11 @@ Working with chunks and their respective indices also improves thread-safety compared to a naive approach based on `threadid()` indexing (see [PSA: Thread-local state is no longer recommended](https://julialang.org/blog/2023/07/PSA-dont-use-threadid/)). +!!! compat + In ChunkSplitters version 3.0 the iteration with `chunks` returns the ranges of indices only. The retrieve + the chunk indices, use `enumerate(chunks(...))`. Additionally, the number of chunks and the distribution type + of chunks are assigned with keyword arguments `n`, and `distribution`. + ## Installation Install with: @@ -13,10 +18,6 @@ julia> import Pkg; Pkg.add("ChunkSplitters") ## The `chunks` iterator -!!! compat - In ChunkSplitters version 3.0 the iteration with `chunks` returns the ranges of indices only. The retrieve - the chunk indices, use `enumerate(chunks(...))`. - The main interface is the `chunks` iterator, and the enumeration of chunks, with `enumerate`. ```julia @@ -134,7 +135,7 @@ julia> sum(chunk_sums) The package also provides a lower-level `getchunk` function: ```julia-repl -getchunk(array::AbstractArray, ichunk::Int, n::Int, distribution::Symbol=:batch) +getchunk(array::AbstractArray, ichunk::Int, n::Int, distribution::Symbol) ``` that returns the range of indices corresponding to the work items in the input `array` that are associated with chunk number `ichunk`. @@ -163,13 +164,13 @@ julia> using ChunkSplitters julia> x = rand(7); -julia> getchunk(x, 1, 3, distribution=:scatter) +julia> getchunk(x, 1, 3, :scatter) 1:3:7 -julia> getchunk(x, 2, 3, distribution=:scatter) +julia> getchunk(x, 2, 3, :scatter) 2:3:5 -julia> getchunk(x, 3, 3, distribution=:scatter) +julia> getchunk(x, 3, 3, :scatter) 3:3:6 ``` diff --git a/docs/src/load_balancing.md b/docs/src/load_balancing.md index c4880eb..4226884 100644 --- a/docs/src/load_balancing.md +++ b/docs/src/load_balancing.md @@ -59,10 +59,10 @@ Using `n == Thread.nthreads() == 12`, we get the following timings: ```julia-repl julia> using BenchmarkTools -julia> @btime uneven_workload_threads($x, $work_load; n=nthreads(), chunk_distribution=:batch) +julia> @btime uneven_workload_threads($x, $work_load; n=nthreads(), distribution=:batch) 2.030 ms (71 allocations: 7.06 KiB) -julia> @btime uneven_workload_threads($x, $work_load; n=nthreads(), chunk_distribution=:scatter) +julia> @btime uneven_workload_threads($x, $work_load; n=nthreads(), distribution=:scatter) 587.309 μs (70 allocations: 7.03 KiB) ``` diff --git a/src/ChunkSplitters.jl b/src/ChunkSplitters.jl index af03427..1e3f9cc 100644 --- a/src/ChunkSplitters.jl +++ b/src/ChunkSplitters.jl @@ -189,13 +189,13 @@ julia> using ChunkSplitters julia> x = rand(7); -julia> getchunk(x, 1, 3, distribution=:scatter) +julia> getchunk(x, 1, 3, :scatter) 1:3:7 -julia> getchunk(x, 2, 3, distribution=:scatter) +julia> getchunk(x, 2, 3, :scatter) 2:3:5 -julia> getchunk(x, 3, 3, distribution=:scatter) +julia> getchunk(x, 3, 3, :scatter) 3:3:6 ``` """