Skip to content

Commit

Permalink
Improved inference
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jan 20, 2022
1 parent ccff220 commit 4a3f596
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,19 @@ function DiffEqBase.prepare_alg(alg::Union{OrdinaryDiffEqAdaptiveImplicitAlgorit

isbitstype(T) && sizeof(T) > 24 && return remake(alg, chunk_size=Val{1}(),linsolve=linsolve)

# If chunksize is zero, pick chunksize right at the start of solve and
# then do function barrier to infer the full solve
x = if prob.f.colorvec === nothing
length(u0)
else
maximum(prob.f.colorvec)
end

L = ArrayInterface.known_length(typeof(u0))
if L === nothing # dynamic sized

# If chunksize is zero, pick chunksize right at the start of solve and
# then do function barrier to infer the full solve
x = if prob.f.colorvec === nothing
length(u0)
else
maximum(prob.f.colorvec)
end

cs = ForwardDiff.pickchunksize(x)
remake(alg,chunk_size=cs,linsolve=linsolve)
remake(alg,chunk_size=Val{cs}(),linsolve=linsolve)
else # statically sized
cs = pick_static_chunksize(Val{L}())
remake(alg,chunk_size=cs,linsolve=linsolve)
Expand Down
7 changes: 4 additions & 3 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ function DiffEqBase.remake(thing::Union{OrdinaryDiffEqAdaptiveImplicitAlgorithm{
DAEAlgorithm{CS,AD,FDT,ST,CJ}};
linsolve, kwargs...) where {CS, AD, FDT, ST, CJ}
T = SciMLBase.remaker_of(thing)
T(; chunk_size=Val{CS}(),autodiff=Val{AD}(),standardtag=Val{ST}(),
T(; SciMLBase.struct_as_namedtuple(thing)...,
chunk_size=Val{CS}(),autodiff=Val{AD}(),standardtag=Val{ST}(),
concrete_jac = CJ === nothing ? CJ : Val{CJ}(),
linsolve,
SciMLBase.struct_as_namedtuple(thing)...,kwargs...)
linsolve = linsolve,
kwargs...)
end

###############################################################################
Expand Down

0 comments on commit 4a3f596

Please sign in to comment.