From 0d899a9549dcaa1abbd98b7925bdf55f843982b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bignonnet?= <108350529+fbignonnet@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:57:08 +0200 Subject: [PATCH] Update multiarrays_r2c.jl (#75) Fix efficiency of view to real data vector using unsafe_wrap --- src/multiarrays_r2c.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multiarrays_r2c.jl b/src/multiarrays_r2c.jl index 0faf8c5b..f4a06e0f 100644 --- a/src/multiarrays_r2c.jl +++ b/src/multiarrays_r2c.jl @@ -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}`. @@ -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)