Skip to content
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

Omit the alignment check when using MKL's fftw3 wrapper? #202

Closed
N5N3 opened this issue May 2, 2021 · 1 comment
Closed

Omit the alignment check when using MKL's fftw3 wrapper? #202

N5N3 opened this issue May 2, 2021 · 1 comment

Comments

@N5N3
Copy link
Contributor

N5N3 commented May 2, 2021

As far as i know, the 'UNALIGNED' flag changes nothing when using MKL's fftw3 wrapper, as the low level DFTI API uses no pointer information until call the DftiComputeForward or DftiComputeBackward.
Some 1d-fft benchmark:

using FFTW, BenchmarkTools, LinearAlgebra
const memory = zeros(Int8,8*2048*20000 + 15) # memory pool for arbitrary alignment
pickalign(::Type{T}, sz, align::Int) where{T} = begin
    data = @view memory[align .+ (1:sizeof(T)*prod(sz))]
    dataᵀ = reinterpret(T,data)
    reshape(dataᵀ,sz)
end 
using Random
a = pickalign(ComplexF32,(2048,100), 0)
randn!(a)
b = similar(a)
plan = plan_fft(a,1)
plan_unaligned = plan_fft(a,1,flags = FFTW.ESTIMATE | FFTW.UNALIGNED)
@btime FFTW.mul!(b,plan,a)                     #fftw:58.600 μs      mkl::34.200 μs
@btime FFTW.mul!(b,plan_unaligned,a)   #fftw:153.800 μs     mkl::34.200 μs
a = pickalign(ComplexF32,(2048,100), 1)  
randn!(a)
@btime FFTW.mul!(b,plan_unaligned,a)  #fftw:152.700 μs      mkl::35.600 μs
a = pickalign(ComplexF32,(2048,100), 8)
randn!(a)
@btime FFTW.mul!(b,plan_unaligned,a)  #fftw:152.100 μs      mkl::35.700 μs

Although only a few cases have been benched, it seems that the alignment doesn't affect MKL's performance, and the default flags could be settled as ESTIMATE | UNALIGNED.

@N5N3
Copy link
Contributor Author

N5N3 commented May 3, 2021

Well I found this in MKL's developer reference [p2643]:
The flags parameter in plan creation functions is always ignored. The same algorithm is used regardless of the value of this parameter.

@N5N3 N5N3 closed this as completed May 20, 2021
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

No branches or pull requests

1 participant