Skip to content

Commit cb135ec

Browse files
vchuravyranocha
andcommitted
Apply suggestions from code review
Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent 7e9ccf8 commit cb135ec

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

docs/src/heterogeneous.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ CuArray
8282

8383
## Element-type conversion with `Trixi.trixi_adapt`.
8484

85-
We can use [`Trixi.trixi_adapt`](@ref) to perform both an element-type and a storage-type adoption
85+
We can use [`Trixi.trixi_adapt`](@ref) to perform both an element-type and a storage-type adoption:
8686

8787
```jldoctest adapt
8888
julia> C = Container(zeros(3))
@@ -98,7 +98,8 @@ Container{CuArray{Float32, 1, CUDA.DeviceMemory}}(Float32[0.0, 0.0, 0.0])
9898
```
9999

100100
!!! note
101-
`adapt(Array{Float32}, C)` is tempting but will do the wrong thing in the presence of `StaticArrays`.
101+
`adapt(Array{Float32}, C)` is tempting, but it will do the wrong thing
102+
in the presence of `SVector`s and similar arrays from StaticArrays.jl.
102103

103104

104105
## Writing GPU kernels
@@ -123,10 +124,10 @@ end
123124
`element`, pass all required fields as arguments, but make sure to `@unpack` them from
124125
their structs in advance.
125126

126-
2. Where `trixi_rhs_fct` is called, get the backend, i.e. the hardware we are currently
127+
2. Where `trixi_rhs_fct` is called, get the backend, i.e., the hardware we are currently
127128
running on via `trixi_backend(x)`.
128-
This will, e.g., work with `u_ode`. Internally, `KernelAbstractions.jl`'s `get_backend`
129-
will be called, i.e. `KernelAbstractions.jl` has to know the type of `x`.
129+
This will, e.g., work with `u_ode`. Internally, KernelAbstractions.jl's `get_backend`
130+
will be called, i.e., KernelAbstractions.jl has to know the type of `x`.
130131

131132
```julia
132133
backend = trixi_backend(u_ode)
@@ -143,8 +144,8 @@ end
143144
end
144145
```
145146

146-
4. When `backend` is a `Backend` (a type defined by `KernelAbstractions.jl`), write a
147-
`KernelAbstractions.jl` kernel:
147+
4. When `backend` is a `Backend` (a type defined by KernelAbstractions.jl), write a
148+
KernelAbstractions.jl kernel:
148149
```julia
149150
function trixi_rhs_fct(backend::Backend, mesh, equations, solver, cache, args)
150151
nelements(solver, cache) == 0 && return nothing # return early when there are no elements

examples/p4est_2d_dgsem/elixir_advection_basic_gpu.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ stepsize_callback = StepsizeCallback(cfl = 1.6)
4949

5050
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
5151
callbacks = CallbackSet(summary_callback, stepsize_callback)
52+
# TODO: GPU. The `analysis_callback` needs to be updated for GPU support
5253
# analysis_callback, save_solution, stepsize_callback)
5354

5455
###############################################################################

src/auxiliary/containers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function trixi_backend(x)
366366
return get_backend(x)
367367
end
368368

369-
# TODO: Remove once we have https://github.com/SciML/RecursiveArrayTools.jl/pull/455
369+
# TODO: After https://github.com/SciML/RecursiveArrayTools.jl/pull/455 we need to investigate the right way to handle StaticArray as uEltype for MultiDG.
370370
function trixi_backend(x::VectorOfArray)
371371
u = parent(x)
372372
# FIXME(vchuravy): This is a workaround because KA.get_backend is ambivalent of where a SArray is residing.

src/solvers/dgsem_p4est/containers_parallel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ mutable struct P4estMPIMortarContainer{NDIMS, uEltype <: Real, RealT <: Real, ND
128128
u::uArray # [small/large side, variable, position, i, j, mortar]
129129
local_neighbor_ids::Vector{Vector{Int}} # [mortar][ids]
130130
local_neighbor_positions::Vector{Vector{Int}} # [mortar][positions]
131-
node_indices::Matrix{NTuple{NDIMS, Symbol}} # [small/large, mortar]
131+
node_indices::Matrix{NTuple{NDIMS, Symbol}} # [small/large, mortar]
132132
normal_directions::Array{RealT, NDIMSP2} # [dimension, i, j, position, mortar]
133133
# internal `resize!`able storage
134134
_u::uVector
@@ -222,6 +222,7 @@ function init_mpi_mortars!(mpi_mortars, mesh::ParallelP4estMesh, basis, elements
222222
end
223223

224224
function Adapt.adapt_structure(to, mpi_mortars::P4estMPIMortarContainer)
225+
# TODO: GPU
225226
# Only parts of this container are adapted, since we currently don't
226227
# use `local_neighbor_ids`, `local_neighbor_positions`, `normal_directions`
227228
# on the GPU. If we do need them we need to redesign this to use the VecOfArrays

test/test_amdgpu.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem")
1616
# Expected errors are exactly the same as with TreeMesh!
1717
l2=8.311947673061856e-6,
1818
linf=6.627000273229378e-5,)
19-
# # Ensure that we do not have excessive memory allocations
20-
# # (e.g., from type instabilities)
19+
# Ensure that we do not have excessive memory allocations
20+
# (e.g., from type instabilities)
2121
let
2222
t = sol.t[end]
2323
u_ode = sol.u[end]
@@ -44,12 +44,12 @@ end
4444
using AMDGPU
4545
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"),
4646
# Expected errors are exactly the same as with TreeMesh!
47-
l2=nothing, # [Float32(8.311947673061856e-6)],
48-
linf=nothing, # [Float32(6.627000273229378e-5)],
47+
l2=nothing, # TODO: GPU. [Float32(8.311947673061856e-6)],
48+
linf=nothing, # TODO: GPU. [Float32(6.627000273229378e-5)],
4949
RealT=Float32,
5050
real_type=Float32,
5151
storage_type=ROCArray,
52-
sol=nothing,) # TODO: Remove this once we can run the simulation on the GPU
52+
sol=nothing,) # TODO: GPU. Remove this once we can run the simulation on the GPU
5353
# # Ensure that we do not have excessive memory allocations
5454
# # (e.g., from type instabilities)
5555
# let

test/test_cuda.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ end
4444
using CUDA
4545
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"),
4646
# Expected errors are exactly the same as with TreeMesh!
47-
l2=nothing, # [Float32(8.311947673061856e-6)],
48-
linf=nothing, # [Float32(6.627000273229378e-5)],
47+
l2=nothing, # TODO: GPU. [Float32(8.311947673061856e-6)],
48+
linf=nothing, # TODO: GPU. [Float32(6.627000273229378e-5)],
4949
RealT=Float32,
5050
real_type=Float32,
5151
storage_type=CuArray,
52-
sol=nothing,) # TODO: Remove this once we can run the simulation on the GPU
52+
sol=nothing,) # TODO: GPU. Remove this once we can run the simulation on the GPU
5353
# # Ensure that we do not have excessive memory allocations
5454
# # (e.g., from type instabilities)
5555
# let

0 commit comments

Comments
 (0)