From 66260c23e1f80f79db3c22ad0e5ede13fb009162 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Fri, 15 Mar 2024 13:00:38 +0100 Subject: [PATCH 1/3] add ExplicitImports.jl tests --- Project.toml | 2 -- src/Trixi.jl | 15 +++++++-------- src/auxiliary/auxiliary.jl | 2 +- test/Project.toml | 2 ++ test/test_aqua.jl | 3 +++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 97da4aec51b..0e960a06a38 100644 --- a/Project.toml +++ b/Project.toml @@ -31,7 +31,6 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Requires = "ae029012-a4dd-5104-9daa-d747884805df" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" -Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StartUpDG = "472ebc20-7c99-4d4b-9470-8fde4e9faa0f" @@ -84,7 +83,6 @@ RecipesBase = "1.1" Reexport = "1.0" Requires = "1.1" SciMLBase = "1.90, 2" -Setfield = "1" SimpleUnPack = "1.1" SparseArrays = "1" StartUpDG = "0.17.7" diff --git a/src/Trixi.jl b/src/Trixi.jl index da7359999c5..9c9c9b6e927 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -22,7 +22,7 @@ using LinearAlgebra: LinearAlgebra, Diagonal, diag, dot, mul!, norm, cross, norm UniformScaling, det using Printf: @printf, @sprintf, println using SparseArrays: AbstractSparseMatrix, AbstractSparseMatrixCSC, sparse, droptol!, - rowvals, nzrange, nonzeros, spzeros + rowvals, nzrange, nonzeros # import @reexport now to make it available for further imports/exports using Reexport: @reexport @@ -32,10 +32,10 @@ using Reexport: @reexport using MPI: MPI using SciMLBase: CallbackSet, DiscreteCallback, - ODEProblem, ODESolution, ODEFunction, + ODEProblem, ODESolution, SplitODEProblem import SciMLBase: get_du, get_tmp_cache, u_modified!, - AbstractODEIntegrator, init, step!, check_error, + init, step!, check_error, get_proposed_dt, set_proposed_dt!, terminate!, remake, add_tstop!, has_tstop, first_tstop @@ -53,11 +53,10 @@ using LoopVectorization: LoopVectorization, @turbo, indices using StaticArrayInterface: static_length # used by LoopVectorization using MuladdMacro: @muladd using Octavian: Octavian, matmul! -using Polyester: Polyester, @batch # You know, the cheapest threads you can find... +using Polyester: Polyester # You know, the cheapest threads you can find... using OffsetArrays: OffsetArray, OffsetVector using P4est using T8code -using Setfield: @set using RecipesBase: RecipesBase using Requires: @require using Static: Static, One, True, False @@ -66,7 +65,7 @@ using StaticArrays: StaticArrays, MVector, MArray, SMatrix, @SMatrix using StrideArrays: PtrArray, StrideArray, StaticInt @reexport using StructArrays: StructArrays, StructArray using TimerOutputs: TimerOutputs, @notimeit, TimerOutput, print_timer, reset_timer! -using Triangulate: Triangulate, TriangulateIO, triangulate +using Triangulate: Triangulate, TriangulateIO export TriangulateIO # for type parameter in DGMultiMesh using TriplotBase: TriplotBase using TriplotRecipes: DGTriPseudocolor @@ -84,9 +83,9 @@ const _PREFERENCE_LOG = @load_preference("log", "log_Trixi_NaN") # finite difference SBP operators using SummationByPartsOperators: AbstractDerivativeOperator, - AbstractNonperiodicDerivativeOperator, DerivativeOperator, + AbstractNonperiodicDerivativeOperator, AbstractPeriodicDerivativeOperator, - PeriodicDerivativeOperator, grid + grid import SummationByPartsOperators: integrate, semidiscretize, compute_coefficients, compute_coefficients!, left_boundary_weight, right_boundary_weight diff --git a/src/auxiliary/auxiliary.jl b/src/auxiliary/auxiliary.jl index 92da9a5ba8b..9cc06d38d84 100644 --- a/src/auxiliary/auxiliary.jl +++ b/src/auxiliary/auxiliary.jl @@ -243,7 +243,7 @@ macro threaded(expr) # Look at the comments for `wrap_array` when considering to change this macro. return esc(quote - Trixi.@batch $(expr) + Polyester.@batch $(expr) end) end diff --git a/test/Project.toml b/test/Project.toml index 1a042dab44f..1491d7a5c5f 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -16,6 +17,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Aqua = "0.8" CairoMakie = "0.10" Downloads = "1" +ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.24" LinearAlgebra = "1" diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 93457caba28..c89484db83c 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -1,6 +1,7 @@ module TestAqua using Aqua +using ExplicitImports: check_no_implicit_imports, check_no_stale_explicit_imports using Test using Trixi @@ -13,6 +14,8 @@ include("test_trixi.jl") # in src/solvers/dgmulti/sbp.jl piracies = (treat_as_own = [Trixi.StartUpDG.RefElemData, Trixi.StartUpDG.MeshData],)) + @test isnothing(check_no_implicit_imports(Trixi, skip = (Core, Base, Trixi.P4est, Trixi.T8code, Trixi.EllipsisNotation))) + @test isnothing(check_no_stale_explicit_imports(Trixi, ignore = (:derivative_operator, :periodic_derivative_operator, :upwind_operators))) end end #module From a1f7376f8f6d974bf62e13426efe84a1104aa075 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Fri, 15 Mar 2024 13:04:35 +0100 Subject: [PATCH 2/3] format --- test/test_aqua.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index c89484db83c..d0cb52c772f 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -14,8 +14,13 @@ include("test_trixi.jl") # in src/solvers/dgmulti/sbp.jl piracies = (treat_as_own = [Trixi.StartUpDG.RefElemData, Trixi.StartUpDG.MeshData],)) - @test isnothing(check_no_implicit_imports(Trixi, skip = (Core, Base, Trixi.P4est, Trixi.T8code, Trixi.EllipsisNotation))) - @test isnothing(check_no_stale_explicit_imports(Trixi, ignore = (:derivative_operator, :periodic_derivative_operator, :upwind_operators))) + @test isnothing(check_no_implicit_imports(Trixi, + skip = (Core, Base, Trixi.P4est, Trixi.T8code, + Trixi.EllipsisNotation))) + @test isnothing(check_no_stale_explicit_imports(Trixi, + ignore = (:derivative_operator, + :periodic_derivative_operator, + :upwind_operators))) end end #module From 9a3ca0866610fbec3868e1475a3ccaaa3fecaa51 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Fri, 15 Mar 2024 14:27:41 +0100 Subject: [PATCH 3/3] use Trixi.at-batch in at-threaded and skipt at-batch in stale explicit imports test --- src/Trixi.jl | 2 +- src/auxiliary/auxiliary.jl | 4 +++- test/test_aqua.jl | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 9c9c9b6e927..9375c80d77e 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -53,7 +53,7 @@ using LoopVectorization: LoopVectorization, @turbo, indices using StaticArrayInterface: static_length # used by LoopVectorization using MuladdMacro: @muladd using Octavian: Octavian, matmul! -using Polyester: Polyester # You know, the cheapest threads you can find... +using Polyester: Polyester, @batch # You know, the cheapest threads you can find... using OffsetArrays: OffsetArray, OffsetVector using P4est using T8code diff --git a/src/auxiliary/auxiliary.jl b/src/auxiliary/auxiliary.jl index 9cc06d38d84..972a748c56b 100644 --- a/src/auxiliary/auxiliary.jl +++ b/src/auxiliary/auxiliary.jl @@ -242,8 +242,10 @@ macro threaded(expr) # !!! danger "Heisenbug" # Look at the comments for `wrap_array` when considering to change this macro. + # By using `Trixi.@batch` we allow users of Trixi.jl to use `@threaded` without having + # Polyester.jl in their namespace. return esc(quote - Polyester.@batch $(expr) + Trixi.@batch $(expr) end) end diff --git a/test/test_aqua.jl b/test/test_aqua.jl index d0cb52c772f..04c4a533d26 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -20,7 +20,8 @@ include("test_trixi.jl") @test isnothing(check_no_stale_explicit_imports(Trixi, ignore = (:derivative_operator, :periodic_derivative_operator, - :upwind_operators))) + :upwind_operators, + Symbol("@batch")))) end end #module