Hi,
In PDMP.jl, I have some large gc time reported. I looked at the performance tips and it seems my code is not type stable. For example, considering the example tcp.jl
,
I find that pdmp!
is not type stable even if the return type is always pdmpResult
. I could anotate the return type like pdmp!(,,,)::pdmpResult
but I dont understand why Julia is not able to do so.
Can anyone help me understand this please?
If you have further suggestions on my function pdmp!
, I am also interested.
Thank you for your help,
Best,
result3= @code_warntype PDMP.pdmp!(xc0,xd0,F_tcp!,R_tcp!,nu_tcp,parms,0.0,tf,ode=:lsoda,n_jumps = 100)
Body::Any
1 ββ %1 = PDMP.pdmp!::typeof(pdmp!) ββ» #pdmp!#37
β %2 = PDMP.Delta_dummy::typeof(PDMP.Delta_dummy) ββ
β %3 = Ο (false, Bool) βββ» #pdmp!
β %4 = (Base.getfield)(#temp#, :ode)::Symbol ββββ» getindex
β %5 = Ο (:chv, Symbol) βββ
β %6 = (Base.getfield)(#temp#, :n_jumps)::Int64 ββββ» getindex
β (Base.ifelse)(true, 1, -2) βββββ»β· Type
β %8 = %new(UnitRange{Int64}, -1, 1)::UnitRange{Int64} βββββ
β (Base.ifelse)(true, 1, -2) βββββ»β· Type
β %10 = %new(UnitRange{Int64}, -1, 1)::UnitRange{Int64} βββββ
β %11 = Ο (1.0, Float64) βββ
β %12 = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Any,1}, svec(Any, Int64), :(:ccall), 2, Array{Any,1}, 0, 0))::Array{Any,1}
β %13 = (Base.sle_int)(1, 1)::Bool βββββ»β·β·β· iterate
ββββ goto #3 if not %13 βββββββ iterate
2 ββ %15 = (Base.sle_int)(1, 0)::Bool ββββββββ iterate
ββββ goto #4 βββββββ
3 ββ nothing β
4 ββ %18 = Ο (#2 => %15, #3 => false)::Bool βββββββ
ββββ goto #6 if not %18 βββββββ
5 ββ invoke Base.getindex(()::Tuple{}, 1::Int64) βββββββ
ββββ $(Expr(:unreachable)) βββββββ
6 ββ goto #8 βββββββ
7 ββ $(Expr(:unreachable)) βββββββ
8 ββ goto #9 ββββββ
9 ββ goto #10 βββββ» iterate
10 β goto #11 ββββ
11 β %27 = Ο (%3, Bool) βββ
β %28 = Ο (%5, Symbol) βββ
β %29 = Ο (%11, Float64) βββ
β %30 = invoke PDMP.:(#pdmp!#35)(%27::Bool, %4::Symbol, %28::Symbol, %6::Int64, %8::UnitRange{Int64}, %10::UnitRange{Int64}, %29::Float64, %12::Array{Any,1}, %1::typeof(pdmp!), _4::Array{Float64,1}, _5::Array{Int64,1},_6::typeof(F_tcp!), _7::typeof(R_tcp!), %2::typeof(PDMP.Delta_dummy), _8::Array{Int64,2}, _9::Array{Float64,1}, _10::Float64, _11::Float64)::Any
ββββ goto #12 βββ
12 β goto #13 ββ
13 β return %30