Skip to content

Commit

Permalink
Force allocation for interpolate on CPU
Browse files Browse the repository at this point in the history
MPI.reduce does not always allocate a new array. As a result, the
remapper in interpolate calls may retain ownership of the output array
  • Loading branch information
Sbozzolo committed Mar 12, 2024
1 parent a594d69 commit 819a3e8
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/Remapping/distributed_remapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -679,23 +679,6 @@ interpolated data.
`_collect_and_return_interpolated_values!` is type-unstable and allocates new return arrays.
"""
function _collect_and_return_interpolated_values!(remapper::Remapper)
return _collect_and_return_interpolated_values!(
remapper::Remapper,
ClimaComms.device(remapper.comms_ctx),
)
end

function _collect_and_return_interpolated_values!(
remapper::Remapper,
::ClimaComms.AbstractCPUDevice,
)
ClimaComms.reduce(remapper.comms_ctx, remapper._interpolated_values, +)
end

function _collect_and_return_interpolated_values!(
remapper::Remapper,
::ClimaComms.CUDADevice,
)
ClimaComms.reduce!(remapper.comms_ctx, remapper._interpolated_values, +)
return ClimaComms.iamroot(remapper.comms_ctx) ?
Array(remapper._interpolated_values) : nothing
Expand Down

0 comments on commit 819a3e8

Please sign in to comment.