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

inconsistent report of "runtime dispatch detected: Base.InexactError" #308

Closed
dpinol opened this issue Dec 27, 2021 · 1 comment
Closed

Comments

@dpinol
Copy link
Contributor

dpinol commented Dec 27, 2021

Hi,
the following code

using JET
mutable struct MutStruct
    value::Float64
end
const ms = MutStruct(3.4)
function rc()
     period = trunc(Int, ms.value)
     @debug "cd" cd = ms.value
end
@report_opt rc()

reports

┌ @ float.jl:812 Base.InexactError(:Int64, Int64, %4)
│ runtime dispatch detected: Base.InexactError(:Int64::Symbol, Int64, %4::Float64)

Shouldn't Julia be able to invoke the concrete trunc version for Float64? invoke(trunc, Tuple{Float64}, ms.value) doesn't report the dispatch, but it's not feasible for me because I need the conversion to Int. . So I tried 'invoke(trunc, Tuple{Type{Int}, Float64}, Int, ms.value)', but it also reports dispatch. Finally I found that unsafe_trunc(Int, ms.value) also avoid the dispatch report. Do you know if there's a better way? thanks

The following alterations to the code also avoid reporting the issue. I thought that it was caused due to the code being inlined, but adding @noinline also avoided the dispatch report.

  • Declaring the struct non mutable
  • Commenting out the @debug line
  • Changing the @debug line with @debug "cd" cd = 3.2

thanks

@aviatesk
Copy link
Owner

The runtime dispatch error seems to come from the line @debug ..., which is very expected.

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