Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
- mpi
- threaded
- kernelabstractions
- serial
- threads
Comment on lines +89 to +90
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a bit more descriptive name for it, e.g., base_threads or so?

include:
- version: '1.11'
os: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,24 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3)
Trixi.set_threading_backend!(Symbol(previous_backend))
end
end

@time if TRIXI_TEST == "all" || TRIXI_TEST == "serial"
previous_backend = Trixi._PREFERENCE_THREADING
Trixi.set_threading_backend!(:serial)
try
run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes $(abspath("test_serial.jl"))`)
finally
Trixi.set_threading_backend!(Symbol(previous_backend))
end
end

@time if TRIXI_TEST == "all" || TRIXI_TEST == "threads"
previous_backend = Trixi._PREFERENCE_THREADING
Trixi.set_threading_backend!(:static)
try
run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes $(abspath("test_threads.jl"))`)
finally
Trixi.set_threading_backend!(Symbol(previous_backend))
end
end
end
58 changes: 58 additions & 0 deletions test/test_serial.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module TestExamplesSerial

using Test
using Trixi

include("test_trixi.jl")

EXAMPLES_DIR = examples_dir()

# Start with a clean environment: remove Trixi.jl output directory if it exists
outdir = "out"
Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true)
Trixi.MPI.Barrier(Trixi.mpi_comm())

@testset "basic" begin
@test Trixi._PREFERENCE_THREADING == :serial
end

@testset "Serial 2D" begin
#! format: noindent

@trixi_testset "elixir_advection_amr_refine_twice.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_amr_refine_twice.jl"),
l2=[0.00020547512522578292],
linf=[0.007831753383083506])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 5000)
end

@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_euler_source_terms_nonperiodic.jl"),
l2=[
2.259440511766445e-6,
2.318888155713922e-6,
2.3188881557894307e-6,
6.3327863238858925e-6
],
linf=[
1.498738264560373e-5,
1.9182011928187137e-5,
1.918201192685487e-5,
6.0526717141407005e-5
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 5000)
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

end # testset

# Clean up afterwards: delete Trixi.jl output directory
Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true)
Trixi.MPI.Barrier(Trixi.mpi_comm())

end # module
61 changes: 61 additions & 0 deletions test/test_threads.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module TestExamplesThreads

using Test
using Trixi

include("test_trixi.jl")

EXAMPLES_DIR = examples_dir()

# Start with a clean environment: remove Trixi.jl output directory if it exists
outdir = "out"
Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true)
Trixi.MPI.Barrier(Trixi.mpi_comm())

@testset "basic" begin
@test Trixi._PREFERENCE_THREADING == :static
end

@testset "Threads.@threads 2D" begin
#! format: noindent

@trixi_testset "elixir_advection_amr_refine_twice.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_amr_refine_twice.jl"),
l2=[0.00020547512522578292],
linf=[0.007831753383083506])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
# Threads.@threads :static has more overhead than Polyester's @batch
@test_allocations(Trixi.rhs!, semi, sol, 30_000)
end

@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_euler_source_terms_nonperiodic.jl"),
l2=[
2.259440511766445e-6,
2.318888155713922e-6,
2.3188881557894307e-6,
6.3327863238858925e-6
],
linf=[
1.498738264560373e-5,
1.9182011928187137e-5,
1.918201192685487e-5,
6.0526717141407005e-5
],
rtol=0.001)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
# Threads.@threads :static has more overhead than Polyester's @batch
@test_allocations(Trixi.rhs!, semi, sol, 50_000)
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

end # testset

# Clean up afterwards: delete Trixi.jl output directory
Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true)
Trixi.MPI.Barrier(Trixi.mpi_comm())

end # module
Loading