From be3c65c4d806911c68a6287fdf07200064079ae0 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 18 Sep 2023 15:42:07 +0200 Subject: [PATCH 1/4] Increase type stab, avoid allocs --- src/solvers/dgsem_unstructured/dg_2d.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/solvers/dgsem_unstructured/dg_2d.jl b/src/solvers/dgsem_unstructured/dg_2d.jl index 7b8dafdddd2..5d9c14df4e2 100644 --- a/src/solvers/dgsem_unstructured/dg_2d.jl +++ b/src/solvers/dgsem_unstructured/dg_2d.jl @@ -313,7 +313,7 @@ function calc_boundary_flux!(cache, t, boundary_condition::BoundaryConditionPeri end # Function barrier for type stability -function calc_boundary_flux!(cache, t, boundary_conditions, +function calc_boundary_flux!(cache, t, boundary_conditions::UnstructuredSortedBoundaryTypes, mesh::Union{UnstructuredMesh2D, P4estMesh, T8codeMesh}, equations, surface_integral, dg::DG) @unpack boundary_condition_types, boundary_indices = boundary_conditions @@ -357,9 +357,9 @@ function calc_boundary_flux_by_type!(cache, t, BCs::Tuple{}, BC_indices::Tuple{} nothing end -function calc_boundary_flux!(cache, t, boundary_condition, boundary_indexing, +function calc_boundary_flux!(cache, t, boundary_condition::BC, boundary_indexing, mesh::UnstructuredMesh2D, equations, - surface_integral, dg::DG) + surface_integral, dg::DG) where {BC} @unpack surface_flux_values = cache.elements @unpack element_id, element_side_id = cache.boundaries @@ -383,12 +383,12 @@ end # inlined version of the boundary flux calculation along a physical interface where the # boundary flux values are set according to a particular `boundary_condition` function -@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition, +@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition::BC, mesh::UnstructuredMesh2D, nonconservative_terms::False, equations, surface_integral, dg::DG, cache, node_index, side_index, element_index, - boundary_index) + boundary_index) where{BC} @unpack normal_directions = cache.elements @unpack u, node_coordinates = cache.boundaries @unpack surface_flux = surface_integral @@ -417,12 +417,12 @@ end # Note, it is necessary to set and add in the nonconservative values because # the upper left/lower right diagonal terms have been peeled off due to the use of # `derivative_split` from `dg.basis` in [`flux_differencing_kernel!`](@ref) -@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition, +@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition::BC, mesh::UnstructuredMesh2D, nonconservative_terms::True, equations, surface_integral, dg::DG, cache, node_index, side_index, element_index, - boundary_index) + boundary_index) where {BC} surface_flux, nonconservative_flux = surface_integral.surface_flux @unpack normal_directions = cache.elements @unpack u, node_coordinates = cache.boundaries From b69621238cc9fb7f17154b2a9dcecb6ac25c5aca Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 18 Sep 2023 15:52:26 +0200 Subject: [PATCH 2/4] format --- src/solvers/dgsem_unstructured/dg_2d.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/solvers/dgsem_unstructured/dg_2d.jl b/src/solvers/dgsem_unstructured/dg_2d.jl index 5d9c14df4e2..659e6c06e13 100644 --- a/src/solvers/dgsem_unstructured/dg_2d.jl +++ b/src/solvers/dgsem_unstructured/dg_2d.jl @@ -313,7 +313,8 @@ function calc_boundary_flux!(cache, t, boundary_condition::BoundaryConditionPeri end # Function barrier for type stability -function calc_boundary_flux!(cache, t, boundary_conditions::UnstructuredSortedBoundaryTypes, +function calc_boundary_flux!(cache, t, + boundary_conditions::UnstructuredSortedBoundaryTypes, mesh::Union{UnstructuredMesh2D, P4estMesh, T8codeMesh}, equations, surface_integral, dg::DG) @unpack boundary_condition_types, boundary_indices = boundary_conditions @@ -388,7 +389,7 @@ end nonconservative_terms::False, equations, surface_integral, dg::DG, cache, node_index, side_index, element_index, - boundary_index) where{BC} + boundary_index) where {BC} @unpack normal_directions = cache.elements @unpack u, node_coordinates = cache.boundaries @unpack surface_flux = surface_integral From b2116e1bb24404a51816a11a49b8d3534ec43683 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 19 Sep 2023 16:07:36 +0200 Subject: [PATCH 3/4] test seems no longer broken --- test/test_threaded.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 2337d73f30a..b13b5d0f5fc 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -312,11 +312,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) t = sol.t[end] u_ode = sol.u[end] du_ode = similar(u_ode) - if (Threads.nthreads() < 2) || (VERSION < v"1.9") - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 - else - @test_broken (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 - end + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end From 2e626cd650ffa043dac62520ca2753eeddfae4b7 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 19 Sep 2023 21:19:24 +0200 Subject: [PATCH 4/4] only essentials --- src/solvers/dgsem_unstructured/dg_2d.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/solvers/dgsem_unstructured/dg_2d.jl b/src/solvers/dgsem_unstructured/dg_2d.jl index 659e6c06e13..b12a96c4c31 100644 --- a/src/solvers/dgsem_unstructured/dg_2d.jl +++ b/src/solvers/dgsem_unstructured/dg_2d.jl @@ -313,8 +313,7 @@ function calc_boundary_flux!(cache, t, boundary_condition::BoundaryConditionPeri end # Function barrier for type stability -function calc_boundary_flux!(cache, t, - boundary_conditions::UnstructuredSortedBoundaryTypes, +function calc_boundary_flux!(cache, t, boundary_conditions, mesh::Union{UnstructuredMesh2D, P4estMesh, T8codeMesh}, equations, surface_integral, dg::DG) @unpack boundary_condition_types, boundary_indices = boundary_conditions @@ -384,12 +383,12 @@ end # inlined version of the boundary flux calculation along a physical interface where the # boundary flux values are set according to a particular `boundary_condition` function -@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition::BC, +@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition, mesh::UnstructuredMesh2D, nonconservative_terms::False, equations, surface_integral, dg::DG, cache, node_index, side_index, element_index, - boundary_index) where {BC} + boundary_index) @unpack normal_directions = cache.elements @unpack u, node_coordinates = cache.boundaries @unpack surface_flux = surface_integral @@ -418,12 +417,12 @@ end # Note, it is necessary to set and add in the nonconservative values because # the upper left/lower right diagonal terms have been peeled off due to the use of # `derivative_split` from `dg.basis` in [`flux_differencing_kernel!`](@ref) -@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition::BC, +@inline function calc_boundary_flux!(surface_flux_values, t, boundary_condition, mesh::UnstructuredMesh2D, nonconservative_terms::True, equations, surface_integral, dg::DG, cache, node_index, side_index, element_index, - boundary_index) where {BC} + boundary_index) surface_flux, nonconservative_flux = surface_integral.surface_flux @unpack normal_directions = cache.elements @unpack u, node_coordinates = cache.boundaries