Trixi.jl icon indicating copy to clipboard operation
Trixi.jl copied to clipboard

Allocations for `SummaryCallback` with custom integrators

Open DanielDoehring opened this issue 3 months ago • 5 comments

We observe allocations for the custom integrators, see

https://github.com/trixi-framework/Trixi.jl/blob/2dfde7faf3cc74f066d86148ae6c99ed9e58fa79/test/test_structured_2d.jl#L762-L774

https://github.com/trixi-framework/Trixi.jl/blob/2dfde7faf3cc74f066d86148ae6c99ed9e58fa79/test/test_tree_2d_advection.jl#L204-L215

and in the current PR #1871

https://github.com/trixi-framework/Trixi.jl/pull/1871/files#diff-4e3f4096536ca3da518b2f02b6f9197bc83ed9a7aec477b329951667dc1f830c

I observe that the allocations seem to be caused by the SummaryCallback.

For instance, for the example tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl

the alloc check

t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@allocated Trixi.rhs!(du_ode, u_ode, semi, t) # 7520

gives 7520 (as for the PERK2 test).

If one supplies the callbacks

callbacks = CallbackSet(#summary_callback, 
                        steady_state_callback,
                        analysis_callback, alive_callback,
                        save_solution,
                        stepsize_callback)

instead of

callbacks = CallbackSet(summary_callback, 
                        steady_state_callback,
                        analysis_callback, alive_callback,
                        save_solution,
                        stepsize_callback)

one obtains 0.

DanielDoehring avatar Mar 18 '24 12:03 DanielDoehring