From 82932dd4ecff7968ddc3cbb0f0ea20bf5c7b7ae9 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Thu, 20 Apr 2023 14:00:53 +0200 Subject: [PATCH] check for allocations from mortars (#1405) * check for allocations from mortars * update comment --- test/test_p4est_2d.jl | 9 +++++++++ test/test_p4est_3d.jl | 9 +++++++++ test/test_tree_2d_advection.jl | 9 +++++++++ test/test_tree_3d_advection.jl | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/test/test_p4est_2d.jl b/test/test_p4est_2d.jl index 68811a69cab..793b0c57091 100644 --- a/test/test_p4est_2d.jl +++ b/test/test_p4est_2d.jl @@ -23,6 +23,15 @@ isdir(outdir) && rm(outdir, recursive=true) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), l2 = [3.198940059144588e-5], linf = [0.00030636069494005547]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end @trixi_testset "elixir_advection_unstructured_flag.jl" begin diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index 90b73b9a6df..f22e98456ae 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -29,6 +29,15 @@ isdir(outdir) && rm(outdir, recursive=true) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), l2 = [0.00253595715323843], linf = [0.016486952252155795]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end @trixi_testset "elixir_advection_amr.jl" begin diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index a5d80c50062..2785a0aead1 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -37,6 +37,15 @@ EXAMPLES_DIR = joinpath(pathof(Trixi) |> dirname |> dirname, "examples", "tree_2 # Expected errors are exactly the same as in the parallel test! l2 = [0.0015188466707237375], linf = [0.008446655719187679]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end @trixi_testset "elixir_advection_amr.jl" begin diff --git a/test/test_tree_3d_advection.jl b/test/test_tree_3d_advection.jl index f776a07f3dd..e06431e60cc 100644 --- a/test/test_tree_3d_advection.jl +++ b/test/test_tree_3d_advection.jl @@ -47,6 +47,15 @@ EXAMPLES_DIR = joinpath(pathof(Trixi) |> dirname |> dirname, "examples", "tree_3 @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), l2 = [0.001810141301577316], linf = [0.017848192256602058]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end @trixi_testset "elixir_advection_amr.jl" begin