Skip to content

Commit cb1f54e

Browse files
committed
remove AbstractHeterogenousContainer for now
1 parent 72cb0f2 commit cb1f54e

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
@@ -142,11 +142,7 @@ function init_elements(mesh::Union{P4estMesh{NDIMS, NDIMS, RealT},
142142
return elements
143143
end
144144

145-
# Required methods due to <: AbstractHeterogeneousContainer
146-
function KernelAbstractions.get_backend(elements::P4estElementContainer)
147-
return KernelAbstractions.get_backend(elements.node_coordinates)
148-
end
149-
# Adapt.@adapt_structure(P4estElementContainer)
145+
# Manual adapt_structure since we have aliasing memory
150146
function Adapt.adapt_structure(to,
151147
elements::P4estElementContainer{NDIMS, RealT, uEltype}) where {
152148
NDIMS,
@@ -207,7 +203,7 @@ mutable struct P4estInterfaceContainer{NDIMS, uEltype <: Real, NDIMSP2,
207203
IndicesVector <:
208204
DenseVector{NTuple{NDIMS, Symbol}},
209205
ArrayType, Bool} <:
210-
AbstractHeterogeneousContainer{ArrayType, Bool}
206+
AbstractContainer
211207
u::uArray # [primary/secondary, variable, i, j, interface]
212208
neighbor_ids::IdsMatrix # [primary/secondary, interface]
213209
node_indices::IndicesMatrix # [primary/secondary, interface]
@@ -295,11 +291,7 @@ function init_interfaces!(interfaces, mesh::P4estMesh)
295291
return interfaces
296292
end
297293

298-
# Required methods due to <: AbstractHeterogeneousContainer
299-
function KernelAbstractions.get_backend(interfaces::P4estInterfaceContainer)
300-
return KernelAbstractions.get_backend(interfaces.u)
301-
end
302-
# Adapt.@adapt_structure(P4estInterfaceContainer)
294+
# Manual adapt_structure since we have aliasing memory
303295
function Adapt.adapt_structure(to, interfaces::P4estInterfaceContainer)
304296
# Adapt underlying storage
305297
_u = Adapt.adapt_structure(to, interfaces._u)
@@ -331,7 +323,7 @@ mutable struct P4estBoundaryContainer{NDIMS, uEltype <: Real, NDIMSP1,
331323
DenseVector{NTuple{NDIMS, Symbol}},
332324
uVector <: DenseVector{uEltype}, ArrayType,
333325
Bool} <:
334-
AbstractHeterogeneousContainer{ArrayType, Bool}
326+
AbstractContainer
335327
u::uArray # [variables, i, j, boundary]
336328
neighbor_ids::IdsVector # [boundary]
337329
node_indices::IndicesVector # [boundary]
@@ -443,11 +435,7 @@ function init_boundaries_iter_face_inner(info_pw, boundaries, boundary_id, mesh)
443435
return nothing
444436
end
445437

446-
# Required methods due to <: AbstractHeterogeneousContainer
447-
function KernelAbstractions.get_backend(boundaries::P4estBoundaryContainer)
448-
return KernelAbstractions.get_backend(boundaries.u)
449-
end
450-
#Adapt.@adapt_structure(P4estBoundaryContainer)
438+
# Manual adapt_structure since we have aliasing memory
451439
function Adapt.adapt_structure(to, boundaries::P4estBoundaryContainer)
452440
_u = Adapt.adapt_structure(to, boundaries._u)
453441
u = unsafe_wrap_or_alloc(to, _u, size(boundaries.u))
@@ -497,7 +485,7 @@ mutable struct P4estMortarContainer{NDIMS, uEltype <: Real, NDIMSP1, NDIMSP3,
497485
IndicesVector <:
498486
DenseVector{NTuple{NDIMS, Symbol}},
499487
ArrayType, Bool} <:
500-
AbstractHeterogeneousContainer{ArrayType, Bool}
488+
AbstractContainer
501489
u::uArray # [small/large side, variable, position, i, j, mortar]
502490
neighbor_ids::IdsMatrix # [position, mortar]
503491
node_indices::IndicesMatrix # [small/large, mortar]
@@ -584,11 +572,7 @@ function init_mortars!(mortars, mesh::P4estMesh)
584572
return mortars
585573
end
586574

587-
# Required methods due to <: AbstractHeterogeneousContainer
588-
function KernelAbstractions.get_backend(mortars::P4estMortarContainer)
589-
return KernelAbstractions.get_backend(mortars.u)
590-
end
591-
# Adapt.@adapt_structure P4estMortarContainer
575+
# Manual adapt_structure since we have aliasing memory
592576
function Adapt.adapt_structure(to, mortars::P4estMortarContainer)
593577
# Adapt underlying storage
594578
_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
@@ -114,5 +114,6 @@ function initialize!(boundary_types_container::UnstructuredSortedBoundaryTypes{N
114114
return boundary_types_container
115115
end
116116

117-
Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
117+
# @eval due to @muladd
118+
@eval Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
118119
end # @muladd

0 commit comments

Comments
 (0)