-
-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
performanceThis is not fast enoughThis is not fast enoughurgentThis needs an immediate fixThis needs an immediate fix
Description
ComponentArrays are up to 10x slower than LabelledArrays for this problem! ComponentArrays broadcast to ComponentArrays and LabelledArrays broadcast to plain Arrays, so there is that disadvantage for these types of problems, but the disparity shouldn't be nearly this high. All of the microbenchmarks show that ComponentArrays should be almost the same as normal Arrays. From profiling, it appears that there is are plain flat indices that are making it through to the specialized @generated _getindex, which shouldn't be happening. I suspect that's the main problem
using ComponentArrays
using DifferentialEquations
using LabelledArrays
function f1(du,u,p,t)
du.x .= -1 .* u.x .* u.y .* p[1]
du.y .= -1 .* u.y .* p[2]
end
const n = 1000
p = [0.1,0.1]
lu_0 = @LArray fill(1000.0,2*n) (x = (1:n),y = (n+1:2*n))
cu_0 =ComponentArray(x=fill(1000.0, n), y=fill(1000.0, n))
lprob1 = ODEProblem(f1,lu_0,(0,100.0),p)
cprob1 = ODEProblem(f1,cu_0,(0,100.0),p)
lsol = solve(lprob1, Rodas5());
lsol = solve(lprob1, Rodas5(autodiff=false));
csol = solve(cprob1, Rodas5());
csol = solve(cprob1, Rodas5(autodiff=false));Metadata
Metadata
Assignees
Labels
performanceThis is not fast enoughThis is not fast enoughurgentThis needs an immediate fixThis needs an immediate fix