Skip to content
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

Make interpolate_array GPU compatibile #1509

Closed
Sbozzolo opened this issue Oct 20, 2023 · 1 comment
Closed

Make interpolate_array GPU compatibile #1509

Sbozzolo opened this issue Oct 20, 2023 · 1 comment
Labels
bug Something isn't working GPU

Comments

@Sbozzolo
Copy link
Member

function interpolate_slab(
field::Fields.Field,
slabidx::Fields.SlabIndex,
(I1,)::Tuple{<:AbstractArray},
)
space = axes(field)
x = zero(eltype(field))
QS = Spaces.quadrature_style(space)
Nq = Spaces.Quadratures.degrees_of_freedom(QS)
for i in 1:Nq
ij = CartesianIndex((i,))
x += I1[i] * Operators.get_node(space, field, ij, slabidx)
end
return x
end
function interpolate_slab(
field::Fields.Field,
slabidx::Fields.SlabIndex,
(I1, I2)::Tuple{<:AbstractArray, <:AbstractArray},
)
space = axes(field)
x = zero(eltype(field))
QS = Spaces.quadrature_style(space)
Nq = Spaces.Quadratures.degrees_of_freedom(QS)
for j in 1:Nq, i in 1:Nq
ij = CartesianIndex((i, j))
x += I1[i] * I2[j] * Operators.get_node(space, field, ij, slabidx)
end
return x
end

These functions do not run on a GPU because of the explicit indexing.

A temporary workaround might be to make them vector/matrix multiplications by allocating locally a matrix with the values of the nodes. This might be acceptable for the moment, given that Nq is typically not very large and because this is done only when the diagnostic is output (which might be once every 12 hours).

@Sbozzolo Sbozzolo added bug Something isn't working GPU labels Oct 20, 2023
@Sbozzolo
Copy link
Member Author

Closed by #1512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GPU
Projects
None yet
Development

No branches or pull requests

1 participant