-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
RFC/WIP: Use macro to auto switch between for
loop and broadcast
#639
Conversation
lgtm. We should do a quick performance test though before throwing it on the whole package. But this has a good change of solving all of our issues with broadcast. |
This should probably be a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I agree, that seems like a good way to circumvent most broadcasting related issues at the moment 👍
It assumes that the LHS has the same |
masterjulia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), ones(10), (0,100.))), Tsit5());
10.497 μs (148 allocations: 17.11 KiB)
julia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), cu(ones(10)), (0,100.))), Tsit5());
24.335 ms (16613 allocations: 737.70 KiB)
julia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), @MVector(ones(10)), (0,100.))), Tsit5());
8.646 μs (159 allocations: 12.69 KiB)
julia> @btime solve($(ODEProblem((u,p,t)->@.(0.01*u), @SVector(ones(10)), (0,100.))), Tsit5());
8.040 μs (104 allocations: 17.25 KiB) PR : Arrayjulia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), ones(10), (0,100.))), Tsit5());
11.094 μs (148 allocations: 17.11 KiB)
julia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), cu(ones(10)), (0,100.))), Tsit5());
1.503 ms (6829 allocations: 304.88 KiB)
julia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), @MVector(ones(10)), (0,100.))), Tsit5());
668.722 μs (16899 allocations: 307.06 KiB)
julia> @btime solve($(ODEProblem((u,p,t)->@.(0.01*u), @SVector(ones(10)), (0,100.))), Tsit5());
8.332 μs (101 allocations: 16.97 KiB) PR : Array, MArrayjulia> @btime solve($(ODEProblem((du,u,p,t)->@.(du=0.01*u), @MVector(ones(10)), (0,100.))), Tsit5());
8.770 μs (159 allocations: 12.69 KiB) |
Is the plan to not add broadcasts to the non-mutating algorithms since they should be used only with numbers and static arrays? Otherwise the benchmarks for |
julia> @btime solve($(ODEProblem((u,p,t)->@.(0.01*u), @SVector(ones(10)), (0,100.))), Tsit5()); #PR
7.680 μs (125 allocations: 18.28 KiB) |
Looks like it's done but just needs to move to DiffEqBase |
Superseded by #716 |
@loop u = uprev+dt*(a31*k1 + a32*k2)
is functionally equivalent with@. u = uprev+dt*(a31*k1 + a32*k2)
.@loop u = uprev+dt*(a31*k1 + a32*k2)
is functionally equivalent with.