Skip to content

Use KernelAbstractions.jl for collocation - #565

Open
ErikQQY wants to merge 1 commit into
masterfrom
qqy/ka
Open

Use KernelAbstractions.jl for collocation#565
ErikQQY wants to merge 1 commit into
masterfrom
qqy/ka

Conversation

@ErikQQY

@ErikQQY ErikQQY commented Jul 23, 2026

Copy link
Copy Markdown
Member

Before this PR:

julia> @benchmark solve(prob, MIRK4(), dt = 0.05)
BenchmarkTools.Trial: 3415 samples with 1 evaluation per sample.
 Range (min  max):  1.302 ms    7.713 ms  ┊ GC (min  max): 0.00%  81.36%
 Time  (median):     1.320 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   1.464 ms ± 886.647 μs  ┊ GC (mean ± σ):  9.26% ± 12.18%

  █                                                            
  █▇▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆█ █
  1.3 ms       Histogram: log(frequency) by time      7.17 ms <

 Memory estimate: 2.32 MiB, allocs estimate: 52521.

After this PR:

julia> @benchmark solve(prob, MIRK4(), dt = 0.05)
BenchmarkTools.Trial: 4596 samples with 1 evaluation per sample.
 Range (min  max):  975.709 μs    5.862 ms  ┊ GC (min  max): 0.00%  80.19%
 Time  (median):       1.035 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):     1.088 ms ± 280.438 μs  ┊ GC (mean ± σ):  4.18% ±  9.89%

   ▅█▃▁                                                         ▁
  ▆█████▇▆▆▅▆▃▄▁▄▁▃▁▁▁▄▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▅▅▆▅▆▆▆▆▆▇ █
  976 μs        Histogram: log(frequency) by time       2.63 ms <

 Memory estimate: 1.09 MiB, allocs estimate: 7131.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1.11)

Time benchmarks
master 4148d99... master / 4148d99...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.572 ± 0.009 s 0.575 ± 0.0077 s 0.994 ± 0.021
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 12 ± 0.16 ms 12 ± 0.17 ms 1 ± 0.02
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 2.64 ± 0.06 ms 2.67 ± 0.06 ms 0.988 ± 0.032
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 3.16 ± 0.077 ms 3.17 ± 0.092 ms 0.997 ± 0.038
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 1.52 ± 0.033 ms 1.52 ± 0.043 ms 1 ± 0.035
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 1.49 ± 0.044 ms 1.49 ± 0.048 ms 1 ± 0.044
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 3.07 ± 0.11 ms 3.08 ± 0.1 ms 0.998 ± 0.048
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0375 ± 0.0025 s 0.0385 ± 0.0025 s 0.974 ± 0.09
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.0577 ± 0.0014 s 0.0588 ± 0.0027 s 0.98 ± 0.051
Simple Pendulum/IIP/Shooting(Tsit5()) 0.173 ± 0.071 ms 0.176 ± 0.072 ms 0.986 ± 0.57
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.698 ± 0.0082 s 0.702 ± 0.011 s 0.995 ± 0.02
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 15.1 ± 3.6 ms 15.1 ± 3.8 ms 0.998 ± 0.35
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 3.14 ± 0.11 ms 3.12 ± 0.095 ms 1.01 ± 0.048
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 3.8 ± 0.15 ms 3.77 ± 0.13 ms 1.01 ± 0.054
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 1.83 ± 0.1 ms 1.8 ± 0.081 ms 1.02 ± 0.072
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 3.21 ± 0.38 ms 3.19 ± 0.36 ms 1.01 ± 0.16
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 6.3 ± 4.8 ms 6.2 ± 4.9 ms 1.02 ± 1.1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0815 ± 0.0024 s 0.0804 ± 0.0019 s 1.01 ± 0.038
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.125 ± 0.0047 s 0.124 ± 0.004 s 1 ± 0.049
Simple Pendulum/OOP/Shooting(Tsit5()) 0.594 ± 0.032 ms 0.588 ± 0.032 ms 1.01 ± 0.077
time_to_load 6.87 ± 0.045 s 6.89 ± 0.073 s 0.997 ± 0.012
Memory benchmarks
master 4148d99... master / 4148d99...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.389 M allocs: 0.0443 GB 0.389 M allocs: 0.0443 GB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 0.0436 M allocs: 4.88 MB 0.0436 M allocs: 4.88 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 15.7 k allocs: 1.65 MB 15.7 k allocs: 1.65 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 22.1 k allocs: 2.03 MB 22.1 k allocs: 2.03 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 12.8 k allocs: 1.05 MB 12.8 k allocs: 1.05 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 25.5 k allocs: 1.82 MB 25.5 k allocs: 1.82 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.049 M allocs: 3.39 MB 0.049 M allocs: 3.39 MB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.553 M allocs: 0.0535 GB 0.553 M allocs: 0.0535 GB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.833 M allocs: 0.0778 GB 0.833 M allocs: 0.0778 GB 1
Simple Pendulum/IIP/Shooting(Tsit5()) 4.64 k allocs: 0.224 MB 4.64 k allocs: 0.224 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.89 M allocs: 0.984 GB 0.89 M allocs: 0.984 GB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 0.0932 M allocs: 24.8 MB 0.0932 M allocs: 24.8 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 0.0324 M allocs: 3.96 MB 0.0324 M allocs: 3.96 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 0.045 M allocs: 4.99 MB 0.045 M allocs: 4.99 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 25.3 k allocs: 2.17 MB 25.3 k allocs: 2.17 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 0.142 M allocs: 10.2 MB 0.142 M allocs: 10.2 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.266 M allocs: 18.7 MB 0.266 M allocs: 18.7 MB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 2.52 M allocs: 0.279 GB 2.52 M allocs: 0.279 GB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 3.82 M allocs: 0.404 GB 3.82 M allocs: 0.404 GB 1
Simple Pendulum/OOP/Shooting(Tsit5()) 0.0373 M allocs: 1.69 MB 0.0373 M allocs: 1.69 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant