-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Switch to the fast broadcast implementation #716
Conversation
julia> using OrdinaryDiffEq, BenchmarkTools
julia> using OrdinaryDiffEq: perform_step!, initialize!
julia> prob10 = ODEProblem((du, u, p, t)->copyto!(du, u),ones(10),(0.0,10.0));
julia> prob100 = ODEProblem((du, u, p, t)->copyto!(du, u),ones(100),(0.0,10.0));
julia> prob1000 = ODEProblem((du, u, p, t)->copyto!(du, u),ones(1000),(0.0,10.0));
julia> integ10 = init(prob10, Tsit5()); integ100 = init(prob100, Tsit5()); integ1000 = init(prob1000, Tsit5());
julia> initialize!(integ10, integ10.cache); initialize!(integ100, integ100.cache); initialize!(integ1000, integ1000.cache);
julia> @btime perform_step!($integ10, $integ10.cache, false) # PR
251.051 ns (0 allocations: 0 bytes)
julia> @btime perform_step!($integ100, $integ100.cache, false) # PR
645.738 ns (0 allocations: 0 bytes)
julia> @btime perform_step!($integ1000, $integ1000.cache, false) # PR
5.743 μs (0 allocations: 0 bytes)
julia> @btime perform_step!($integ10, $integ10.cache, false) # Master
220.204 ns (0 allocations: 0 bytes)
julia> @btime perform_step!($integ100, $integ100.cache, false) # Master
620.471 ns (0 allocations: 0 bytes)
julia> @btime perform_step!($integ1000, $integ1000.cache, false) # Master
5.754 μs (0 allocations: 0 bytes)
|
Codecov Report
@@ Coverage Diff @@
## master #716 +/- ##
==========================================
- Coverage 72.31% 72.01% -0.31%
==========================================
Files 93 93
Lines 29182 28808 -374
==========================================
- Hits 21104 20747 -357
+ Misses 8078 8061 -17
Continue to review full report at Codecov.
|
With SciML/DiffEqBase.jl#204, I got using OrdinaryDiffEq, BenchmarkTools
prob = ODEProblem((du, u, p, t)->copyto!(du, u),ones(1000),(0.0,10.0))
integ = init(prob, Tsit5());
@btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # bc
@btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # loop
#=
julia> @btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # bc
4.122 μs (0 allocations: 0 bytes)
julia> @btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # loop
4.129 μs (0 allocations: 0 bytes)
=#
integ = init(prob, Vern9());
@btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # bc
@btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # loop
#=
julia> @btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # bc
11.411 μs (0 allocations: 0 bytes)
julia> @btime OrdinaryDiffEq.perform_step!($integ, $(integ.cache)) # loop
20.662 μs (0 allocations: 0 bytes)
=# . I think that it is safe to say that there is no regression :-) |
This PR needs SciML/DiffEqBase.jl#204 |
@@ -50,7 +50,7 @@ function qradd!(Q::AbstractMatrix, R::AbstractMatrix, v::AbstractVector, k::Int) | |||
@inbounds begin | |||
d = norm(v) | |||
R[k, k] = d | |||
@. Q[:, k] = v / d | |||
@.. @view(Q[:, k]) = v / d |
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.
oh lol. That might effect timings.
Nord fails. |
Macro
@..
is the fast broadcast implementation which assumes that all arrays are non-extruded, so that LLVM can always do a runtime alias check and vectorize.