JuliaSIMD / JuliaSIMD/StrideArrays.jl

`reinterpret` ignores column stride of `view(ptr_array, 1:2, :)`

Open
#95 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
59
Forks
9
PR merge metrics
No merged PRs in 30d

Description

`reinterpret(reshape, SVector{2, Float64}, view(ptr_array, 1:2, :))` appears to ignore the column stride of the `PtrArray` view and reads contiguous pairs instead:
```julia
using StrideArraysCore
using StaticArrays

raw = collect(1.0:12.0)

ptr = PtrArray(pointer(raw), (3, 4))
view_ = view(ptr, 1:2, :)
copied_array = Array(view_)

svectors = reinterpret(reshape, SVector{2, Float64}, view_)
svectors_array = reinterpret(reshape, SVector{2, Float64}, copied_array)

println(collect(svectors))
println(collect(svectors_array))
```
Expected:
```julia
SVector{2, Float64}[[1.0, 2.0], [4.0, 5.0], [7.0, 8.0], [10.0, 11.0]]
SVector{2, Float64}[[1.0, 2.0], [4.0, 5.0], [7.0, 8.0], [10.0, 11.0]]
```
Actual:
```julia
SVector{2, Float64}[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]
SVector{2, Float64}[[1.0, 2.0], [4.0, 5.0], [7.0, 8.0], [10.0, 11.0]]
```
Note that this is not a show/print bug:
```julia
julia> sum.(svectors)
4-element Vector{Float64}:
3.0
7.0
11.0
15.0

julia> sum.(svectors_array)
4-element Vector{Float64}:
3.0
9.0
15.0
21.0
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the Julia reproducer with StrideArraysCore and StaticArrays, comparing reinterpret on the PtrArray view with reinterpret on copied_array. Trace the reinterpret(reshape, SVector{2, Float64}, ...) entry point and how it handles the view's column stride. Done means collect(svectors) and sum.(svectors) match the copied-array results.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.