Create a plan's extra workers lazily, on the first threaded execution - #10
Open
pankgeorg wants to merge 20 commits into
Open
Create a plan's extra workers lazily, on the first threaded execution#10pankgeorg wants to merge 20 commits into
pankgeorg wants to merge 20 commits into
Conversation
W butterflies per iteration on SIMD.jl vectors (2 for ComplexF64, 4 for ComplexF32); the twiddle table keeps its compact layout and the triplets are rearranged in registers. Falls back to the scalar loop for strided or non-contiguous output and for other element types.
Above 2^18 elements the depth-first recursion reads each leaf at a stride that uses one element per cache line. Compute the 4096-point sub-transforms first, in input order, gathering one cache line of pencils at a time into a plan-owned buffer, then run the remaining butterfly passes level by level. Same operations, identical output; 2^20 43 -> 21 ms, 2^22 188 -> 101 ms (ComplexF64, Neoverse-N1, with the SIMD pass).
Symmetric odd-length DFT (cosine and sine sums over x_j ± x_{N-j}) with
folded constants, (N-1)^2 real multiplications instead of 4(N-1)^2 from a
twiddle table. Real input is accepted. Composite sizes with factors 5/7:
1000 35 -> 19 us, 46305 3.3 -> 1.9 ms, 10^6 100 -> 68 ms (ComplexF64).
Same structure as the radix-3 kernel, with the 5-/7-point codelets as in-place butterflies; replaces the composite step + O(n^2) leaves for 5^k and 7^k (Float32/Float64). 125-point 1.8 -> 1.2 us, 1000 19 -> 14 us, 10^6 68 -> 55 ms (ComplexF64).
…of two), test for 2^18-2^21 N/B must be a power of 4; with a fixed B = 4096 that failed for odd log2 N (e.g. the 2^19 complex transform inside a 2^20 rfft) and the digit reversal wrote out of bounds.
…py-based packing The even-length real transform's post-processing (and the backward pre-processing) used a per-call twiddle recurrence; the twiddles now live in the workers (Float32 accuracy at 2^20: 8e-6 -> 2.5e-7) and the loops run W values per iteration on SIMD vectors; the real<->complex pair packing is a copy. rfft 16384: 142 -> 131 us (Float64), 136 -> 118 us (Float32).
# Conflicts: # src/FFTA.jl
…56-point block The sibling leaves are computed together, one leaf per complex lane of a SIMD vector (2 for Float64, 4 for Float32), with the twiddle products written to round exactly as the scalar codelets. ComplexF64 2^14 197 -> 168 us (FFTW ESTIMATE 177), ComplexF32 2^14 146 -> 114 us.
Plans with several workers run a 1D transform of >= 2^18 points (and the half-size transform of an even-length real one) as independent sub-transforms on the workers' gather buffers, then butterfly passes split by block or by butterfly range (multiples of 64); same operations, output identical to the serial path. 16 workers, Neoverse-N1: ComplexF64 2^20 20.1 -> 1.87 ms (FFTW MEASURE 1.75 ms), 2^22 105 -> 10.2 ms (9.4 ms), rfft Float64 2^20 11.5 -> 3.2 ms (2.7 ms).
WorkerPool: the first worker is built with the plan, the others are cloned under a lock when an execution is actually split over threads. One-shot calls (fft(x), which plan with num_threads = Threads.nthreads()) no longer pay for workers they never use: fft of 2^17 one-shot at 16 threads 3.5 -> 2.8 ms. Results and the threaded paths are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on
integration/experiments(all previous branches).WorkerPool: the first worker is built with the plan, the others are cloned under a lock when an execution is actually split over threads; one-shot calls (fft(x), which plan withnum_threads = Threads.nthreads()) no longer pay for workers they never use. Results and the threaded paths are unchanged (p.workers[i]still works and completes the pool).16 threads, Neoverse-N1: one-shot
fftof 2^17 3.5 → 2.8 ms (same as with 1 worker); DSP.jlhilbert2^17 9.5 → 6.1 ms,conv2^16⋆2^12 6.3 → 4.1 ms,periodogram2^16 1.58 → 1.05 ms — the one-shot routines back to their 1-thread times (benchmark/compare3/aarch64/final/DSP_WORKLOADS.mdonbench/compare3).Tested: full suite green on 4 threads (11 061 tests).