Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/runtests.jl
5582 views
1
using Test
2
using MPI: mpiexec
3
import Trixi
4
5
# We run tests in parallel with CI jobs setting the `TRIXI_TEST` environment
6
# variable to determine the subset of tests to execute.
7
# By default, we just run the threaded tests since they are relatively cheap
8
# and test a good amount of different functionality.
9
const TRIXI_TEST = get(ENV, "TRIXI_TEST", "threaded")
10
# Some GitHub CI runners may have not much RAM and just 3 virtual CPU cores.
11
# In this case, we do not want to use all of the cores to speed-up CI.
12
const TRIXI_MPI_NPROCS = clamp(Sys.CPU_THREADS - 1, 2, 3)
13
const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3)
14
15
@time @testset "Trixi.jl tests" begin
16
# This is placed first since tests error out otherwise if `TRIXI_TEST == "all"`,
17
# at least on some systems.
18
@time if TRIXI_TEST == "all" || TRIXI_TEST == "mpi"
19
# Do a dummy `@test true`:
20
# If the process errors out the testset would error out as well,
21
# cf. https://github.com/JuliaParallel/MPI.jl/pull/391
22
@test true
23
24
# We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing
25
mpiexec() do cmd
26
run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=0.5G $(joinpath(@__DIR__, "test_mpi.jl"))`)
27
return nothing
28
end
29
end
30
31
@time if TRIXI_TEST == "all" || TRIXI_TEST == "threaded" ||
32
TRIXI_TEST == "threaded_legacy"
33
# Do a dummy `@test true`:
34
# If the process errors out the testset would error out as well,
35
# cf. https://github.com/JuliaParallel/MPI.jl/pull/391
36
@test true
37
38
run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(joinpath(@__DIR__, "test_threaded.jl"))`)
39
end
40
41
# Downgrade CI currently has issues with running julia processes via `run`, see
42
# https://github.com/trixi-framework/Trixi.jl/pull/2507#issuecomment-3990318366
43
# So we run test_threaded.jl serially.
44
# For `TRIXI_TEST = "all"`, test_threaded.jl is already covered by the threaded run, so we don't need to run it again.
45
@time if TRIXI_TEST == "downgrade"
46
include(joinpath(@__DIR__, "test_threaded.jl"))
47
end
48
49
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1"
50
include(joinpath(@__DIR__, "test_tree_1d.jl"))
51
include(joinpath(@__DIR__, "test_tree_2d_part1.jl"))
52
end
53
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part2"
54
include(joinpath(@__DIR__, "test_tree_2d_part2.jl"))
55
end
56
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part3"
57
include(joinpath(@__DIR__, "test_tree_2d_part3.jl"))
58
end
59
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part4"
60
include(joinpath(@__DIR__, "test_tree_3d_part1.jl"))
61
end
62
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part5"
63
include(joinpath(@__DIR__, "test_tree_3d_part2.jl"))
64
end
65
@time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part6"
66
include(joinpath(@__DIR__, "test_tree_3d_part3.jl"))
67
end
68
69
@time if TRIXI_TEST == "all" || TRIXI_TEST == "structured"
70
include(joinpath(@__DIR__, "test_structured_1d.jl"))
71
include(joinpath(@__DIR__, "test_structured_2d.jl"))
72
include(joinpath(@__DIR__, "test_structured_3d.jl"))
73
end
74
75
@time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part1"
76
include(joinpath(@__DIR__, "test_p4est_2d.jl"))
77
end
78
@time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part2"
79
include(joinpath(@__DIR__, "test_p4est_3d.jl"))
80
end
81
82
@time if TRIXI_TEST == "all" || TRIXI_TEST == "t8code_part1"
83
include(joinpath(@__DIR__, "test_t8code_2d.jl"))
84
end
85
@time if TRIXI_TEST == "all" || TRIXI_TEST == "t8code_part2"
86
include(joinpath(@__DIR__, "test_t8code_3d.jl"))
87
end
88
89
@time if TRIXI_TEST == "all" || TRIXI_TEST == "unstructured_dgmulti"
90
include(joinpath(@__DIR__, "test_unstructured_2d.jl"))
91
include(joinpath(@__DIR__, "test_dgmulti_1d.jl"))
92
include(joinpath(@__DIR__, "test_dgmulti_2d.jl"))
93
include(joinpath(@__DIR__, "test_dgmulti_3d.jl"))
94
end
95
96
@time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic_part1"
97
include(joinpath(@__DIR__, "test_parabolic_1d.jl"))
98
include(joinpath(@__DIR__, "test_parabolic_2d.jl"))
99
end
100
@time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic_part2"
101
include(joinpath(@__DIR__, "test_parabolic_3d.jl"))
102
end
103
104
@time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part1"
105
include(joinpath(@__DIR__, "test_unit.jl"))
106
include(joinpath(@__DIR__, "test_type.jl"))
107
include(joinpath(@__DIR__, "test_visualization.jl"))
108
end
109
@time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part2"
110
include(joinpath(@__DIR__, "test_special_elixirs.jl"))
111
include(joinpath(@__DIR__, "test_aqua.jl"))
112
end
113
114
@time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations"
115
include(joinpath(@__DIR__, "test_performance_specializations_2d.jl"))
116
include(joinpath(@__DIR__, "test_performance_specializations_3d.jl"))
117
end
118
119
@time if TRIXI_TEST == "all" || TRIXI_TEST == "paper_self_gravitating_gas_dynamics"
120
include(joinpath(@__DIR__, "test_paper_self_gravitating_gas_dynamics.jl"))
121
end
122
123
@time if TRIXI_TEST == "all" || TRIXI_TEST == "CUDA"
124
import CUDA
125
if CUDA.functional()
126
include(joinpath(@__DIR__, "test_cuda_2d.jl"))
127
include(joinpath(@__DIR__, "test_cuda_3d.jl"))
128
else
129
@warn "Unable to run CUDA tests on this machine"
130
end
131
end
132
133
@time if TRIXI_TEST == "all" || TRIXI_TEST == "AMDGPU"
134
import AMDGPU
135
if AMDGPU.functional()
136
include(joinpath(@__DIR__, "test_amdgpu_2d.jl"))
137
include(joinpath(@__DIR__, "test_amdgpu_3d.jl"))
138
else
139
@warn "Unable to run AMDGPU tests on this machine"
140
end
141
end
142
143
@time if TRIXI_TEST == "all" || TRIXI_TEST == "kernelabstractions"
144
previous_backend = Trixi._PREFERENCE_THREADING
145
Trixi.set_threading_backend!(:kernelabstractions)
146
# relaunching julia
147
try
148
run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes $(abspath("test_kernelabstractions.jl"))`)
149
finally
150
# Restore previous threading backend for later tests
151
Trixi.set_threading_backend!(Symbol(previous_backend))
152
end
153
end
154
end
155
156