Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_cuda.jl
2802 views
1
module TestCUDA
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
# Start with a clean environment: remove Trixi.jl output directory if it exists
9
outdir = "out"
10
isdir(outdir) && rm(outdir, recursive = true)
11
12
EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem")
13
14
@trixi_testset "elixir_advection_basic_gpu.jl native" begin
15
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"),
16
# Expected errors are exactly the same as with TreeMesh!
17
l2=8.311947673061856e-6,
18
linf=6.627000273229378e-5)
19
# Ensure that we do not have excessive memory allocations
20
# (e.g., from type instabilities)
21
@test_allocations(Trixi.rhs!, semi, sol, 1000)
22
@test real(ode.p.solver) == Float64
23
@test real(ode.p.solver.basis) == Float64
24
@test real(ode.p.solver.mortar) == Float64
25
# TODO: `mesh` is currently not `adapt`ed correctly
26
@test real(ode.p.mesh) == Float64
27
28
@test ode.u0 isa Array
29
@test ode.p.solver.basis.derivative_matrix isa Array
30
31
@test Trixi.storage_type(ode.p.cache.elements) === Array
32
@test Trixi.storage_type(ode.p.cache.interfaces) === Array
33
@test Trixi.storage_type(ode.p.cache.boundaries) === Array
34
@test Trixi.storage_type(ode.p.cache.mortars) === Array
35
end
36
37
@trixi_testset "elixir_advection_basic_gpu.jl Float32 / CUDA" begin
38
# Using CUDA inside the testset since otherwise the bindings are hiddend by the anonymous modules
39
using CUDA
40
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"),
41
# Expected errors are exactly the same as with TreeMesh!
42
l2=nothing, # TODO: GPU. [Float32(8.311947673061856e-6)],
43
linf=nothing, # TODO: GPU. [Float32(6.627000273229378e-5)],
44
RealT_for_test_tolerances=Float32,
45
real_type=Float32,
46
storage_type=CuArray,
47
sol=nothing,) # TODO: GPU. Remove this once we can run the simulation on the GPU
48
# # Ensure that we do not have excessive memory allocations
49
# # (e.g., from type instabilities)
50
# @test_allocations(Trixi.rhs!, semi, sol, 1000)
51
@test real(ode.p.solver) == Float32
52
@test real(ode.p.solver.basis) == Float32
53
@test real(ode.p.solver.mortar) == Float32
54
# TODO: `mesh` is currently not `adapt`ed correctly
55
@test real(ode.p.mesh) == Float64
56
57
@test ode.u0 isa CuArray
58
@test ode.p.solver.basis.derivative_matrix isa CuArray
59
60
@test Trixi.storage_type(ode.p.cache.elements) === CuArray
61
@test Trixi.storage_type(ode.p.cache.interfaces) === CuArray
62
@test Trixi.storage_type(ode.p.cache.boundaries) === CuArray
63
@test Trixi.storage_type(ode.p.cache.mortars) === CuArray
64
end
65
66
# Clean up afterwards: delete Trixi.jl output directory
67
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
68
69
end # module
70
71