-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Adapt.jl to change storage and element type #2212
base: main
Are you sure you want to change the base?
Conversation
In order to eventually support GPU computation we need to use Adapt.jl to allow GPU backend packages to swap out host-array types like `CuArray` with device-side types like `CuDeviceArray`. Additionally this will allow us to change the element type of a simulation by using `adapt(Array{Float32}`. Co-authored-by: Lars Christmann <[email protected]> Co-authored-by: Benedict Geihe <[email protected]>
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
performance_counter::PerformanceCounter) where {Mesh, Equations, | ||
InitialCondition, | ||
BoundaryConditions, | ||
SourceTerms, | ||
Solver, | ||
Cache} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
performance_counter::PerformanceCounter) where {Mesh, Equations, | |
InitialCondition, | |
BoundaryConditions, | |
SourceTerms, | |
Solver, | |
Cache} | |
performance_counter::PerformanceCounter) where { | |
Mesh, | |
Equations, | |
InitialCondition, | |
BoundaryConditions, | |
SourceTerms, | |
Solver, | |
Cache | |
} |
SemidiscretizationHyperbolic{typeof(mesh), typeof(equations), | ||
typeof(initial_condition), | ||
typeof(_boundary_conditions), typeof(source_terms), | ||
typeof(solver), typeof(cache)}(mesh, equations, | ||
initial_condition, | ||
_boundary_conditions, | ||
source_terms, solver, | ||
cache) | ||
cache, performance_counter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
cache, performance_counter) | |
cache, | |
performance_counter) |
initial_condition, | ||
boundary_conditions, | ||
source_terms, solver, | ||
cache, performance_counter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
cache, performance_counter) | |
cache, | |
performance_counter) |
_contravariant_vectors = Adapt.adapt_structure(to, elements._contravariant_vectors) | ||
_inverse_jacobian = Adapt.adapt_structure(to, elements._inverse_jacobian) | ||
_surface_flux_values = Adapt.adapt_structure(to, elements._surface_flux_values) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
neighbor_ids = unsafe_wrap_or_alloc(to, _neighbor_ids, size(interfaces.neighbor_ids)) | ||
node_indices = unsafe_wrap_or_alloc(to, _node_indices, size(interfaces.node_indices)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
neighbor_ids = unsafe_wrap_or_alloc(to, _neighbor_ids, size(interfaces.neighbor_ids)) | |
node_indices = unsafe_wrap_or_alloc(to, _node_indices, size(interfaces.node_indices)) | |
neighbor_ids = unsafe_wrap_or_alloc(to, _neighbor_ids, | |
size(interfaces.neighbor_ids)) | |
node_indices = unsafe_wrap_or_alloc(to, _node_indices, | |
size(interfaces.node_indices)) |
neighbor_ids = unsafe_wrap_or_alloc(to, _neighbor_ids, size(mortars.neighbor_ids)) | ||
node_indices = unsafe_wrap_or_alloc(to, _node_indices, size(mortars.node_indices)) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
_u, _node_indices, | ||
_normal_directions) | ||
NDIMS + 3, typeof(u), | ||
typeof(_u), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
typeof(_u), | |
typeof(_u), |
@@ -5,12 +5,12 @@ | |||
@muladd begin | |||
#! format: noindent | |||
|
|||
mutable struct P4estMPICache{uEltype} | |||
mutable struct P4estMPICache{BufferType <: DenseVector, VecInt <: DenseVector{<:Integer}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
mutable struct P4estMPICache{BufferType <: DenseVector, VecInt <: DenseVector{<:Integer}} | |
mutable struct P4estMPICache{BufferType <: DenseVector, | |
VecInt <: DenseVector{<:Integer}} |
|
||
function Adapt.adapt_structure(to, mpi_cache::P4estMPICache) | ||
mpi_neighbor_ranks = mpi_cache.mpi_neighbor_ranks | ||
mpi_neighbor_interfaces = Adapt.adapt_structure(to, mpi_cache.mpi_neighbor_interfaces) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
mpi_neighbor_interfaces = Adapt.adapt_structure(to, mpi_cache.mpi_neighbor_interfaces) | |
mpi_neighbor_interfaces = Adapt.adapt_structure(to, | |
mpi_cache.mpi_neighbor_interfaces) |
@assert eltype(mpi_send_buffers) == eltype(mpi_recv_buffers) | ||
BufferType = eltype(mpi_send_buffers) | ||
VecInt = eltype(mpi_neighbor_interfaces) | ||
return P4estMPICache{BufferType, VecInt}(mpi_neighbor_ranks, mpi_neighbor_interfaces, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return P4estMPICache{BufferType, VecInt}(mpi_neighbor_ranks, mpi_neighbor_interfaces, | |
return P4estMPICache{BufferType, VecInt}(mpi_neighbor_ranks, | |
mpi_neighbor_interfaces, |
In order to eventually support GPU computation we need
to use Adapt.jl to allow GPU backend packages to swap
out host-array types like
CuArray
with device-side typeslike
CuDeviceArray
.Additionally this will allow us to change the element type
of a simulation by using
adapt(Array{Float32}
.Co-authored-by: Lars Christmann [email protected]
Co-authored-by: Benedict Geihe [email protected]