# oneAPI & FFTW

**URL:** <https://discourse.julialang.org/t/oneapi-fftw/59055>\
**Category:** GPU\
**Tags:** fftw, first-steps, oneapi\
**Created:** [April 11, 2021, 7:48pm UTC](https://discourse.julialang.org/t/oneapi-fftw/59055 "2021-04-11T19:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.julialang.org/u/fra)\
**Post date:** [April 11, 2021, 7:48pm UTC](https://discourse.julialang.org/t/oneapi-fftw/59055/1 "2021-04-11T19:48:25Z")

</div>

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

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

fft(a);
fft(b);

```

For the oneArray case I get

```julia
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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 11, 2021, 8:44pm UTC](https://discourse.julialang.org/t/oneapi-fftw/59055/2 "2021-04-11T20:44:34Z")

</div>

> [@fra](#):
>
> I’m trying oneAPI.jl with FFTW and I get an error when trying to use complex arrays in the GPU.

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

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [April 12, 2021, 6:12am UTC](https://discourse.julialang.org/t/oneapi-fftw/59055/3 "2021-04-12T06:12:44Z")

</div>

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).
