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

Possible new false positive on Julia 1.10.0-beta2 #560

Closed
kbarros opened this issue Aug 21, 2023 · 6 comments
Closed

Possible new false positive on Julia 1.10.0-beta2 #560

kbarros opened this issue Aug 21, 2023 · 6 comments

Comments

@kbarros
Copy link

kbarros commented Aug 21, 2023

The following detects a runtime dispatch on Julia 1.10.0-beta2, but did not on beta1.

using StaticArrays, JET

const Vec3 = SVector{3, Float64}
const μ = Array{Vec3, 4}

function f(μ)
    return reinterpret(reshape, Float64, μ)
end

@report_opt f(μ)

I get

═════ 1 possible error found ═════
┌ f(μ::Type{Array{SVector{3, Float64}, 4}}) @ Main ./REPL[5]:2
│ runtime dispatch detected: reinterpret(reshape, Float64, μ::Type{Array{SVector{3, Float64}, 4}})
└────────────────────

Tested with JET v0.8.11 and

Julia Version 1.10.0-beta2
Commit a468aa198d0 (2023-08-17 06:27 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores
@aviatesk
Copy link
Owner

It looks like this is true positive, as it will actually result in a method error:

julia> f(μ)
ERROR: MethodError: no method matching reinterpret(::typeof(reshape), ::Type{Float64}, ::Type{Array{SVector{3, Float64}, 4}})

Closest candidates are:
  reinterpret(::typeof(reshape), ::Type{T}, ::Base.ReinterpretArray{T, N, S, A, true} where {T, N, S, A<:(AbstractArray{S})}) where T
   @ Base reinterpretarray.jl:160
  reinterpret(::typeof(reshape), ::Type{T}, ::AbstractArray{T}) where T
   @ Base reinterpretarray.jl:114
  reinterpret(::typeof(reshape), ::Type{T}, ::A) where {T, S, A<:(AbstractArray{S})}
   @ Base reinterpretarray.jl:82
  ...

Stacktrace:
 [1] f::Type)
   @ Main ./REPL[6]:2
 [2] top-level scope
   @ REPL[10]:1

@kbarros
Copy link
Author

kbarros commented Aug 21, 2023

Sorry, I had a mistake in the definition of μ. Could you please give it another try with this fixed version?

using StaticArrays, JET

const Vec3 = SVector{3, Float64}
const μ = zeros(Vec3, 2, 3, 4, 5)

function f(μ)
    return reinterpret(reshape, Float64, μ)
end

f(μ) # runs now

@report_opt f(μ) # runtime dispatch detected in 1.10.0-beta2 only

@aviatesk
Copy link
Owner

Yeah, confirmed. Thanks!

@aviatesk aviatesk reopened this Aug 21, 2023
@kbarros
Copy link
Author

kbarros commented Sep 5, 2023

It seems like this is now fixed, and the issue can be closed.

@aviatesk
Copy link
Owner

Sorry for being late here and thanks for confirming it's now fixed. Let me investigate the root problem of this, and I will close this issue once confirming it is not on JET-side.

@aviatesk
Copy link
Owner

I confirmed that this issue no longer reproduces on:

Julia Version 1.10.0-beta2
Commit a468aa198d (2023-08-17 06:27 UTC)
Build Info:

    Note: This is an unofficial build, please report bugs to the project
    responsible for this build and not to the Julia project unless you can
    reproduce the issue using official builds available at https://julialang.org/downloads

Platform Info:
  OS: macOS (arm64-apple-darwin23.0.0)
  CPU: 10 × Apple M2 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores

It seems the core problem originated from StaticArrays.jl. Given this, I'll close this issue as no further action appears required on the JET side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants