Open Lightup1 opened 2 years ago
Thanks for the information. Is there a way to change the threading system (not the provider) to let it allocation free?
Julia has https://github.com/JuliaSIMD/Polyester.jl, which should be able to replace https://github.com/JuliaMath/FFTW.jl/blob/17bc81a0fcf9875d777ea4bee2fca70fc23c8a0c/src/providers.jl#L56-L60 with
function spawnloop(f::Ptr{Cvoid}, fdata::Ptr{Cvoid}, elsize::Csize_t, num::Cint, callback_data::Ptr{Cvoid})
@batch per=core for i = 0:num-1
ccall(f, Ptr{Cvoid}, (Ptr{Cvoid},), fdata + elsize*i)
end
end
(I didn't test it, so don't except this to work!!!!!)
But I'm affraid this won't help the performance. FFT it self is much more heavy than the allocation.
Thank you very much! I'll test it later.
I can confirm this issue, I haven't noticed it in the past.
julia> using FFTW, BenchmarkTools
julia> x = randn((1024, 1024));
julia> FFTW.set_num_threads(8)
julia> @btime ifft($x);
7.646 ms (17810 allocations: 33.20 MiB)
julia> FFTW.set_num_threads(4)
julia> @btime ifft($x);
6.362 ms (115 allocations: 32.01 MiB)
julia> FFTW.set_num_threads(6)
julia> @btime ifft($x);
10.943 ms (38485 allocations: 34.27 MiB)
When activate multithreading by
FFTW.set_num_threads()
, it become slower and allocate more. The provider here is the default "fftw". But when using "mkl", it just use multithreading automatically depending on the problem size and allocation is 0. Here are some benchmarksAnd