`plan_fft` fails when Julia is built with Intel MKL?

I built Julia 0.5.2 with Intel MKL on macOS (with some effort) and am enjoying some nice speedups in 3D FFTs.

However, it appears that plan_fft doesn’t work with MKL:

julia> Base.libfftw_name

julia> x = reshape(1:128 * 128 * 128, 128, 128, 128);

julia> @elapsed y = fft(x)

julia> p = plan_fft(x)
FFTW forward plan for 128×128×128 array of Complex{Float64}Error showing value of type Base.DFT.FFTW.cFFTWPlan{Complex{Float64},-1,false,3}:
ERROR: ccall: could not find function fftw_sprint_plan in library libmkl_rt
 in sprint_plan at ./fft/FFTW.jl:301 [inlined]

From the FFTW release notes appears fftw_sprint_plan is a function to “output a description of plan to a string” and isn’t (yet) available in MKL—it’s not listed in this MKL manual.

I guess I’d like to know if anyone has gotten plan_fft function to work with MKL. If this is a bug in Base.DFT, I’ll dig into the source and see if I can suggest a fix.

I belive fft calls plan_fft in its internal. So that is strange…
Why don’t you check the source code to see what fft is doing? I think you can easily find the function definition by doing @edit fft(x) or @which fft(x).

You are absolutely right. This is happening only because I left out the semicolon at the end—plan_fft ccalls fftw_sprint_plan only when showing the result (source)!

julia> p = plan_fft(x);
# happy 😁

So it’s not plan_fft, but rather showing a FFTWPlan.

Should be fixed in 0.6 (https://github.com/JuliaLang/julia/pull/21546) assuming that MKL does not claim to be FFTW 3.3.4+?

1 Like

Argh! My search-engine-game was weak, sorry, and thank you :bowing_man:!

At an MKL–FFTW overview, there’s a section, “Relationship between FFTW 3.3.4 API and Intel MKL provided DFTI (FORTRAN interfaces)” which makes me think MKL will be <=3.3.4. But who knows :rofl:

I just got the latest MKL compiled with Julia v0.6.1-pre.3 and I seem to be getting the same errors (it appears MKL is claiming to have FFTW 3.3.4). Any idea what/if I’m doing wrong?

BTW: sorry to be adding user questions to the development section but this seemed like the relevant place for it given the original question.

julia> m = rand(Float32,16384,16384);

julia> p = plan_rfft(m)
FFTW real-to-complex plan for 16384×16384 array of Float32Error showing value of type Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}:
ERROR: ccall: could not find function fftwf_sprint_plan in library libmkl_rt
 [1] sprint_plan(::Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}) at ./fft/FFTW.jl:295
 [2] show(::IOContext{Base.Terminals.TTYTerminal}, ::Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}) at ./fft/FFTW.jl:313
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}) at /Users/ethananderes/.julia/v0.6/OhMyREPL/src/output_prompt_overwrite.jl:8
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}) at ./REPL.jl:125
 [5] display(::Base.DFT.FFTW.rFFTWPlan{Float32,-1,false,2}) at ./multimedia.jl:194
julia> FFTW.version

julia> Base.libfftw_name

julia> versioninfo()
Julia Version 0.6.1-pre.3
Commit 4aa661a0c1* (2017-09-14 17:43 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin17.0.0)
  CPU: Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
  BLAS: libmkl_rt
  LAPACK: libmkl_rt
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

I also still see the same issue with Julia v0.6 + MKL, as well as another issue when 3D arrays are passed to the MKL FFT. I have opened a new issue for these problems.