-
Notifications
You must be signed in to change notification settings - Fork 4
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
Type stability #16
Comments
Heh, I did not know about |
The culprit might be the julia> function sinpi_test(::Type{T},n::Integer) where T
big2 = 2one(T)
logn = 2
while logn < n
θ = -big2/logn
wtemp = sinpi(θ/2)
wpi = sinpi(θ)
logn <<= 1
end
end
sinpi_test (generic function with 1 method)
julia> @count_ops sinpi_test(Float16,1024)
Flop Counter: 431 flop
┌────────┬─────────┬─────────┬─────────┐
│ │ Float16 │ Float32 │ Float64 │
├────────┼─────────┼─────────┼─────────┤
│ muladd │ 0 │ 0 │ 28 │
│ add │ 18 │ 0 │ 32 │
│ sub │ 58 │ 0 │ 0 │
│ mul │ 36 │ 0 │ 90 │
│ div │ 36 │ 21 │ 0 │
│ abs │ 36 │ 17 │ 0 │
│ neg │ 14 │ 0 │ 0 │
│ sqrt │ 0 │ 17 │ 0 │
└────────┴─────────┴─────────┴─────────┘ So maybe it's okay because the call of |
As far as I understand this, for an |
Are the sinpi calls expensive? It seems like reducing the number of calls requires some analytical thinking here about the algorithm. Overall, anything could be put into a plan, as long as the plan itself does not become too large. FFTW precomputes lots of things. To get an idea, see their Documentation, for example The design and implementation of FFTW3 (link to pdf). On topic, if the issue arises from the sinpi calls, then the current code of GenericFFT actually is type-stable? |
Counting the float operations, we currently aren't as type-stable as I was expecting
The Float32 operations might be miscounted similar to triscale-innov/GFlops.jl#40 but I doubt the Float64 operations are. Just raising this as we may want to ensure type stability and explicit conversions rather than relying on promotions (which can easily cascade into Float64s where we don't actually want to use them). The output may still be of eltype T but users of this package probably want a Fourier transform fully in T when they provide an input vector of eltype T?
The text was updated successfully, but these errors were encountered: