Skip to content

Handling wrapper array inputs #119

@gaurav-arya

Description

@gaurav-arya

We do not correctly handle wrapper array input types for non-CPU arrays. For example:

julia> using CUDA.CUFFT

julia> P = plan_fft(CuArray([1,2,3]))
CUFFT d.p. complex forward plan for 3-element CuArray of ComplexF64

julia> x = CuArray([1.0 2.0; 3.0 4.0])
2×2 CuArray{Float64, 2, CUDA.Mem.DeviceBuffer}:
 1.0  2.0
 3.0  4.0

julia> P = plan_fft(CuArray([1,2,3]))
CUFFT d.p. complex forward plan for 3-element CuArray of ComplexF64

julia> P * view(x, axes(x)...)
ERROR: StackOverflowError:
Stacktrace:
 [1] Array
   @ AbstractFFTs ./boot.jl:477 [inlined]
 [2] Array
   @ AbstractFFTs ./boot.jl:485 [inlined]
 [3] Array
   @ AbstractFFTs ./boot.jl:492 [inlined]
 [4] copy1(::Type{ComplexF64}, x::Vector{ComplexF64})
   @ AbstractFFTs ~/AbstractFFTs.jl/src/definitions.jl:53 [inlined]
 [5] *(p::CUDA.CUFFT.cCuFFTPlan{ComplexF64, -1, false, 1}, x::Matrix{ComplexF64}) (repeats 64932 times)
   @ AbstractFFTs ~/AbstractFFTs.jl/src/definitions.jl:224
 [6] *(p::CUDA.CUFFT.cCuFFTPlan{ComplexF64, -1, false, 1}, x::SubArray{Float64, 2, CuArray{…}, Tuple{…}, false})
   @ AbstractFFTs ~/AbstractFFTs.jl/src/definitions.jl:224
 [7] top-level scope
   @ REPL[80]:1
Some type information was truncated. Use `show(err)` to see complete types.

I don't know whether there is a standard solution to this issue? Possibly we would want to design a cleverer fallback * dispatch, that, perhaps using parent, would find its way to the more specific dispatch.

Related: #32, #73

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions