Skip to content

Commit 13d8654

Browse files
committed
remove AbstractHeterogenousContainer for now
1 parent d4425de commit 13d8654

File tree

6 files changed

+21
-40
lines changed

6 files changed

+21
-40
lines changed

src/semidiscretization/semidiscretization_hyperbolic.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ function remake(semi::SemidiscretizationHyperbolic; uEltype = real(semi.solver),
109109
source_terms, boundary_conditions, uEltype)
110110
end
111111

112-
Adapt.@adapt_structure(SemidiscretizationHyperbolic)
112+
# @eval due to @muladd
113+
@eval Adapt.@adapt_structure(SemidiscretizationHyperbolic)
113114

114115
# general fallback
115116
function digest_boundary_conditions(boundary_conditions, mesh, solver, cache)

src/solvers/dgsem/basis_lobatto_legendre.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ In particular, not the nodes themselves are returned.
122122

123123
@inline get_nodes(basis::LobattoLegendreBasis) = basis.nodes
124124

125-
Adapt.@adapt_structure(LobattoLegendreBasis)
125+
# @eval due to @muladd
126+
@eval Adapt.@adapt_structure(LobattoLegendreBasis)
126127

127128
"""
128129
integrate(f, u, basis::LobattoLegendreBasis)
@@ -207,7 +208,8 @@ end
207208

208209
@inline polydeg(mortar::LobattoLegendreMortarL2) = nnodes(mortar) - 1
209210

210-
Adapt.@adapt_structure(LobattoLegendreMortarL2)
211+
# @eval due to @muladd
212+
@eval Adapt.@adapt_structure(LobattoLegendreMortarL2)
211213

212214
# TODO: We can create EC mortars along the lines of the following implementation.
213215
# abstract type AbstractMortarEC{RealT} <: AbstractMortar{RealT} end

src/solvers/dgsem_p4est/containers.jl

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mutable struct P4estElementContainer{NDIMS, RealT <: Real, uEltype <: Real, NDIM
1313
VectorRealT <: DenseVector{RealT},
1414
VectoruEltype <: DenseVector{uEltype},
1515
ArrayType, Bool} <:
16-
AbstractHeterogeneousContainer{ArrayType, Bool}
16+
AbstractContainer
1717
# Physical coordinates at each node
1818
node_coordinates::ArrayNDIMSP2 # [orientation, node_i, node_j, node_k, element]
1919
# Jacobian matrix of the transformation
@@ -143,11 +143,7 @@ function init_elements(mesh::Union{P4estMesh{NDIMS, NDIMS, RealT},
143143
return elements
144144
end
145145

146-
# Required methods due to <: AbstractHeterogeneousContainer
147-
function KernelAbstractions.get_backend(elements::P4estElementContainer)
148-
return KernelAbstractions.get_backend(elements.node_coordinates)
149-
end
150-
# Adapt.@adapt_structure(P4estElementContainer)
146+
# Manual adapt_structure since we have aliasing memory
151147
function Adapt.adapt_structure(to,
152148
elements::P4estElementContainer{NDIMS, RealT, uEltype}) where {
153149
NDIMS,
@@ -208,7 +204,7 @@ mutable struct P4estInterfaceContainer{NDIMS, uEltype <: Real, NDIMSP2,
208204
IndicesVector <:
209205
DenseVector{NTuple{NDIMS, Symbol}},
210206
ArrayType, Bool} <:
211-
AbstractHeterogeneousContainer{ArrayType, Bool}
207+
AbstractContainer
212208
u::uArray # [primary/secondary, variable, i, j, interface]
213209
neighbor_ids::IdsMatrix # [primary/secondary, interface]
214210
node_indices::IndicesMatrix # [primary/secondary, interface]
@@ -297,11 +293,7 @@ function init_interfaces!(interfaces, mesh::Union{P4estMesh, P4estMeshView})
297293
return interfaces
298294
end
299295

300-
# Required methods due to <: AbstractHeterogeneousContainer
301-
function KernelAbstractions.get_backend(interfaces::P4estInterfaceContainer)
302-
return KernelAbstractions.get_backend(interfaces.u)
303-
end
304-
# Adapt.@adapt_structure(P4estInterfaceContainer)
296+
# Manual adapt_structure since we have aliasing memory
305297
function Adapt.adapt_structure(to, interfaces::P4estInterfaceContainer)
306298
# Adapt underlying storage
307299
_u = Adapt.adapt_structure(to, interfaces._u)
@@ -333,7 +325,7 @@ mutable struct P4estBoundaryContainer{NDIMS, uEltype <: Real, NDIMSP1,
333325
DenseVector{NTuple{NDIMS, Symbol}},
334326
uVector <: DenseVector{uEltype}, ArrayType,
335327
Bool} <:
336-
AbstractHeterogeneousContainer{ArrayType, Bool}
328+
AbstractContainer
337329
u::uArray # [variables, i, j, boundary]
338330
neighbor_ids::IdsVector # [boundary]
339331
node_indices::IndicesVector # [boundary]
@@ -446,11 +438,7 @@ function init_boundaries_iter_face_inner(info_pw, boundaries, boundary_id, mesh)
446438
return nothing
447439
end
448440

449-
# Required methods due to <: AbstractHeterogeneousContainer
450-
function KernelAbstractions.get_backend(boundaries::P4estBoundaryContainer)
451-
return KernelAbstractions.get_backend(boundaries.u)
452-
end
453-
#Adapt.@adapt_structure(P4estBoundaryContainer)
441+
# Manual adapt_structure since we have aliasing memory
454442
function Adapt.adapt_structure(to, boundaries::P4estBoundaryContainer)
455443
_u = Adapt.adapt_structure(to, boundaries._u)
456444
u = unsafe_wrap_or_alloc(to, _u, size(boundaries.u))
@@ -500,7 +488,7 @@ mutable struct P4estMortarContainer{NDIMS, uEltype <: Real, NDIMSP1, NDIMSP3,
500488
IndicesVector <:
501489
DenseVector{NTuple{NDIMS, Symbol}},
502490
ArrayType, Bool} <:
503-
AbstractHeterogeneousContainer{ArrayType, Bool}
491+
AbstractContainer
504492
u::uArray # [small/large side, variable, position, i, j, mortar]
505493
neighbor_ids::IdsMatrix # [position, mortar]
506494
node_indices::IndicesMatrix # [small/large, mortar]
@@ -588,11 +576,7 @@ function init_mortars!(mortars, mesh::Union{P4estMesh, P4estMeshView})
588576
return mortars
589577
end
590578

591-
# Required methods due to <: AbstractHeterogeneousContainer
592-
function KernelAbstractions.get_backend(mortars::P4estMortarContainer)
593-
return KernelAbstractions.get_backend(mortars.u)
594-
end
595-
# Adapt.@adapt_structure P4estMortarContainer
579+
# Manual adapt_structure since we have aliasing memory
596580
function Adapt.adapt_structure(to, mortars::P4estMortarContainer)
597581
# Adapt underlying storage
598582
_u = Adapt.adapt_structure(to, mortars._u)

src/solvers/dgsem_p4est/containers_parallel.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mutable struct P4estMPIInterfaceContainer{NDIMS, uEltype <: Real, NDIMSP2,
1212
DenseVector{NTuple{NDIMS, Symbol}},
1313
uVector <: DenseVector{uEltype},
1414
ArrayType, Bool} <:
15-
AbstractHeterogeneousContainer{ArrayType, Bool}
15+
AbstractContainer
1616
u::uArray # [primary/secondary, variable, i, j, interface]
1717
local_neighbor_ids::VecInt # [interface]
1818
node_indices::IndicesVector # [interface]
@@ -90,11 +90,7 @@ function init_mpi_interfaces!(mpi_interfaces, mesh::ParallelP4estMesh)
9090
return mpi_interfaces
9191
end
9292

93-
# Required methods due to <: AbstractHeterogeneousContainer
94-
function KernelAbstractions.get_backend(mpi_interfaces::P4estMPIInterfaceContainer)
95-
return KernelAbstractions.get_backend(mpi_interfaces.u)
96-
end
97-
# Adapt.@adapt_structure(P4estMPIInterfaceContainer)
93+
# Manual adapt_structure since we have aliasing memory
9894
function Adapt.adapt_structure(to, mpi_interfaces::P4estMPIInterfaceContainer)
9995
# Adapt Vectors and underlying storage
10096
_u = Adapt.adapt_structure(to, mpi_interfaces._u)
@@ -125,7 +121,7 @@ mutable struct P4estMPIMortarContainer{NDIMS, uEltype <: Real, RealT <: Real, ND
125121
uArray <: DenseArray{uEltype, NDIMSP3},
126122
uVector <: DenseVector{uEltype},
127123
ArrayType, Bool} <:
128-
AbstractHeterogeneousContainer{ArrayType, Bool}
124+
AbstractContainer
129125
u::uArray # [small/large side, variable, position, i, j, mortar]
130126
local_neighbor_ids::Vector{Vector{Int}} # [mortar][ids]
131127
local_neighbor_positions::Vector{Vector{Int}} # [mortar][positions]
@@ -223,10 +219,6 @@ function init_mpi_mortars!(mpi_mortars, mesh::ParallelP4estMesh, basis, elements
223219
return mpi_mortars
224220
end
225221

226-
# Required methods due to <: AbstractHeterogeneousContainer
227-
function KernelAbstractions.get_backend(mpi_mortars::P4estMPIMortarContainer)
228-
return KernelAbstractions.get_backend(mpi_mortars.u)
229-
end
230222
function Adapt.adapt_structure(to, mpi_mortars::P4estMPIMortarContainer)
231223
# TODO: Vector of Vector type data structure does not work on GPUs,
232224
# must be redesigned. This skeleton implementation here just exists just

src/solvers/dgsem_p4est/dg_parallel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ end
4747

4848
@inline Base.eltype(::P4estMPICache{BufferType}) where {BufferType} = eltype(BufferType)
4949

50-
Adapt.@adapt_structure(P4estMPICache)
50+
# @eval due to @muladd
51+
@eval Adapt.@adapt_structure(P4estMPICache)
5152

5253
##
5354
# Note that the code in `start_mpi_send`/`finish_mpi_receive!` is sensitive to inference on (at least) Julia 1.10.

src/solvers/dgsem_unstructured/sort_boundary_conditions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,6 @@ function initialize!(boundary_types_container::UnstructuredSortedBoundaryTypes{N
122122
return boundary_types_container
123123
end
124124

125-
Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
125+
# @eval due to @muladd
126+
@eval Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
126127
end # @muladd

0 commit comments

Comments
 (0)