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

Broadcast inference failure results in scalar iteration #145

Closed
dpsanders opened this issue Feb 23, 2019 · 2 comments · Fixed by JuliaGPU/GPUArrays.jl#345
Closed

Broadcast inference failure results in scalar iteration #145

dpsanders opened this issue Feb 23, 2019 · 2 comments · Fixed by JuliaGPU/GPUArrays.jl#345
Labels
cuda array Stuff about CuArray. enhancement New feature or request

Comments

@dpsanders
Copy link

Describe the bug
Broadcast failure with a CuArray{Interval{Float32}}, even though it works fine with Interval{Float64}.

To Reproduce
MWE for this bug:

julia> using IntervalArithmetic, CuArrays

julia> a = Interval{Float32}[1, 2, 3];

julia> a2 = CuArray(a);

julia> f(x) = x^2 - 2
f (generic function with 1 method)

julia> f.(a2)
ERROR: scalar getindex is disallowed
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] assertscalar at /home/dpsanders/.julia/packages/GPUArrays/t8tJB/src/indexing.jl:8 [inlined]
 [3] getindex(::CuArray{Interval{Float32},1}, ::Int64) at /home/dpsanders/.julia/packages/GPUArrays/t8tJB/src/indexing.jl:44
 [4] _broadcast_getindex at ./broadcast.jl:544 [inlined]
 [5] _getindex at ./broadcast.jl:575 [inlined]
 [6] _broadcast_getindex at ./broadcast.jl:550 [inlined]
 [7] getindex at ./broadcast.jl:511 [inlined]
 [8] copy at ./broadcast.jl:787 [inlined]
 [9] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.ArrayStyle{CuArray},Nothing,typeof(f),Tuple{CuArray{Interval{Float32},1}}}) at ./broadcast.jl:753
 [10] top-level scope at none:0

julia> a = Interval{Float64}[1, 2, 3];

julia> a2 = CuArray(a);

julia> f.(a2)
3-element CuArray{Interval{Float64},1}:
 [-1, -1]
   [2, 2]
   [7, 7]

Expected behavior
The same as for 64-bit intervals.

Build log

# post the output of Pkg.build()
# make sure the error still reproduces after that.

Environment details (please complete this section)
Details on Julia:

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2603 v4 @ 1.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

Julia packages:

  • CuArrays.jl: 0.10.0
  • CUDAnative.jl: v1.0.1+
  • CUDAdrv v1.0.1+ #master

CUDA: toolkit and driver version
(Don't know how to find this out)

@vchuravy
Copy link
Member

This looks like a type-inference issue since we are hitting the generic fallback, this indicates that the return type for f is abstract.

@dpsanders
Copy link
Author

Apologies, you're right:

julia> using IntervalArithmetic

julia> x = Interval{Float32}(3, 4)
[3, 4]

julia> @code_warntype x^2
Body::Union{Interval{Float32}, Interval{Float64}}
...

Is it possible to make the error message more explicit about this?

@maleadt maleadt transferred this issue from JuliaGPU/CuArrays.jl May 27, 2020
@maleadt maleadt added bug Something isn't working cuda array Stuff about CuArray. labels May 27, 2020
@maleadt maleadt changed the title Broadcast failure with Interval{Float32} Broadcast inference failure results in scalar iteration Oct 29, 2020
@maleadt maleadt added enhancement New feature or request and removed bug Something isn't working labels Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda array Stuff about CuArray. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants