Skip to content

Genericfft #64

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

Merged
merged 3 commits into from
Apr 12, 2019
Merged

Genericfft #64

merged 3 commits into from
Apr 12, 2019

Conversation

daanhb
Copy link
Member

@daanhb daanhb commented Apr 11, 2019

This pull request makes the generic FFT and DCT routines in FastTransforms available for all AbstractFloats. Some changes to the codeflow are described in #62. An earlier issue was #34.

The code is written such that the more efficient plans of FFTW are still returned when T is one of the fftwNumber types. There is currently no check for this, which is dangerous. I suppose we could check on the type of the plan returned by plan_fft, but I'm not sure how to check which method of fft ends up being invoked. I would not be surprised if this pull request breaks things. The implementation remains a lot slower than FFTW of course, and it is also less accurate.

My goal was to make it work for DoubleFloats.jl types, such as Double64. This works now:

julia> using FFTW, FastTransforms, DoubleFloats

julia> N = 10000; z = rand(N); z2 = Double64.(z); z3 = BigFloat.(z);

julia> v = fft(z); v2 = fft(z2); v3 = fft(z3);

julia> maximum(abs.(v-v2))
2.0438760310276306e-13

julia> maximum(abs.(v2-v3))
4.673372870301638733235131886202073426336931382556029192698665209605575831732632e-26

julia> @time fft(z);
  0.000491 seconds (58 allocations: 315.766 KiB)

julia> @time fft(z2);
  0.097739 seconds (548.98 k allocations: 33.332 MiB, 3.70% gc time)

julia> @time fft(z3);
  1.978109 seconds (17.87 M allocations: 952.290 MiB, 42.06% gc time)

So, for this example, Double64 is faster than BigFloat by a factor of about 20. It is slower than FFTW by a factor of about 200.

@MikaelSlevinsky
Copy link
Member

Awesome! It looks like this might work with Intervals from ValidatedNumerics.jl as well.

@dlfivefifty, do these changes work with the ecosystem?

@MikaelSlevinsky
Copy link
Member

I think the build failures mainly point to too broad of support. We can drop 0.6 now. The Appveyor builds also should have 0.7/1.0 builds instead of 0.6 and keep latest on allowable failure.

@dlfivefifty
Copy link
Member

It looks fine to me.

@MikaelSlevinsky MikaelSlevinsky merged commit dc3e973 into JuliaApproximation:master Apr 12, 2019
This was referenced Apr 12, 2019
@daanhb
Copy link
Member Author

daanhb commented Apr 20, 2019

I'm afraid I did not get this right the first time. The code accidentally hijacks some of the FFTW plans, resulting in significant slowdowns elsewhere. I'm looking at it and will add some tests to detect similar situations in the future.

@daanhb
Copy link
Member Author

daanhb commented Apr 20, 2019

I've made a new pull request: #66.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants