|
| 1 | +module TestAMDGPU |
| 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 | + let |
| 22 | + t = sol.t[end] |
| 23 | + u_ode = sol.u[end] |
| 24 | + du_ode = similar(u_ode) |
| 25 | + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 |
| 26 | + end |
| 27 | + @test real(ode.p.solver) == Float64 |
| 28 | + @test real(ode.p.solver.basis) == Float64 |
| 29 | + @test real(ode.p.solver.mortar) == Float64 |
| 30 | + # TODO: remake ignores the mesh itself as well |
| 31 | + @test real(ode.p.mesh) == Float64 |
| 32 | + |
| 33 | + @test ode.u0 isa Array |
| 34 | + @test ode.p.solver.basis.derivative_matrix isa Array |
| 35 | + |
| 36 | + @test Trixi.storage_type(ode.p.cache.elements) === Array |
| 37 | + @test Trixi.storage_type(ode.p.cache.interfaces) === Array |
| 38 | + @test Trixi.storage_type(ode.p.cache.boundaries) === Array |
| 39 | + @test Trixi.storage_type(ode.p.cache.mortars) === Array |
| 40 | +end |
| 41 | + |
| 42 | +@trixi_testset "elixir_advection_basic_gpu.jl Float32 / AMDGPU" begin |
| 43 | + # Using AMDGPU inside the testset since otherwise the bindings are hiddend by the anonymous modules |
| 44 | + using AMDGPU |
| 45 | + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"), |
| 46 | + # Expected errors are exactly the same as with TreeMesh! |
| 47 | + l2=nothing, # TODO: GPU. [Float32(8.311947673061856e-6)], |
| 48 | + linf=nothing, # TODO: GPU. [Float32(6.627000273229378e-5)], |
| 49 | + RealT=Float32, |
| 50 | + real_type=Float32, |
| 51 | + storage_type=ROCArray, |
| 52 | + sol=nothing,) # TODO: GPU. Remove this once we can run the simulation on the GPU |
| 53 | + # # Ensure that we do not have excessive memory allocations |
| 54 | + # # (e.g., from type instabilities) |
| 55 | + # let |
| 56 | + # t = sol.t[end] |
| 57 | + # u_ode = sol.u[end] |
| 58 | + # du_ode = similar(u_ode) |
| 59 | + # @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 |
| 60 | + # end |
| 61 | + @test real(ode.p.solver) == Float32 |
| 62 | + @test real(ode.p.solver.basis) == Float32 |
| 63 | + @test real(ode.p.solver.mortar) == Float32 |
| 64 | + # TODO: remake ignores the mesh itself as well |
| 65 | + @test real(ode.p.mesh) == Float64 |
| 66 | + |
| 67 | + @test ode.u0 isa ROCArray |
| 68 | + @test ode.p.solver.basis.derivative_matrix isa ROCArray |
| 69 | + |
| 70 | + @test Trixi.storage_type(ode.p.cache.elements) === ROCArray |
| 71 | + @test Trixi.storage_type(ode.p.cache.interfaces) === ROCArray |
| 72 | + @test Trixi.storage_type(ode.p.cache.boundaries) === ROCArray |
| 73 | + @test Trixi.storage_type(ode.p.cache.mortars) === ROCArray |
| 74 | +end |
| 75 | + |
| 76 | +# Clean up afterwards: delete Trixi.jl output directory |
| 77 | +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) |
| 78 | + |
| 79 | +end # module |
0 commit comments