Skip to content

Commit

Permalink
Update multiarrays_r2c.jl (#75)
Browse files Browse the repository at this point in the history
Fix efficiency of view to real data vector using unsafe_wrap
  • Loading branch information
fbignonnet authored Sep 25, 2024
1 parent 4d7a16c commit 0d899a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/multiarrays_r2c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PencilArrays: AbstractManyPencilArray, _make_arrays
ManyPencilArrayRFFT!{T,N,M} <: AbstractManyPencilArray{N,M}
Container holding `M` different [`PencilArray`](https://jipolanco.github.io/PencilArrays.jl/dev/PencilArrays/#PencilArrays.PencilArray) views to the same
underlying data buffer. All views share the same and dimensionality `N`.
underlying data buffer. All views share the same dimensionality `N`.
The element type `T` of the first view is real, that of subsequent views is
`Complex{T}`.
Expand Down Expand Up @@ -72,7 +72,7 @@ function _make_real_array(data, extra_dims, p)
dims = (dims_padded_local..., extra_dims...)
axes_local = (Base.OneTo.(dims_space_local)..., Base.OneTo.(extra_dims)...)
n = prod(dims)
vec = view(data, Base.OneTo(n))
vec = unsafe_wrap(typeof(data), pointer(data), n) # fixes efficiency issues with vec = view(data, Base.OneTo(n))
parent_arr = reshape(vec, dims)
arr = view(parent_arr, axes_local...)
PencilArray(p, arr)
Expand Down

0 comments on commit 0d899a9

Please sign in to comment.