oneAPI & FFTW

I’m trying oneAPI.jl with FFTW and I get an error when trying to use complex arrays in the GPU.

using oneAPI
using FFTW
a = randn(1024) .+ im*randn(1024);
b = oneArray(a);

fft(a);
fft(b);

For the oneArray case I get

julia> fft(b);
ERROR: ArgumentError: cannot take the host address of a oneArray{ComplexF64, 1}
Stacktrace:
 [1] unsafe_convert(#unused#::Type{Ptr{ComplexF64}}, x::oneArray{ComplexF64, 1})
   @ oneAPI ~/.julia/packages/oneAPI/zydrg/src/array.jl:176
 [2] macro expansion
   @ ~/.julia/packages/FFTW/G3lSO/src/fft.jl:564 [inlined]
 [3] (FFTW.cFFTWPlan{ComplexF64, -1, false, 1, G} where G)(X::oneArray{ComplexF64, 1}, Y::FFTW.FakeArray{ComplexF64, 1}, region::UnitRange{Int64}, flags::UInt32, timelimit::Float64)
   @ FFTW ~/.julia/packages/FFTW/G3lSO/src/FFTW.jl:71
 [4] plan_fft(X::oneArray{ComplexF64, 1}, region::UnitRange{Int64}; flags::UInt32, timelimit::Float64)
   @ FFTW ~/.julia/packages/FFTW/G3lSO/src/fft.jl:684
 [5] plan_fft(X::oneArray{ComplexF64, 1}, region::UnitRange{Int64})
   @ FFTW ~/.julia/packages/FFTW/G3lSO/src/fft.jl:684
 [6] plan_fft(X::oneArray{ComplexF64, 1}; kws::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ FFTW ~/.julia/packages/FFTW/G3lSO/src/fft.jl:693
 [7] plan_fft(X::oneArray{ComplexF64, 1})
   @ FFTW ~/.julia/packages/FFTW/G3lSO/src/fft.jl:693
 [8] fft(x::oneArray{ComplexF64, 1})
   @ AbstractFFTs ~/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:50
 [9] top-level scope
   @ REPL[15]:1

This error doesn’t happen if oneArray is real. Am I combining FFTW and oneAPI in the right way?
At the end I would like to find out if there is any speedup, but for the moment I’m just trying to see it working.

FFTW only works with in-memory arrays. It won’t work arrays that reside on a GPU.

4 Likes

oneMKL does have FFT routines, but we don’t have that library wrapped, let alone integrated with AbstractFFTs such that the fft method would just work (as it does with CUDA.jl).

1 Like